-
服務(wù)端安裝與配置
192.168.2.10
1. 安裝rsync
[root@localhost ~]# yum -y install rsync
2. 建立密碼認(rèn)證文件,并且賦權(quán)限
[root@localhost ~]# cd /etc/ [root@localhost etc]# vi rsyncd.password wbc@wodata [root@localhost etc]# chmod 600 rsyncd.password
3 修改配置文件
[root@localhost ~]# cd /etc/ [root@localhost etc]# vi rsyncd.conf uid = root gid = root use chroot = no max connections = 3 timeout = 800 pid file = /var/run/rsyncd.pid lockfile = /var/run/rsyncd.lock log file = /var/log/rsyncd.log [uploads] path = /home/wbc/webroot/ROOT/upload ignore errors = yes host allow = 192.168.0.0/255.255.0.0 #hosts deny = * read only = no write only = no list = yes auth users = wbc secrets file = /etc/rsyncd.password
4. 安裝inotify-tools净嘀,安裝在etc下
需要有編譯環(huán)境
yum install make gcc gcc-c++
[root@localhost ~]# cd /etc/ [root@localhost etc]# wget http://cloud.github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz [root@localhost etc]# tar zxvf inotify-tools-3.14.tar.gz [root@localhost etc]# rm -rf inotify-tools-3.14.tar.gz [root@localhost ~]# cd /etc/inotify-tools-3.14/ [root@localhost inotify-tools-3.14]# ./configure --prefix=/etc/inotify [root@localhost inotify-tools-3.14]# make [root@localhost inotify-tools-3.14]# make install
5. 創(chuàng)建rsync復(fù)制腳本
將服務(wù)端的/home/wbc/webapps/ROOT/upload/同步到備份端的/home/wbc/webapps/ROOT/uploads/戳粒,進(jìn)行冗余備份券坞,不做刪除同步
[root@localhost etc]# vi rs-upload.sh #!/bin/bash src='/home/wbc/webapps/ROOT/upload/' passwordfile='/etc/rsyncd.password' user='wbc' host0='192.168.2.11' rsync_module='uploads' if [ ! -d "${src}" ]; then mkdir -p ${src} fi /etc/inotify/bin/inotifywait -mrq --timefmt '%Y%m%d %H%M%S' --format '%T %w %f' -e modify,delete,create,attrib ${src} | while read DATE TIME DIR file do /usr/bin/rsync -vzrtopg --progress ${src} ${user}@${host0}::${rsync_module} --password-file=${passwordfile} echo "${file} was rsynced at ${DATE}_${TIME} in ${DIR}" >> /var/log/rsync-upload.log 2>&1 done
6. 后臺執(zhí)行腳本
[root@localhost etc]# sh rs-upload.sh &
如果有報錯 inotifywait: error while loading shared libraries: libinotifytools.so.0: cannot open shared object file: No such file or directory 解決方法: 32位系統(tǒng):ln -s /etc/inotify/lib/libinotifytools.so.0 /usr/lib/libinotifytools.so.0 64位系統(tǒng):ln -s /etc/inotify/lib/libinotifytools.so.0 /usr/lib64/libinotifytools.so.0
-
備份端安裝與配置
192.168.2.11
1. 安裝rsync
[root@localhost ~]# yum -y install rsync
2. 建立密碼認(rèn)證文件,并且賦權(quán)限
[root@localhost ~]# cd /etc/ [root@localhost etc]# vi rsyncd.password wbc@wodata [root@localhost etc]# chmod 600 rsyncd.password
3 修改配置文件
[root@localhost ~]# cd /etc/ [root@localhost etc]# vi rsyncd.conf uid = root gid = root use chroot = no max connections = 3 timeout = 800 pid file = /var/run/rsyncd.pid lockfile = /var/run/rsyncd.lock log file = /var/log/rsyncd.log [uploads] path = /home/wbc/webapps/uploads ignore errors = yes host allow = 192.168.0.0/255.255.0.0 #hosts deny = * read only = no write only = no list = yes auth users = wbc secrets file = /etc/rsyncd.password
4. 新增自定義服務(wù)文件
[root@localhost etc]# vi /init.d/rsync #!/bin/sh #whoami #root #chkconfig: 345 51 49 #description: starts the rsync deamons # case "$1" in start) echo "Starting Rsync ..." rsync --daemon --config=/etc/rsyncd.conf ;; stop) echo "Stop Rsync ..." pkill rsync > /dev/null 2>/dev/null ;; restart) echo "Restart Rsync ..." $0 stop $0 start ;; *) echo "Usage: $1 {start|stop|restart}" ;; esac exit 0
5. 啟動服務(wù)
[root@localhost etc]# cd /init.d [root@localhost etc]# vi rsync #!/bin/sh #whoami #root #chkconfig: 345 51 49 #description: starts the rsync deamons # case "$1" in start) echo "Starting Rsync ..." rsync --daemon --config=/etc/rsyncd.conf ;; stop) echo "Stop Rsync ..." pkill rsync > /dev/null 2>/dev/null ;; restart) echo "Restart Rsync ..." $0 stop $0 start ;; *) echo "Usage: $1 {start|stop|restart}" ;; esac exit 0
6. 為自定義服務(wù)賦權(quán)限
[root@localhost init.d]# chmod +x rsync
7. 啟動服務(wù)
[root@localhost init.d]# service rsync start
-
目前為止已經(jīng)安裝配置好了
1. 在服務(wù)端測試
[root@localhost upload]# mkdir test
正常情況會輸出以下信息 [root@localhost upload]# sending incremental file list ./ test/ sent 107 bytes received 19 bytes 252.00 bytes/sec total size is 0 speedup is 0.00
2. 在備份端做檢查
查看該目錄下是否有test文件夾 [root@localhost ~]# ll /home/wbc/webapps/uploads
-
引文
搭建文件同步服務(wù):rsync+inotify
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來烁挟,“玉大人,你說我怎么就攤上這事骨坑『成ぃ” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵欢唾,是天一觀的道長且警。 經(jīng)常有香客問我,道長礁遣,這世上最難降的妖魔是什么斑芜? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮祟霍,結(jié)果婚禮上杏头,老公的妹妹穿的比我還像新娘。我一直安慰自己沸呐,他們只是感情好醇王,可當(dāng)我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著崭添,像睡著了一般寓娩。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上呼渣,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼帅容!你這毒婦竟也來了颇象?” 一聲冷哼從身側(cè)響起,我...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡蕴茴,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年劝评,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片倦淀。...
- 正文 年R本政府宣布愿棋,位于F島的核電站科展,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏糠雨。R本人自食惡果不足惜才睹,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望甘邀。 院中可真熱鬧琅攘,春花似錦、人聲如沸鹃答。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽测摔。三九已至置济,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間锋八,已是汗流浹背浙于。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長得像紊服,于是被迫代替她去往敵國和親檀轨。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 4層負(fù)載均衡和7層負(fù)載均衡的區(qū)別欺嗤。A参萄、rsync的安裝;軟件包安裝# yum install rsync 注...
- 隨著應(yīng)用系統(tǒng)規(guī)模的不斷擴(kuò)大煎饼,對數(shù)據(jù)的安全性和可靠性也提出的更好的要求讹挎,rsync在高端業(yè)務(wù)系統(tǒng)中也逐漸暴露出了很多...
- 1.1 inotify介紹 inotify是一種強(qiáng)大的、細(xì)粒度的、異步的文件系統(tǒng)事件控制機(jī)制筒溃。linux內(nèi)核從2....
- 說明: 操作系統(tǒng):CentOS 5.X 源服務(wù)器:192.168.21.129 目標(biāo)服務(wù)器:192.168.21....
- 一怜奖、簡介 sersync是基于Inotify開發(fā)的浑测,類似于Inotify-tools的工具。 sersync可以記...