rysnc server端linux
一、vim /etcrsyncd.conf (用戶rsync,目錄,模塊,非系統虛擬用戶及密碼文件)vim
二、建立共享目錄 /data/www/{www,bbs,blog}服務器
三、建立rsync用戶,並受權訪問/data/www/ide
四、建立密碼文件,複製配置文件裏的路徑,而後添加密碼內容:‘’虛擬用戶名:密碼‘’測試
五、密碼文件權限600 chmod 600 /etc/rsync.passwordui
六、rsync --daemon 啓動rysnc進程,而後放入/etc/rc.local 開機自啓加密
七、tail /var/log/rsyncd.log 查看rsync運行log spa
服務器端rsync重啓服務code
一、 pkill rsyncserver
二、 kill `cat /var/run/rsyncd.pid`
rsync --daemon
查看是不是啓動rsync服務
ps -ef|grep rsync
netstat -lnt |grep 873
lsof -i:873
rsync client端
一、密碼文件和服務端沒有任何關係。命令是--password-file=/etc/rsync.password
二、密碼文件內容:‘’密碼‘’
三、密碼文件權限600 chmod 600 /etc/rsync.password
語法:
pull:
rysnc -avz rsync_backup@10.0.0.11::www /data --password-file=/etc/rsync.password
push
rsync -avz /data/ rsync_backup@10.0.0.11::www --password-file=/etc/rsync.password
排錯:
一、防火牆和selinux
二、/var/log/rsyncd.log
三、整個部署流程總體考慮排查
四、操做習慣當作一個大事。如rsyncd.conf的內容都複製一份,部署時直接複製粘貼使用;定位文件時儘量使用tab補全;使用命令腳本時,先測試腳本本地單獨運行沒有問題,而後再複製粘貼到腳本中,儘可能減小手打。
/etc/rsyncd.conf
##rsyncd.conf start## uid = rsync 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 ## Module 1 ## [www] comment = www added by jp at 2019/5/10 9:39 path = /data/www/www/ ## Module 2 ## [bbs] comment = www added by jp at 2019/5/10 9:40 path = /data/www/bbs/ ##################################### [blog] comment = blog added by jp at 2019/5/10 9:41 path = /data/www/blog/
排錯
一、rsync: chgrp ".passwd.DKh65W" (in backup) failed: Operation not permitted (1)
[root@nfs01-31 tmp]# rsync -avz /etc/passwd rsync_backup@172.16.1.41::backup
Password:
sending incremental file list
passwd
rsync: chgrp ".passwd.DKh65W" (in backup) failed: Operation not permitted (1)
sent 524 bytes received 125 bytes 432.67 bytes/sec
total size is 1,022 speedup is 1.57
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
這個多是配置文件裏面沒有加fake super = yes
在之前的版本里面不須要,如今版本須要
二、sending incremental file list
rsync: failed to write xattr user.rsync.%stat for "." (in server10): Permission denied (13)
rsync: failed to set times on "." (in server10): Operation not permitted (1)
緣由:在rsync服務器端,rsync在模塊的目標文件夾中沒有權限
三、@ERROR: Unknown module 'sipbackup'
rsync error: error starting client-server protocol (code 5) at main.c(1648) [sender=3.1.2]
緣由:
這個報錯是由於hosts allow配置的有問題
檢查了一下發現把192.168.40.0/24 寫成了192.168.40.0\24
四、elastixbackup-20191215105901-ab.tar
42,352,640 100% 17.16MB/s 0:00:02 (xfr#1, to-chk=0/1)
rsync: mkstemp "/NC/.elastixbackup-20191215105901-ab.tar.FcBWez" (in sipbackup) failed: Permission denied (13)
緣由:服務器端的文件夾沒有權限。
解決方法:drwxr-xr-x 2 rsync rsync 48 Dec 20 13:58 DMZdrwxr-xr-x 2 root root 6 Dec 19 15:47 NCdrwxr-xr-x 2 rsync rsync 48 Dec 18 00:16 ALGdrwxr-xr-x 2 rsync rsync 48 Dec 18 00:02 XAdrwxr-xr-x 2 rsync rsync 48 Dec 18 00:02 SZdrwxr-xr-x 2 rsync rsync 48 Dec 18 00:02 SUZdrwxr-xr-x 2 rsync rsync 48 Dec 18 00:00 SHchmod -R rsync.rsync /NC