前版本的sersync依赖于rsync进行同步。如下图所示,在同步主服务器上开启sersync,将监控路径中的文件同步到目标服务器,因此需要在主 服务器配置sersync,在同步目标服务器配置rsync。对于rsync配置,在google上可以找到很多资料,以下只是一些必要的配置和使用说 明,仅供参考,请根据您的实际情况修改。
confxml.xml sersync2
[root@localhost GNU-Linux-x86]# ./sersync2 -d
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
daemon thread num : 10
parse xml config file
host ip : localhost host port : 8008
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)
please according your cpu ,use -n param to adjust the cpu rate
run the sersync :
watch path is : /opt/tongbu
[root@localhost GNU-Linux-x86]# ./sersync2 -d
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
daemon thread num : 10
parse xml config file
host ip : localhost host port : 8008
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)
please according your cpu ,use -n param to adjust the cpu rate
run the sersync :
watch path is : /opt/tongbu
表明,sersync已经开启,可以在本地监控路径下建立文件,查看远程是否同步成功。
2.在开启实时监控的之前对主服务器目录与远程目标机目录进行一次整体同步
./sersync -r
如果需要将sersync运行前,已经存在的所有文件或目录全部同步到远程,要以-r参数运行sersync,将本地与远程整体同步一次。
如果设置了过滤器,即在xml文件中,filter为true,则暂时不能使用-r参数进行整体同步。-r参数将会无效
3.查看启动参数帮助
./sersync --help
4.指定配置文件
./sersync -o XXXX.xml
对于sersync使用可执行文件目录下的默认配置文件confxml.xml,如果需要使用另一个配置文件,可以使用-o参数指定其它配置文件。
5.指定默认的线程池的线程总数
./sersync -n num
例如 ./sersync -n 5 则指定线程总数为5,如果不指定,默认启动线程池数量是10,如果cpu使用过高,可以通过这个参数调低,如果机器配置较高,可以用-n跳高线程总数。
6.不进行同步,只运行插件
./sersync -m pluginName
例如./sersync -m command,则在监控到文件事件后,不对远程目标服务器进行同步,而是直接运行command插件。
7.多个参数可以配合使用
./sersync -n 8 -o abc.xml -r -d
表示,设置线程池工作线程为8个,指定abc.xml作为配置文件,在实时监控前作一次整体同步,以守护进程方式在后台运行。
8.通常情况下, 对本地到远程整体同步一遍后,在后台运行实时同步。
./sersync -r -d
转载于:https://blog.51cto.com/luoning504/688608