1)客户端推送成功
rsync -az /data rsync_backup@172.16.1.41::backup
2)部署sersync服务(NFS)
wget https://github.com/wsgzao/sersync/blob/master/sersync2.5.4_64bit_binary_stable_final.tar.gz
sersync_oldboy_64bit_20160928.tar.gz
[root@nfs01 /server/tools]# mkdir /application -p
[root@nfs01 /server/tools]# mv application/sersync /application/
4 directories, 5 files
[root@nfs01 /server/tools]# cd /application/sersync/
[root@nfs01 /application/sersync]# ls
bin conf logs readme.txt
[root@nfs01 /application/sersync]# cd conf/
[root@nfs01 /application/sersync/conf]# ls
confxml.xml confxml.xml.ori
3)sersync配置文件:干两件事:
1)完成监控配置:
inotifywait -mrq --format '%w%f' -e createFolder,close_write,delete,moveFrom,moveTo /data
2)完整命令拼接:
rsync -az /data --timeout=100 rsync_backup@172.16.1.41::backup
4)启动服务
[root@nfs01 /application/sersync/conf]# ../bin/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
[root@nfs01 /application/sersync/conf]# /application/sersync/bin/sersync -d -n 10 -o /application/sersync/conf/confxml.xml
最终
/application/sersync/bin/sersync -d
参数-d:启用守护进程模式
参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍
c参数-n: 指定开启守护线程的数量,默认为10个
参数-o:指定配置文件,默认使用confxml.xml文件
参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块
参数-m:单独启用其他模块,使用 -m socket 开启socket模块
参数-m:单独启用其他模块,使用 -m http 开启http模块
不加-m参数,则默认执行同步程序
二进制程序,不是yum安装的,所以不能systemctl start sersync
配置:systemctl start sersync启动方案
https://blog.51cto.com/oldboy/2155931
[root@nfs01 /data]# tail -1 /etc/rc.local
/application/sersync/bin/sersync -d
配置:systemctl start sersync启动方案
https://blog.51cto.com/oldboy/2155931
[root@nfs01 /data]# cat /etc/rc.d/init.d/sersync
#!/bin/bash
# chkconfig: 2345 21 81
# description: rsync service start and stop scripts
# Author: oldboy
# Organization: www.oldboyedu.com
start(){
/application/sersync/bin/sersync -d -o /application/sersync/conf/confxml.xml &>/dev/null
}
stop(){
killall sersync 2>/dev/null
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
*)
echo $"Usage:$0 {start|stop|restart}"
exit 1
esac
chmod +x /etc/rc.d/init.d/sersync
[root@nfs01 /data]# cat /usr/lib/systemd/system/sersync.service
[Unit]
Description=sersyncd service
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/init.d/sersync start
ExecReload=/etc/rc.d/init.d/sersync restart
ExecStop=/etc/rc.d/init.d/sersync stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
chmod +x /usr/lib/systemd/system/sersync.service
设置开机自启
[root@nfs01 /data]# systemctl enable sersync.service
Created symlink from /etc/systemd/system/multi-user.target.wants/sersync.service to /usr/lib/systemd/system/sersync.service.
[root@nfs01 /data]# systemctl status sersync.service