Sersync 服務(wù)

主要內(nèi)容:

1.Sersync是什么

2.準(zhǔn)備環(huán)境

3.Sersync的使用

4.Sersync的配置

一、Sersync是什么

實(shí)時(shí)同步:sersync/inotify
sersync:整合inotify和rsync命令
監(jiān)控文件/目錄是否有變化(增刪改)

二、準(zhǔn)備環(huán)境

web01
nfs01
backup

三、sersync的使用

服務(wù)端:

1.準(zhǔn)備rsync服務(wù)

(1)sersync 利用到了rsync的守護(hù)進(jìn)程模式
(2)backup上面的共享目錄為 /nfsbackup

2.準(zhǔn)備好sersync

(1)上傳 解壓 加權(quán)限

上傳:

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

加權(quán)限

[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)創(chuàng)建軟連接

[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)啟動(dòng)serrsync服務(wù):
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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容