sersync 文件同步系统(一) 服务初步搭建

简介:

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!服务正在后台运行!

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

本文转自运维笔记博客51CTO博客,原文链接http://blog.51cto.com/lihuipeng/562573如需转载请自行联系原作者


lihuipeng

相关文章
|
6天前
|
Shell 开发工具 数据安全/隐私保护
Rsync 文件同步原理及部署
Rsync 文件同步原理及部署
11 0
|
监控 算法 Linux
Linux 服务器集群下同步目录文件 - rsync
Linux 服务器集群下同步目录文件 - rsync
251 0
|
存储 监控 安全
|
网络安全 数据安全/隐私保护 Windows
|
监控 Linux 数据安全/隐私保护
rsync+sersync实现服务器文件同步
集群件服务器或者是多台服务器之间有数据同步需求的时候,要使多台服务器之间的数据快速同步,使用手动拷贝或者scp这样的命令是不太明智的,rsync+sersync组合工具可以解决这一痛点,快速的同步更新数据文件,减轻运维人员的工作压力。
4434 0
|
Linux
Linux rsync+sersync实现文件时时同步
一.简介 sersync是基于Inotify开发的,类似于Inotify-tools的工具; sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字; rsync在同步的时候,只同步发生变化的这个文件或者这个目录(每次发生变化的数据相对整个同步目录数据来说是很小的,rsync在遍历查找比对文件时,速度很快),因此,效率很高; 注:当同步的目录数据量不大时,建议使用Rsync+Inotify-tools;当数据量很大(几百G甚至1T以上)、文件很多时,建议使用Rsync+sersync。
1143 0
|
Shell 网络安全
Lsyncd - 实时文件同步工具(精译)
原文: http://axkibe.github.io/lsyncd/ 描述 Lsyncd监视本地目录树事件监视器接口(inotify或fsevents)。它聚集并组合事件几秒钟,然后生成一个(或多个)进程(es)来同步这些更改。
3006 0
|
网络安全 数据安全/隐私保护 测试技术