sersync功能:
sersync组成:
sersync工作原理:
参照https://www.cnblogs.com/zoe233/p/12035383.html的部署过程。
注意:部署过程中将inotify监听服务和rsync同步数据的过程的脚本/server/scripts/inotifywait_nfs_to_backup.sh
通过/etc/init.d/syncd脚本加入了chkconfig开机自启动服务,可以通过/etc/init.dsyncd [start|stop]启动或关闭服务。
为了避免冲突,将相关所有服务关闭:
chkconfig syncd off
/etc/init.d/syncd stop
上传sersync安装包到NFS服务端指定目录下。
一般使用rz命令上传,由于secureCRT的transfer命令在mac上出现问题,使用scp命令传输文件。
scp `pwd`/sersync_installdir_64bit.zip root@192.168.0.31:/application
在nfs-31主机上进行操作:
# 创建目录
[root@nfs-31 /]# mkdir /application -p
[root@nfs-31 application]# ls
sersync_installdir_64bit.zip
[root@nfs-31 application]# unzip ./sersync_installdir_64bit.zip
Archive: ./sersync_installdir_64bit.zip
creating: sersync_installdir_64bit/
creating: sersync_installdir_64bit/sersync/
creating: sersync_installdir_64bit/sersync/bin/
inflating: sersync_installdir_64bit/sersync/bin/sersync
creating: sersync_installdir_64bit/sersync/conf/
inflating: sersync_installdir_64bit/sersync/conf/confxml.xml
creating: sersync_installdir_64bit/sersync/logs/
[root@nfs-31 application]# ls
sersync_installdir_64bit sersync_installdir_64bit.zip
[root@nfs-31 application]# cd sersync_installdir_64bit
[root@nfs-31 sersync_installdir_64bit]# ls
sersync
[root@nfs-31 sersync_installdir_64bit]# mv ./sersync/ /application/
[root@nfs-31 sersync_installdir_64bit]# ls
[root@nfs-31 sersync_installdir_64bit]# cd ..
[root@nfs-31 application]# ls
sersync sersync_installdir_64bit sersync_installdir_64bit.zip
[root@nfs-31 bin]# ll /application/sersync/bin
total 1768
-rw-r--r-- 1 root root 1810128 Oct 26 2011 sersync
[root@nfs-31 bin]# chmod +x /application/sersync/bin/sersync
[root@nfs-31 sersync]# ln -s /application/sersync/bin/sersync /sbin/
[root@nfs-31 sbin]# ll /sbin/sersync
lrwxrwxrwx 1 root root 32 Dec 13 19:04 /sbin/sersync -> /application/sersync/bin/sersync
配置sersync之前,先单独使用rsync服务推送一次,确定rsync服务正常以及各项参数的准确。
[root@nfs-31 conf]# cat confxml.xml -n
1
2
37
43
44
修改相应配置:
22
23 <sersync> # 同步的部分
24 ** <localpath watch="/data">** # 同步的源,目录
25 **<remote ip="192.168.0.41" name="nfsbackup"/> ** # ip是推送的机器的ip,name是rsync推送指定的模块
28 </localpath>
29 <rsync> # rsync命令的各个参数
30 ** <commonParams params="-az"/>** # 参数选项
31 **<auth start="true" users="rsync\_backup" passwordfile="/etc/rsync.password"/>** # 连接用户和用户的指定密码文件
32 <userDefinedPort start="false" port=""/><!-- port=874 --> # 是否指定端口,false使用默认端口873
33 **<timeout start="true" time=""/><!-- timeout=100 -->** # 超时设置
34 <ssh start="false"/>
35 </rsync>
36 **<failLog path="/tmp/rsync\_fail\_log.sh" timeToExecute=""/> # 失败日志 **
sersync命令参数说明:
[root@nfs-31 ~]# sersync -h
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
_______________________________________________________
参数-d:启用守护进程模式
参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍
c参数-n: 指定开启守护线程的数量,默认为10个
参数-o:指定配置文件,默认使用confxml.xml文件
参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块
参数-m:单独启用其他模块,使用 -m socket 开启socket模块
参数-m:单独启用其他模块,使用 -m http 开启http模块
不加-m参数,则默认执行同步程序
______________________________________________________________
服务启动后,将过程文件中rsync服务命令粘贴出来单独执行一遍,检验配置文件信息是否填写正确。
[root@nfs-31 ~]# sersync -rdo /application/sersync/conf/confxml.xml
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: -r rsync all the local files to the remote servers before the sersync work
option: -d run as a daemon
option: -o config xml name: /application/sersync/conf/confxml.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)
rsync the directory recursivly to the remote servers once
working please wait…
execute command: cd /data && rsync -az -R --delete ./ --timeout=100 rsync_backup@192.168.0.41::nfsbackup --password-file=/etc/rsync.password >/dev/null 2>&1
run the sersync:
watch path is: /data
[root@nfs-31 ~]# ps -ef|grep sersync|grep -v grep
root 20924 1 0 21:33 ? 00:00:00 sersync -rdo /application/sersync/conf/confxml.xml
[root@nfs-31 ~]# tail -2 /etc/rc.local
注意:sersync服务的开机自启动和inotify的开机自启动最好不要冲突,只选其一。
手机扫一扫
移动阅读更方便
你可能感兴趣的文章