Linux rsync

rsync_setting
1.下載所需要的軟件包
rsync-3.0.9.tar.gz

2.把軟件包放到你的服務器端和客戶端
[root@SYS-20140609-7-50 soft]# ll
total 776
-rw-r--r-- 1 root root 792725 Jun  8 20:48 rsync-3.0.9.tar.gz

[root@SYS-20140609-7-50 soft]# scp ./rsync-3.0.9.tar.gz [email protected]:/data/soft/
[email protected]'s password:
rsync-3.0.9.tar.gz                                                             100%  774KB 774.2KB/s   00:00 


3.刪除在服務器存在的rsync的軟件包
[root@SYS-20140609-7-50 init.d]# rpm -qa | grep rsync
rsync-3.0.6-5.el6_0.1.x86_64

[root@SYS-20140609-7-51 data]# which rsync
/usr/bin/rsync
[root@SYS-20140609-7-51 data]# rpm -qa | grep rsync
rsync-3.0.6-5.el6_0.1.x86_64
[root@SYS-20140609-7-51 data]# yum -y remove rsync-3.0.6-5.el6_0.1.x86_64

4.安裝軟件包

4.1 解壓
[root@SYS-20140609-7-50 soft]# tar zxvf rsync-3.0.9.tar.gz

4.2 進入目錄
[root@SYS-20140609-7-50 soft]# cd rsync-3.0.9

4.3 進行編譯,指定編譯目錄
[root@SYS-20140609-7-50 rsync-3.0.9]# ./configure

出現問題:
[root@SYS-20140609-7-50 rsync-3.0.9]# ./configure
configure.sh: Configuring rsync 3.0.9
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking whether to include debugging symbols... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure.sh: error: in `/data/soft/rsync-3.0.9':
configure.sh: error: no acceptable C compiler found in $PATH
See `config.log' for more details

解決辦法:
[root@SYS-20140609-7-50 rsync-3.0.9]# yum -y install gcc

出現這樣的字體
config.status: creating lib/dummy
config.status: creating zlib/dummy
config.status: creating popt/dummy
config.status: creating shconfig
config.status: creating config.h

    rsync 3.0.9 configuration successful
 
 說明可以進行一步進行編譯操作


 


4.4 編譯
[root@SYS-20140609-7-50 rsync-3.0.9]# make && make install

這樣就可以使用rsync軟件

5. rsync服務器端的配置
Server_setting

5.1 /etc/rsyncd.conf文件配置
[root@SYS-20140609-7-50 123]# cat /etc/rsyncd.conf
#[global]
strict modes = yes
port = 873
logfile = /var/log/rsyncd.log
pidfile = /var/run/rsyncd.pid
lockfile = /var/run/rsync.lock
max connections = 4

#[modules]
[data]
uid= root
gid= root
path = /data/123/
read only = no
host allow = 172.26.7.51
auth users = root
secrets file = /etc/rsyncd.scrt

5.2 /etc/rsyncd.scrt文件的配置
[root@SYS-20140609-7-50 123]# cat /etc/rsyncd.scrt
root:q1w2e3r4

5.3 /etc/rsyncd.scrt文件的權限的配置
[root@SYS-20140609-7-50 123]# chmod 600 /etc/rsyncd.scrt


5.4 啓動rsync服務
[root@SYS-20140609-7-50 123]# /usr/local/bin/rsync --daemon

6.客戶端的rsync的配置
Client_setting

6.1 /etc/rsyncd.scrt文件的配置
[root@SYS-20140609-7-50 123]# cat /etc/rsyncd.scrt
q1w2e3r4

6.2 /etc/rsyncd.scrt文件的權限的配置
[root@SYS-20140609-7-50 123]# chmod 600 /etc/rsyncd.scrt

6.3驗證配置
cd /data/soft/rsync-3.0.9
./rsync -vzrtopg --delete --progress --bwlimit=1000 [email protected]::data /data/123 --password-file=/etc/rsyncd.scrt

7 驗證結果
[root@SYS-20140609-7-51 rsync-3.0.9]# rsync -vzrtopg  --progress --bwlimit=1000 [email protected]::data /data/123 --password-file=/etc/rsyncd.scrt
receiving incremental file list
./
34
          27 100%   26.37kB/s    0:00:00 (xfer#1, to-check=1/4)
345
          20 100%    0.49kB/s    0:00:00 (xfer#2, to-check=0/4)

sent 95 bytes  received 256 bytes  33.43 bytes/sec
total size is 68  speedup is 0.19


結果成功


8.查看目錄文件是否是同步狀態
[root@SYS-20140609-7-50 123]# ls
123  34  345

[root@SYS-20140609-7-51 123]# ls
123  34  345

同步成功

 

rsync問題解決集
問題一:
@ERROR: chroot failed
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服務器端的目錄不存在或無權限。創建目錄並修正權限可解決問題。
 
問題二:
@ERROR: auth failed on module tee
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服務器端該模塊(tee)需要驗證用戶名密碼,但客戶端沒有提供正確的用戶名密碼,認證失敗。提供正確的用戶名密碼解決此問題。
 
問題三:
@ERROR: Unknown module ‘tee_nonexists’
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:
服務器不存在指定模塊。提供正確的模塊名或在服務器端修改成你要的模塊以解決問題。
 
問題四:
password file must not be other-accessible
continuing without password file
Password:
原因:
這是因爲rsyncd.pwd rsyncd.secrets的權限不對,應該設置爲600。如:chmod 600 rsyncd.pwd
 
問題五:
rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
原因:
對方沒開機、防火牆阻擋、通過的網絡上有防火牆阻擋,都有可能。關閉防火牆,其實就是把tcp udp的873端口打開。
 
問題六:
rsync error: error starting client-server protocol (code 5) at main.c(1524) [Receiver=3.0.7]
原因:
/etc/rsyncd.conf配置文件內容有錯誤。請正確覈對配置文件。
 
問題七:
rsync: chown "" failed: Invalid argument (22)
原因:
權限無法複製。去掉同步權限的參數即可。(這種情況多見於Linux向Windows的時候)
 問題八:
@ERROR: daemon security issue -- contact admin
rsync error: error starting client-server protocol (code 5) at main.c(1530) [sender=3.0.6]
原因:
同步的目錄裏面有軟連接文件,需要服務器端的/etc/rsyncd.conf打開use chroot = yes。掠過軟連接文件

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章