Sersync 服务

主要内容:

1.Sersync是什么

2.准备环境

3.Sersync的使用

4.Sersync的配置

一、Sersync是什么

实时同步:sersync/inotify
sersync:整合inotify和rsync命令
监控文件/目录是否有变化(增删改)

二、准备环境

web01
nfs01
backup

三、sersync的使用

服务端:

1.准备rsync服务

(1)sersync 利用到了rsync的守护进程模式
(2)backup上面的共享目录为 /nfsbackup

2.准备好sersync

(1)上传 解压 加权限

上传:

QQ图片20190526230726.png

解压

[root@nfs01 tools]# tree
.
└── sersync_installdir_64bit.zip

0 directories, 1 file
[root@nfs01 tools]# 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@nfs01 tools]# tree 
.
├── sersync_installdir_64bit
│?? └── sersync
│??     ├── bin
│??     │?? └── sersync
│??     ├── conf
│??     │?? └── confxml.xml
│??     └── logs
└── sersync_installdir_64bit.zip

5 directories, 3 files

加权限

[root@nfs01 bin]# chmod +x  /app/sersync/bin/sersync 
[root@nfs01 bin]# sersync 
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
XML Parsing error inside file 'confxml.xml'.
Error: File not found
At line 0, column 0.
[root@nfs01 bin]# 

(2)创建软连接

[root@nfs01 app]# ln -s /app/sersync/bin/sersync  /sbin/sersync
[root@nfs01 app]# sersync
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
XML Parsing error inside file 'confxml.xml'.
Error: File not found
At line 0, column 0.

(3)配置

[root@nfs01 ~]# diff /app/sersync/conf/confxml.xml  ./confxml.xml 
5c5
<     <fileSystem xfs="true"/>
---
>     <fileSystem xfs="false"/>
24c24
<   <localpath watch="/upload">
---
>   <localpath watch="/opt/tongbu">
30,31c30,31
<       <commonParams params="-az"/>
<       <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
---
>       <commonParams params="-artuz"/>
>       <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
36c36
<   <failLog path="/var/log/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
---
>   <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->

客户端

[root@backup ~]# vim /etc/rsyncd.conf 
##created by oldboy 15:01 2009-6-5
##rsyncd.conf start##
fake super = yes
uid = rsync
gid = rsync
use chroot = no
max connections = 2000
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
#hosts allow = 10.0.0.0/24
#hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
#####################################
[backup]
comment = www by old0boy 14:18 2012-1-13
path = /backup
#####################################
[nfsbackup]
comment = www by old0boy 14:18 2012-1-13
path = /nfsbackup
#####################################
[upload]
comment = www by old0boy 14:18 2012-1-13
path = /upload            
[root@backup ~]# mkdir /upload
[root@backup ~]# chown rsync.rsync  /upload/
[root@backup ~]# ll -d /upload/
drwxr-xr-x 2 rsync rsync 6 May 26 23:37 /upload/
[root@backup ~]# systemctl restart  rsyncd

(4)启动serrsync服务:
sersync -rd -o /app/sersync/conf/confxml.xml

[root@nfs01 ~]# diff   ./confxml.xml  /app/sersync/conf/confxml.xml 
5c5
<     <fileSystem xfs="false"/>
---
>     <fileSystem xfs="true"/>
24,25c24,25
<   <localpath watch="/opt/tongbu">
<       <remote ip="127.0.0.1" name="tongbu1"/>
---
>   <localpath watch="/upload">
>       <remote ip="172.16.1.41" name="nfsbackup"/>
30,31c30,31
<       <commonParams params="-artuz"/>
<       <auth start="false" users="root" passwordfile="/etc/rsync.pas"/>
---
>       <commonParams params="-az"/>
>       <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
36c36
<   <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
---
>   <failLog path="/var/log/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
[root@nfs01 ~]# 
[root@nfs01 ~]# 
[root@nfs01 ~]# sersync  -rd  -o  /app/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:  /app/sersync/conf/confxml.xml
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
WARNING XFS FILE SYSTEM WORK
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)
please according your cpu ,use -n param to adjust the cpu rate
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /upload && rsync -az -R --delete ./ rsync_backup@172.16.1.41::nfsbackup --password-file=/etc/rsync.password >/dev/null 2>&1 
run the sersync: 
watch path is: /upload
QQ图片20190526234836.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容