root@mysql-2:~# apt-get install -y lsyncd
root@mysql-2:/data/lsyncd# cat /etc/lsyncd.conf
settings {
logfile ="/data/mysql/project_nginx.log",
statusFile ="/data/lsyncd/lsyncd.status",
inotifyMode = "CloseWrite",
maxProcesses = 8,
-- maxConnections = 4,
-- delay = 10,
-- excludeFrom = file,
-- excludeFrom 排除選項(xiàng)
}
sync {
default.rsyncssh,
source = "/data/docker-compose",
host = "192.168.1.23",
targetdir = "/data/docker-compose",
-- exclude = "/data/www/public_html/config.inc.php", #排除此文件不同步
-- maxDelays = 5,累計(jì)到多少所監(jiān)控的事件激活一次同步,即使后面的delay延遲時(shí)間還未到
-- delay = 2,
-- init = false,這是一個(gè)優(yōu)化選項(xiàng),當(dāng)init = false,只同步進(jìn)程啟動(dòng)以后發(fā)生改動(dòng)事件的文件,原有的目錄即使有差異也不會(huì)同步。默認(rèn)是true
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
-- _extra = {"--bwlimit=2000"},
},
ssh = {
binary = "/usr/bin/ssh",
port = 22,
}
}
sync {
default.rsyncssh,
source = "/data/docker-compose", #源目錄
host = "192.168.1.43",
targetdir = "/data/docker-compose", #目標(biāo)目錄
-- exclude = "/data/www/public_html/config.inc.php",
-- maxDelays = 5,累計(jì)到多少所監(jiān)控的事件激活一次同步,即使后面的delay延遲時(shí)間還未到
-- delay = 2,
-- init = false,這是一個(gè)優(yōu)化選項(xiàng),當(dāng)init = false,只同步進(jìn)程啟動(dòng)以后發(fā)生改動(dòng)事件的文件,原有的目錄即使有差異也不會(huì)同步。默認(rèn)是true
rsync = {
binary = "/usr/bin/rsync",
archive = true,
compress = true,
verbose = true,
-- _extra = {"--bwlimit=2000"},
},
ssh = {
binary = "/usr/bin/ssh",
port = 22,
}
}
root@mysql-2:/data/lsyncd# lsyncd /etc/lsyncd.conf
目錄里面有問(wèn)題或者新建立都會(huì)同步,注意沒(méi)有目錄會(huì)自己創(chuàng)建目錄同步
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。