day 39 sersync服務

一、準備環(huán)境

(一)在backup服務端

1.創(chuàng)建nfsbackup模塊

[root@backup ~]# mkdir /nfsbackup
[root@backup ~]# chown rsync.rsync /nfsbackup
[root@backup ~]# ll /nfsbackup -d
drwxr-xr-x 2 rsync rsync 6 May 25 17:14 /nfsbackup

2.配置rsync文件

[root@backup ~]# vim /etc/rsyncd.conf 

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

3.創(chuàng)建密碼文件

[root@backup ~]# ll /etc/rsync.password 
-rw------- 1 root root 20 May 25 10:56 /etc/rsync.password
[root@backup ~]# cat /etc/rsync.password
rsync_backup:123456

(二)nfs 客戶端

1.創(chuàng)建環(huán)境

[root@nfs01 ~]# mkdir -p /server/{scripts,tools}
[root@nfs01 ~]# tree /server/
/server/
├── scripts
└── tools

2 directories, 0 files

2.上傳sersync軟件包

[root@nfs01 ~]# cd /server/tools/
[root@nfs01 tools]# rz -E
rz waiting to receive.
[root@nfs01 tools]# ll
total 692
-rw-r--r-- 1 root root 708025 May 23  2019 sersync_installdir_64bit.zip

[root@nfs01 tools]# unzip sersync_installdir_64bit.zip 
[root@nfs01 tools]# tree
.
├── sersync_installdir_64bit
│   └── sersync
│       ├── bin
│       │   └── sersync
│       ├── conf
│       │   └── confxml.xml
│       └── logs
└── sersync_installdir_64bit.zip

5 directories, 3 files

3.給sersync創(chuàng)建目錄,并創(chuàng)建一個軟連接

[root@nfs01 tools]# mkdir -p /app
[root@nfs01 tools]# mv /server/tools/sersync_installdir_64bit/sersync /app
[root@nfs01 tools]# ll /app
total 0
drwxr-xr-x 5 root root 41 Dec 23  2012 sersync

[root@nfs01 tools]# tree /app
/app
└── sersync
    ├── bin
    │   └── sersync
    ├── conf
    │   └── confxml.xml
    └── logs

4 directories, 2 files

[root@nfs01 tools]# /app/sersync/bin/sersync          //執(zhí)行sersync
-bash: /app/sersync/bin/sersync: Permission denied
[root@nfs01 tools]# chmod +x /app/sersync/bin/sersync
[root@nfs01 tools]# ln -s /app/sersync/bin/sersync  /sbin/     //創(chuàng)建軟連接
[root@nfs01 tools]# ll /sbin/sersync 
lrwxrwxrwx 1 root root 24 May 21 02:02 /sbin/sersync -> /app/sersync/bin/sersync
[root@nfs01 tools]# sersync         //執(zhí)行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.

sersync執(zhí)行命令時,默認會在path環(huán)境變量中查找 是否有該命令

4.修改confxml.xml文件

 5     <fileSystem xfs="true"/>
 24         <localpath watch="/upload">
 30             <commonParams params="-az"/>
 31             <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.passwd"/>
 36 <failLog path="/var/log/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->

5.創(chuàng)建密碼文件

[root@nfs01 conf]# echo '123456' >/etc/rsync.passwd
[root@nfs01 conf]# chmod 600 /etc/rsync.passwd

二、測試

1.啟動sersync服務 并同步

[root@nfs01 conf]# 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.passwd
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.passwd >/dev/null 2>&1 
run the sersync: 
watch path is: /upload

2.查看共享目錄

  • nfs 客戶端 查看目錄
[root@nfs01 conf]# ll /upload/
total 0
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old01.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old02.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old03.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old04.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old05.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old06.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old07.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old08.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old09.txt
-rw-r--r-- 1 nfsnobody nfsnobody 0 May 20 22:54 old10.txt
[root@nfs01 conf]# rm -f /upload/old{05..10}.txt
  • backup 服務端 查看目錄
[root@backup ~]# ll /nfsbackup/
total 0
-rw-r--r-- 1 rsync rsync 0 May 20 22:54 old01.txt
-rw-r--r-- 1 rsync rsync 0 May 20 22:54 old02.txt
-rw-r--r-- 1 rsync rsync 0 May 20 22:54 old03.txt
-rw-r--r-- 1 rsync rsync 0 May 20 22:54 old04.txt
[root@backup ~]# 

配置inotify 的監(jiān)控的事件 sersync 什么時候用rsync推送 實時監(jiān)控目錄變量

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

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

  • 轉(zhuǎn)載:https://www.cnblogs.com/liangml/p/5959571.html 一.為什么要用...
    SkTj閱讀 1,579評論 0 1
  • 70 何年部落到陰陵,奕世勤王國史稱。夜卷牙旗千帳雪,朝飛羽騎一河冰。蕃兒襁負來青冢,狄女壺漿出白登。日晚鸝鵜泉畔...
    郭零閱讀 396評論 0 0

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