1. 程式人生 > >Rsync 故障排查整理

Rsync 故障排查整理

環境:本地伺服器叢集內部傳輸利用遠端ssh 報錯

利用(telnet 172.16.1.31 22) 排查服務監聽狀態後採取的解決方法

[[email protected] ~]# rsync /etc/hosts 172.16.1.31:/tmp

ssh: connect to host 172.16.1.31 port 22: Connection refused

rsync: connection unexpectedly closed (0 bytes received so far) [sender]

rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]

排錯思路:

[[email protected] ~]# ping 172.16.1.31

PING 172.16.1.31 (172.16.1.31) 56(84) bytes of data.

64 bytes from 172.16.1.31: icmp_seq=1 ttl=64 time=0.628 ms

64 bytes from 172.16.1.31: icmp_seq=2 ttl=64 time=0.393 ms

64 bytes from 172.16.1.31: icmp_seq=3 ttl=64 time=1.06 ms

64 bytes from 172.16.1.31: icmp_seq=4 ttl=64 time=0.745 ms

[[email protected] ~]# traceroute 172.16.1.31

traceroute to 172.16.1.31 (172.16.1.31), 30 hops max, 60 byte packets

 1  nfs01 (172.16.1.31)  0.597 ms  0.189 ms  0.965 ms

/etc/init.d/iptables status

iptables: Firewall is not running.

[[email protected] ~]#

[[email protected] ~]# netstat -lntup|grep 22

  p        0      0 10.0.0.31:22                0.0.0.0:*                   LISTEN      1187/sshd          

故障原因:無法連線

telnet 172.16.1.31 22

解決方法:

[[email protected]]# vim /etc/ssh/sshd_config

#Port 22

#AddressFamily any

#ListenAddress 10.0.0.31 改為 0.0.0.0

#ListenAddress ::

總結:內網傳輸通過SSH pro 22 表明22埠連結不上

==============================================================================================

12 --passwd-file=/etc/rsync.passwd: unknown option 沒有正確輸入password檔名

報錯:--passwd-file=/etc/rsync.passwd: unknown option

錯誤案例  本地rsync.password 檔案要保持一致缺少字母都會報錯

echo "123456">>/etc/rsync.passwd

[[email protected] ~]# chmod 600 /etc/rsync.passwd

[[email protected] ~]# ll /etc/rsync.passwd

-rw------- 1 root root 7 Mar  9 13:47 /etc/rsync.passwd

[[email protected] ~]# rsync  -az -P /root/ [email protected]::backup --passwd-file=/etc/rsync.passwd

rsync: --passwd-file=/etc/rsync.passwd: unknown option

rsync error: syntax or usage error (code 1) at main.c(1422) [client=3.0.6]

 正確做法:

[[email protected] ~]# echo "123456">>/etc/rsync.password

[[email protected] ~]# chmod 600 /etc/rsync.password

[[email protected] ~]# ll /etc/rsync.password

-rw------- 1 root root 7 Mar  9 13:49 /etc/rsync.password

rsync  -az -P /server/files/secure-20161219  [email protected]::backup --password-file=/etc/rsync.password

sending incremental file list

secure-20161219

    51053780 100%   14.31MB/s    0:00:03 (xfer#1, to-check=0/1)

rsync: mkstemp ".secure-20161219.lcnuWA" (in backup) failed: Permission denied (13)

sent 2210982 bytes  received 27 bytes  491335.33 bytes/sec

total size is 51053780  speedup is 23.09

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]

[[email protected] ~]# ls /backup/

100.log          cc.txt       optimize-init_sys.sh

anaconda-ks.cfg

      1)可能是服務沒有開啟

      2)iptables SELinux

      3)本次遇見sshd傳輸受限 限制了傳輸的ip(安全)

==============================================================================================

Rsync服務端排錯思路

m  檢視rsync服務配置檔案路徑是否正確 /etc/rsyncd.conf

m  檢視配置檔案例的host allow,host deny,允許的ip網段是否是允許客戶端訪問的ip網段

m  檢視配置檔案中path引數裡的路徑是否存在,許可權是否正確(正常應為配置檔案中的UUID引數對應的屬主和組)

m  檢視rsync服務是否啟動,埠是否存在 ps -ef  netstat -lntup

m  檢視iptables防火牆和SELinux是否開啟允許rsync服務通過,也可以關閉

m  檢視服務端rsync配置檔案裡的密碼許可權是否為600 密碼檔案格式是否正確,正確格式(使用者名稱:密碼)檔案路徑和配置檔案裡的secrect files 引數對應

m  如果是推送資料,要檢視,配置rsyncd.conf 檔案中使用者是否對模組下目錄有可讀的許可權

==============================================================================================

客戶端排錯思路

m  檢視客戶端rsync配置的密碼檔案是否為600的許可權,密碼檔案格式是否正確,注意:僅需要有密碼,並且和服務端的密碼一致

m  用telnet連結rsync伺服器ip地址873埠,檢視服務是否啟動(可測試服務端防火牆是否阻擋telnet10.0.0.100 873)

m  客戶端執行命令是 rsync -avzP [email protected]::backup/test/test/ --password-file=/etc/rsync.password

m  此命令要記清楚尤其10.0.0.100::backup/test/處的雙引號及隨後的backup為模組名稱

==============================================================================================

轉至:王曉東  https://www.cnblogs.com/wang-xd/p/6551402.html