标签:path hosts 开始 客户端 secret 文件同步 progress 清除 rdf
yum install rsync #安装rsync,如果嫌yum版本过低也可以源码安装
#Rsync server
uid = root
gid = root
use chroot = no # 安全相关
max connections = 2000 # 并发连接数
timeout = 600 # 超时时间(秒)
pid file =/var/run/rsyncd.pid # 指定rsync的pid目录
lock file =/var/run/rsync.lock # 指定rsync的锁文件【重要】
log file = /var/log/rsyncd.log # 指定rsync的日志目录
ignore errors #忽略一些I/O错误
read only = false #设置rsync服务端文件为读写权限
list = false #不显示rsync服务端资源列表
hosts allow = 10.1.0.0/16 #允许进行数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
hosts deny = 0.0.0.0/32 #禁止数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
auth users = rsync_backup #执行数据同步的用户名,可以设置多个,用英文状态下逗号隔开
secrets file =/etc/rsync.password #用户认证配置文件,里面保存用户名称和密码
#################################################
[www] # 模块
comment = www
path = /data/www/
#################################################
[bbs]
comment = bbs
path = /data/bbs/
#################################################
[blog]
comment = blog
path = /data/blog/
#rsync_config____________end
:wq! #保存,退出
echo "rsync_backup:123456">/etc/rsync.password #配置文件,添加以下内容
chmod 600 /etc/rsync.password
rsync --daemon
vim /etc/rc.local
# rsync server progress
/usr/bin/rsync --daemon
mkdir -p /data/{www,bbs,blog}
touch /etc/rsyncd.conf
echo "123456">/etc/rsync.password
chmod 600 /etc/rsync.password
mkdir -p /data/{www,bbs,blog}
touch /data/www/www.log /data/bbs/bbs.log /data/blog/blog.log
rsync -avzP /data/www/ rsync_backup@172.16.1.25::www/ --password-file=/etc/rsync.password
#rsync -avzP /backup/ rsync://rsync_backup@192.168.1.11/backup/ --password-file=/etc/rsync.password 两种方法
#rsync -avzP /backup/ rsync://rsync_backup@192.168.1.11/backup/test/ --password-file=/etc/rsync.password #test为服务器上的目录
参数: --delete 无差异同步
--bwlimit=KB/S 限速
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE read exclude patterns from FILE
--include=PATTERN don’t exclude files matching PATTERN
--include-from=FILE read include patterns from FILE
#此步骤必须成功才能进行下一步
tar fxzsersync2.5.4_64bit_binary_stable_final.tar.gz -C /usr/local/
cd /usr/local/
mv GNU-Linux-x86 sersync
cp sersync/confxml.xml sersync/confxml.xml-bak
vim sersync/confxml.xml
修改24--28行
24 <localpath watch="/opt/tongbu">
25 <remote ip="127.0.0.1" name="tongbu1"/>
26 <!--<remote ip="192.168.8.39" name="tongbu"/>-->
27 <!--<remote ip="192.168.8.40" name="tongbu"/>-->
28 </localpath>
修改后的内容为:
24 <localpath watch="/data/www">
25 <remote ip="10.1.20.109" name="www"/>
26 </localpath>
修改29--35行,认证部分(rsync密码认证)
29 <rsync>
30 <commonParams params="-artuz"/>
31 <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
32 <userDefinedPort start="false" port="874"/><!-- port=874 -->
33 <timeout start="false" time="100"/><!-- timeout=100 -->
34 <ssh start="false"/>
35 </rsync>
修改后的内容如下:
27 <rsync>
28 <commonParams params="-artuz"/>
29 <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
30 <userDefinedPort start="false" port="874"/><!-- port=874 -->
31 <timeout start="true" time="100"/><!-- timeout=100 -->
32 <ssh start="false"/>
33 </rsync>
/usr/local/sersync/sersync2 -d -r -o /usr/local/sersync/confxml.xml
配置sersync环境变量
echo"PATH=$PATH:/usr/local/sersync/">>/etc/profile
source /etc/profile
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
option: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: ./confxml.xml
daemon thread num: 10
parse xml config file
XML Parsing error inside file ‘./confxml.xml‘.
Error: File not found
At line 0, column 0.
set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
option: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: ./confxml-www.xml
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
daemon start,sersync run behind the console
use rsync password-file :
user is rsync_backup
passwordfile is /etc/rsync.password
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12 = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /data/www && rsync -artuz -R --delete ./ --timeout=100 rsync_backup@10.1.20.109::www --password-file=/etc/rsync.password >/dev/null 2>&1
run the sersync:
watch path is: /data/www
1、配置多个confxml.xml文件(比如:www、bbs、blog....等等)
confxml-bbs.xml confxml-blog.xml confxml-www.xml(按照单个实例配置即可)
2、根据不同的需求同步对应的实例文件
rsync -avzP /data/www/ rsync_backup@10.1.20.109::www/ --password-file=/etc/rsync.password
rsync -avzP /data/bbs/ rsync_backup@10.1.20.109::bbs/ --password-file=/etc/rsync.password
rsync -avzP /data/test/ rsync_backup@10.1.20.109::blog/ --password-file=/etc/rsync.passwor
分别启动即可
标签:path hosts 开始 客户端 secret 文件同步 progress 清除 rdf
原文地址:http://www.cnblogs.com/panwenbin-logs/p/7742288.html