rsync 應用總結


rysnc server端

  1、vim /etcrsyncd.conf (用戶rsync,目錄,模塊,非系統虛擬用戶及密碼文件)

  2、創建共享目錄 /data/www/{www,bbs,blog}

  3、創建rsync用戶,並授權訪問/data/www/

  4、創建密碼文件,復制配置文件里的路徑,然后添加密碼內容:‘’虛擬用戶名:密碼‘’

  5、密碼文件權限600 chmod 600 /etc/rsync.password

  6、rsync --daemon 啟動rysnc進程,然后放入/etc/rc.local 開機自啟

  7、tail /var/log/rsyncd.log 查看rsync運行log 

       服務器端rsync重啟服務

  1、 pkill rsync

  2、 kill `cat /var/run/rsyncd.pid`

          rsync --daemon

     查看是否是啟動rsync服務

      ps -ef|grep rsync
      netstat -lnt |grep 873
      lsof -i:873

  

 

rsync client端

  1、密碼文件和服務端沒有任何關系。命令是--password-file=/etc/rsync.password

  2、密碼文件內容:‘’密碼‘’

  3、密碼文件權限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

排錯:

  1、防火牆和selinux

  2、/var/log/rsyncd.log

  3、整個部署流程整體考慮排查

  4、操作習慣當做一個大事。如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/
View Code

 排錯

1、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 在以前的版本里面不需要,現在版本需要

 

2、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在模塊的目標文件夾中沒有權限

 3、@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

4、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 DMZ
drwxr-xr-x 2 root  root   6 Dec 19 15:47 NC
drwxr-xr-x 2 rsync rsync 48 Dec 18 00:16 ALG
drwxr-xr-x 2 rsync rsync 48 Dec 18 00:02 XA
drwxr-xr-x 2 rsync rsync 48 Dec 18 00:02 SZ
drwxr-xr-x 2 rsync rsync 48 Dec 18 00:02 SUZ
drwxr-xr-x 2 rsync rsync 48 Dec 18 00:00 SH
chmod -R rsync.rsync /NC


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM