linux_6.5_install_sersync2.5_64bit

sersync是一款基于 inotify + rsync 的大量文件的多服务器自动同步程序,监控文件系统事件,文件实时同步

安装说明===
sersync安全的前提是rsync server和rsync client 已经部署完成,并且rsync client可以推送和拉取数据到rsync server端。

–=安装环境说明====

rsync_server: redhat_6.5_x86_64
eth0: 192.168.16.66

rsync_client: redhat_6.5_x86_64
eth0: 192.168.16.106

rsync version: rsync 3.0.6

–=安装====
[root@rsync_client ~]# tar -zxf sersync2.5_64bit_binary_stable_final.tar.gz -C /usr/local
[root@rsync_client ~]# echo $?
0
[root@rsync_client ~]# cd /usr/local/
[root@rsync_client local]# mv GNU-Linux-x86/ sersync
[root@rsync_client local]# cd sersync
[root@rsync_client sersync]# mkdir conf bin logs
[root@rsync_client sersync]# mv confxml.xml ./conf/
[root@rsync_client sersync]# mv sersync2 ./bin/sersync
[root@rsync_client sersync]# cd conf/
[root@rsync_client conf]# cp confxml.xml confxml.xml.bak

[root@rsync_client conf]# vim confxml.xml

sersync是一款基于 inotify + rsync 的大量文件的多服务器自动同步程序,监控文件系统事件,文件实时同步

安装说明===
sersync安全的前提是rsync server和rsync client 已经部署完成,并且rsync client可以推送和拉取数据到rsync server端。

–=安装环境说明====

rsync_server: redhat_6.5_x86_64
eth0: 192.168.16.66

rsync_client: redhat_6.5_x86_64
eth0: 192.168.16.106

rsync version: rsync 3.0.6

–=安装====
[root@rsync_client ~]# tar -zxf sersync2.5_64bit_binary_stable_final.tar.gz -C /usr/local
[root@rsync_client ~]# echo $?
0
[root@rsync_client ~]# cd /usr/local/
[root@rsync_client local]# mv GNU-Linux-x86/ sersync
[root@rsync_client local]# cd sersync
[root@rsync_client sersync]# mkdir conf bin logs
[root@rsync_client sersync]# mv confxml.xml ./conf/
[root@rsync_client sersync]# mv sersync2 ./bin/sersync
[root@rsync_client sersync]# cd conf/
[root@rsync_client conf]# cp confxml.xml confxml.xml.bak

[root@rsync_client conf]# vim confxml.xml

<sersync>
24 <localpath watch="/data">
25 <remote ip=“192.168.16.66” name=“lbw”/> //name为server端的模块名
26 <!–<remote ip=“192.168.8.39” name=“tongbu”/>–>
27 <!–<remote ip=“192.168.8.40” name=“tongbu”/>–>
28 </localpath>
29 <rsync>
30 <commonParams params="-az"/> //rsync的参数
31 <auth start=“true” users=“rsync_backup” passwordfile="/etc/rsync.password"/> //rsync的认证用户和密码文件
32 <userDefinedPort start=“false” port=“874”/>
33 <timeout start=“false” time=“100”/>
34 <ssh start=“false”/>
35 </rsync>
36 <failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecute=“60”/>
37 <crontab start=“false” schedule=“600”>
38 <crontabfilter start=“false”>
39 <exclude expression=".php">
40 <exclude expression="info/
">
41 </crontabfilter>
42 </crontab>
43 <plugin start=“false” name=“command”/>
44 </sersync>

–===配置sersync环境变量=
[root@rsync_client conf]# echo ‘export PATH=$PATH:/usr/local/sersync/bin’>>/etc/profile
[root@rsync_client local]# source /etc/profile
[root@rsync_client local]# which sersync
/usr/local/sersync/bin/sersync

开启sersync守护进程同步数据==
[root@rsync_client local]# sersync -r -d -o /usr/local/sersync/conf/confxml.xml

-r 初始化同步 删除目标目录下文件 第一次同步时使用,增量备份千万不要加 不然就是完全备份 //如果rsync_server端有文件需要保留,而client端没有,就不要使用-r
-d 后台运行 守护进程daemon
-o 指定配置文件

–==测试sersync=
[root@rsync_client data]# ls
1.zz 5.test 6.txt
[root@rsync_client data]# rm -f *
[root@rsync_client data]# ls
[root@rsync_client data]# touch {1…10}.txt
[root@rsync_client data]# ls
10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt

[root@rsync_server data]# ls
1.zz 5.test 6.txt
[root@rsync_server data]# ls
[root@rsync_server data]# ls
10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt

配置sersync多实例
如果在confxml.xml配置多个实例,测试是不会生效的,解决方案是为多个实例创建不同的配置文件结合多个-o参数指定配置文件。

rsync_server端配置文件如下:
[root@rsync_server ~]# cat /etc/rsyncd.conf
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
hosts allow = 192.168.16.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
ignore errors
read only = false
list = false
[lbw]
path = /data/
[lbw1]
path = /data1/
[lbw2]
path = /data2/
#rsync_config_______________end

rsync_client端sersync配置文件如下:(只做差异比对)
[root@rsync_client data]# diff /usr/local/sersync/conf/lbw_confxml.xml /usr/local/sersync/conf/lbw1_confxml.xml24,25c24,25

[root@rsync_client /]# sersync -r -d -o /usr/local/sersync/conf/lbw_confxml.xml
[root@rsync_client /]# sersync -r -d -o /usr/local/sersync/conf/lbw1_confxml.xml
[root@rsync_client /]# sersync -r -d -o /usr/local/sersync/conf/lbw2_confxml.xml
[root@rsync_client data1]# ps -ef | grep sersync
root 5420 1 0 10:44 ? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/lbw_confxml.xml
root 5455 1 0 10:45 ? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/lbw1_confxml.xml
root 5473 1 0 10:45 ? 00:00:00 sersync -r -d -o /usr/local/sersync/conf/lbw2_confxml.xml
root 5497 1634 0 10:45 pts/0 00:00:00 grep sersync

–=测试多实例数据同步====
[root@rsync_server ~]# ls -ld /data*
drwxr-xr-x 2 rsync rsync 57344 7月 9 10:49 /data
drwxr-xr-x 2 rsync rsync 4096 7月 9 10:49 /data1
drwxr-xr-x 2 rsync rsync 4096 7月 9 10:14 /data2

[root@rsync_client ~]# ls -ld /data*
drwxr-xr-x. 2 root root 4096 Jul 9 10:49 /data
drwxr-xr-x. 2 root root 4096 Jul 9 10:49 /data1
drwxr-xr-x. 2 root root 4096 Jul 9 10:14 /data2

[root@rsync_client data]# for n in `ls -ld /data*|awk ‘{print $9}’` ;do echo test>$n/$n.txt;done

[root@rsync_client data]# ll /data
total 4
-rw-r–r--. 1 root root 5 Jul 9 11:04 data.txt
[root@rsync_client data]# ll /data1
total 4
-rw-r–r--. 1 root root 5 Jul 9 11:04 data1.txt
[root@rsync_client data]# ll /data2
total 4
-rw-r–r--. 1 root root 5 Jul 9 11:04 data2.txt
[root@rsync_client data]# for n in `ls -ld /data*|awk ‘{print $9}’` ;do rm -f $n/$n.txt;done
[root@rsync_client data]# ll /data
total 0
[root@rsync_client data]# ll /data1
total 0
[root@rsync_client data]# ll /data2
total 0

[root@rsync_server ~]# ll /data
总用量 4
-rw-r–r-- 1 rsync rsync 5 7月 9 11:04 data.txt
[root@rsync_server ~]# ll /data1
总用量 4
-rw-r–r-- 1 rsync rsync 5 7月 9 11:04 data1.txt
[root@rsync_server ~]# ll /data2
总用量 4
-rw-r–r-- 1 rsync rsync 5 7月 9 11:04 data2.txt
[root@rsync_server ~]# ll /data
总用量 0
[root@rsync_server ~]# ll /data1
总用量 0
[root@rsync_server ~]# ll /data2
总用量 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值