rsync服務端安裝與配置
摘要:
選擇伺服器啟動方式
對於負荷較重的 rsync 伺服器應該使用獨立執行方式,啟動方式:rsync --daemon --config=/etc/rsyncd.conf
對於負荷較輕的 rsync 伺服器可以使用 xinetd 執行方式 /etc/init....
選擇伺服器啟動方式
- 對於負荷較重的 rsync 伺服器應該使用獨立執行方式,啟動方式:rsync --daemon --config=/etc/rsyncd.conf
- 對於負荷較輕的 rsync 伺服器可以使用 xinetd 執行方式 /etc/init.d/xinetd start(建議)
xinetd的配置
#vim /etc/xinetd.d/rsync 修改disable=no,flags=IPv4 #vim /etc/xinetd.conf 修改cps=500 30,instances=UNLIMITED,per_source=UNLIMITED 含義可參見man xinetd.conf
rsync服務端配置
#新增修改配置檔案 mkdir /etc/rsyncd touch /etc/rsyncd/rsyncd.conf ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf #建立使用者認證檔案 #vim /etc/rsyncd/rsyncd.secrets yangyi:111111#格式 使用者名稱:口令 # chmod 600 /etc/rsyncd/rsyncd.secrets 啟動服務,檢視埠預設873是否已經在監聽
rsync服務配置檔案
# GLOBAL OPTIONS #顯示系統提示資訊 motd file=/etc/motd #rsync服務繫結埠 port=873 #指定rsync服務的pid檔案和lock檔案、 pid file=/var/run/rsyncd.pid lock file = /var/lock/rsyncd #指定rsync服務的日誌檔案 log file=/var/log/rsyncd #記錄rsync傳輸日誌 transfer logging = yes #定製rsync日誌格式 log format = [op]:%o [ip]:%a [module]:%m [path]:%P [file]:%f [size]:%l #指定syslog的facility syslog facility=daemon #最多允許5個客戶端連線rsync伺服器 max connections=5 # MODULE OPTIONS [website] #在list中可以顯示模組資訊 comment = "web server" #指定同步的路徑 path = /var/www/ #允許list該模組 list = yes #開啟chroot選項 use chroot = yes #同步過程中使用哪個使用者的uid/gid uid = www-data gid = www-data #根據需求確認是否只讀/只寫 read only = no write only = no #根據需求確認是否要排除某些檔案同步 exclude = include = #使用者驗證,必須提供相關的使用者名稱/密碼,且密碼檔案僅owner為可讀可寫 auth users = www-data secrets file = /etc/rsyncd.secrets strict modes = yes #只允許指定的IP可以訪問rsync服務 hosts allow = 10.1.6.69 hosts deny = *
rsync客戶端的安裝與配置
例項: rsync -vzurtopg --delete --password-file=/etc/rsync.ps ${logpathd}/[email protected]::forlogs172d # 其中,--delete引數客戶端如果存在伺服器端沒有的檔案,將刪除檔案,--passw-file後面跟的是客戶端與服務端建立信任關係的密碼
windows下rsync客戶端的安裝配置(rwRsync)
@echo off echo. echo 開始同步資料,請稍等... echo. cd C:\Program Files (x86)\cwRsync\bin rsync.exe -vzurtopg --delete --progress/cygdrive/d/pilot/[email protected]::repotest < passwd.txt echo. # passwd.txt放在rwRsync的bin目錄下,同樣來驗證服務端設定的密碼