sersync实践

作者:马帅琦
归档:day36
时间:2019/4/19
sersync实践:
1)客户端推送成功

rsync -az /data [email protected]::backup

2)部署sersync服务(NFS)

[root@nfs01 /]# cd /server/tools/
[root@nfs01 /server/tools]#wget https://github.com/wsgzao/sersync/blob/master/sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@nfs01 /server/tools]# ls
sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@nfs01 /server/tools]# mkdir /application -p
[root@nfs01 /server/tools]# mv application/sersync /application/
[root@nfs01 /server/tools]# tree /application/
/application/
└── sersync
    ├── bin
    │   └── sersync
    ├── conf
    │   ├── confxml.xml
    │   └── confxml.xml.ori
    ├── logs
    │   └── rsync_fail_log.sh
    └── readme.txt

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 [email protected]::backup

4)修改配置

[root@nfs01 /application/sersync/conf]# vim confxml.xml
        
        
        
    
    
        
        
        
        
        
        
        
        
    

    
        
            
            
            
            
"confxml.xml" 67L, 2266C                                                        28,6-13       15%

5)启动服务

[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
_______________________________________________________
参数-d:启用守护进程模式
参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍
c参数-n: 指定开启守护线程的数量,默认为10个
参数-o:指定配置文件,默认使用confxml.xml文件
参数-m:单独启用其他模块,使用 -m refreshCDN 开启刷新CDN模块
参数-m:单独启用其他模块,使用 -m socket 开启socket模块
参数-m:单独启用其他模块,使用 -m http 开启http模块
不加-m参数,则默认执行同步程序
________________________________________________________________
[root@nfs01 /application/sersync/conf]# /application/sersync/bin/sersync -d -n 10 -o /application/sersync/conf/confxml.xml
最终
/application/sersync/bin/sersync -d
pkill sersync
二进制程序,不是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

6)配置:systemctl start sersync启动方案
https://blog.51cto.com/oldboy/2155931


[root@nfs01 /application/sersync/conf]# vim /etc/rc.d/init.d/sersync
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


"/etc/rc.d/init.d/sersync" [新] 30L, 511C 已写入                                
[root@nfs01 /application/sersync/conf]# chmod +x /etc/rc.d/init.d/sersync
[root@nfs01 /application/sersync/conf]# vim /usr/lib/s
sendmail          sendmail.postfix  sse2/             sysctl.d/         systemd/
[root@nfs01 /application/sersync/conf]# vim /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
~                                                                                                 
~                                                                                                 
~                                                                                                 
~                                                                                                 
~                                                                                                 
~                                                                                                 
~                                                                                                 
~                                                                                                 
"/usr/lib/systemd/system/sersync.service" [新] 13L, 280C 已写入                 
[root@nfs01 /application/sersync/conf]# chmod +x /usr/lib/systemd/system/sersync.service
[root@nfs01 /application/sersync/conf]# systemctl enable ser
serial-getty@          [email protected]  sersync.service        
[root@nfs01 /application/sersync/conf]# systemctl enable ser
serial-getty@          [email protected]  sersync.service        
[root@nfs01 /application/sersync/conf]# systemctl enable ser
serial-getty@          [email protected]  sersync.service        
[root@nfs01 /application/sersync/conf]# 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 /application/sersync/conf]# systemctl status sersync.service 
● sersync.service - sersyncd service
   Loaded: loaded (/usr/lib/systemd/system/sersync.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
[root@nfs01 /application/sersync/conf]# systemctl stop sersync
[root@nfs01 /application/sersync/conf]# ps -ef|grep sersync
root      10012      1  0 13:42 ?        00:00:00 /application/sersync/bin/sersync -d -n 10 -o /application/sersync/conf/confxml.xml
root      11767  11390  0 15:30 pts/0    00:00:00 grep --color=auto sersync
[root@nfs01 /application/sersync/conf]# ps -ef|grep sersync|grep -v grep
root      10012      1  0 13:42 ?        00:00:00 /application/sersync/bin/sersync -d -n 10 -o /application/sersync/conf/confxml.xml
[root@nfs01 /application/sersync/conf]# systemctl start sersync
[root@nfs01 /application/sersync/conf]# systemctl status sersync
● sersync.service - sersyncd service
   Loaded: loaded (/usr/lib/systemd/system/sersync.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2019-04-19 15:31:02 +08; 8s ago
  Process: 11777 ExecStart=/etc/rc.d/init.d/sersync start (code=exited, status=0/SUCCESS)
 Main PID: 11781 (sersync)
   CGroup: /system.slice/sersync.service
           └─11781 /application/sersync/bin/sersync -d -o /application/sersync/conf/confxml.xml...

4月 19 15:31:01 nfs01 systemd[1]: Starting sersyncd service...
4月 19 15:31:02 nfs01 systemd[1]: Started sersyncd service.

你可能感兴趣的:(sersync实践)