1、看看两台服务器的设置:

主服务器              192.168.1.210     安装sersync

目标同步服务器 192.168.1.211     开启rsync服务

 

2、在机器上安装rsync

 
  
  1. yum -y install rsync 

 

 

3、在目标同步服务器(192.168.1.211)上配置rsync

 vi /etc/rsyncd.conf
 
  
  1. uid=root 
  2. gid=root 
  3. max connections=36000 
  4. use chroot=no 
  5. log file=/var/log/rsyncd.log  
  6. pid file=/var/run/rsyncd.pid  
  7. lock file=/var/run/rsyncd.lock  
  8.  
  9. [tongbu]  
  10. path=/opt/tongbu  
  11. comment  = xoyo video files  
  12. ignore errors = yes 
  13. read only = no 
  14. hosts allow =  192.168.1.210/24  
  15. hosts deny = * 

保存退出!

然后启动服务

 rsync --daemon

查看进程,确认服务正常开启

 [root@localhost ~]# netstat -tunlp | grep rsync
tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      3318/rsync         
tcp        0      0 :::873                      :::*                        LISTEN      3318/rsync

 

 

4、在主服务器(192.168.1.210)上安装并配置sersync

tar zxvf sersync2.5_32bit_binary_stable_final.tar.gz
cd GNU-Linux-x86/

在目录下我们可以看见两个文件confxml.xml 和 sersync2,其中xml是相关的配置信息,sersync2是一个程序文件

 vi confxml.xml
 
  
  1. <localpath watch="/opt/tongbu"> 
  2.   <remote ip="192.168.1.211" name="tongbu"/> 
  3.   <!--<remote ip="192.168.8.39" name="tongbu"/>--> 
  4.   <!--<remote ip="192.168.8.40" name="tongbu"/>--> 
  5. </localpath> 

把这里的配置填好,很简单,watch就是监控本地的目录,remote就是远程机器的信息,name填写刚才在目标同步服务器上的rsync的配置文件上的信息,然后确保目录存在,并权限正确,就可以开始运行程序:

同步之前可以先进行整体同步一次:

 ./sersync2 -r

然后后台运行程序,监控目录

 sersync -d

如果有多个XML可以加参数来指定

 sersync -d -o config.xml

运行后可以看见一段这样的信息:

 
  
  1. set the system param  
  2. execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches  
  3. execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events  
  4. parse the command param  
  5. option: -d      run as a daemon  
  6. daemon thread num: 10  
  7. parse xml config file  
  8. host ip : localhost     host port: 8008  
  9. daemon start,sersync run behind the console   
  10. config xml parse success  
  11. please set /etc/rsyncd.conf max connections=0 Manually  
  12. sersync working thread 112  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads)   
  13. Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)  
  14. please according your cpu ,use -n param to adjust the cpu rate  
  15. run the sersync:   
  16. watch path is: /opt/tongbu 

没有报错,再看看进程:

 [root@localhost GNU-Linux-x86]# ps -aef | grep sersync2
root     30868     1  0 01:03 ?        00:00:00 ./sersync2 -d
root     30896 30809  0 01:04 pts/3    00:00:00 grep sersync2

OK!服务正在后台运行!

然后可以去试试在目录下新建些东西看看是否成功!