這篇文章主要介紹了linux系統(tǒng)中怎么實(shí)現(xiàn)網(wǎng)頁(yè)自動(dòng)同步的相關(guān)知識(shí),內(nèi)容詳細(xì)易懂,操作簡(jiǎn)單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇linux系統(tǒng)中怎么實(shí)現(xiàn)網(wǎng)頁(yè)自動(dòng)同步文章都會(huì)有所收獲,下面我們一起來看看吧。
成都創(chuàng)新互聯(lián)主營(yíng)茫崖網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都APP應(yīng)用開發(fā),茫崖h5微信小程序定制開發(fā)搭建,茫崖網(wǎng)站營(yíng)銷推廣歡迎茫崖等地區(qū)企業(yè)咨詢
使用多個(gè)web服務(wù)器實(shí)現(xiàn)負(fù)載均衡,為了保持前端web服務(wù)器上資源的一致性可以通過rsync在主服務(wù)器上(可寫入數(shù)據(jù))將更新過的文件同步到其他從服務(wù)器(只讀服務(wù)器),但是不能自動(dòng)的進(jìn)行實(shí)時(shí)同步,使用inotify可以實(shí)現(xiàn)實(shí)時(shí)同步
主服務(wù)器:192.168.6.205 inotify
從服務(wù)器:192.168.6.36 rsync
1、在從服務(wù)器上配置rsync,開啟rsync服務(wù),讓主服務(wù)可以將資源同步到該服務(wù)器上
vim /etc/rsyncd.conf
uid = nginx
gid = nginx
port = 873
host all = 192.168.6.205
use chroot = on
max connections = 4
timeout = yes
[wordpress]
path = /usr/local/nginx/html/wordpress
comment = rsync files
ignore errors
read only = no
list = yes
auth users = rsync
secrets file = /etc/rsync.passwd
創(chuàng)建/etc/rsync.passwd密碼配置文件
vim /etc/rsync.passwd
#用戶:密碼
rsync:rsync
2、在主服務(wù)器上安裝inotify-tools
tar -zxvf inotify-tools-3.14.tar.gz
cd inotify-tools-3.14
./configure –prefix=/usr/local/inotify
make && make install
在主服務(wù)器上配置rsync密碼文件,用于將數(shù)據(jù)同步到從服務(wù)器
vim /etc/rsync.passwd
#密碼
rsync
創(chuàng)建腳本
vim inotifyrsync.sh
#!/bin/bash
host=192.168.6.36
src=/usr/local/nginx/html/wordpress/
dst=wordpress
user=rsync
inotifywait=/usr/local/inotify/bin/inotifywait
rsync=/usr/bin/rsync
$inotifywait -mrq –timefmt '%d/%m/%y %h:%m' –format '%t %w%f' -e modify,delete,create,attrib $src | while read files
do
$rsync -vzrtopg –delete –progress –password-file=/etc/rsync.passwd $src $user@$host::$dst
echo "${files} was rsynced" >>/tmp/rsync.log 2>&1
done
關(guān)于“l(fā)inux系統(tǒng)中怎么實(shí)現(xiàn)網(wǎng)頁(yè)自動(dòng)同步”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對(duì)“l(fā)inux系統(tǒng)中怎么實(shí)現(xiàn)網(wǎng)頁(yè)自動(dòng)同步”知識(shí)都有一定的了解,大家如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)站名稱:linux系統(tǒng)中怎么實(shí)現(xiàn)網(wǎng)頁(yè)自動(dòng)同步
分享URL:http://www.chinadenli.net/article2/gcijic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站內(nèi)鏈、外貿(mào)網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化、營(yíng)銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)