centos6 64X rsync 使用實戰

centos  rsync 使用實戰

場景: 搭建服務同步源,客戶端拉取同步文件

服務端(191.168.1.100)

客戶端(191.168.1.10)

客戶端(191.168.1.20)


一、服務端搭建

mkdir /etc/rsync

1、創建密碼文件

echo "www_app:test" > /etc/rsync/web.pas        #可以是非用戶密碼

2、創建配置文件

vim /etc/rsync/rsyncd.conf

編輯如下內容

# This line is required by the /etc/init.d/rsyncd script
#pid file = /var/run/rsyncd.pid 
#port = 873
#address = 192.168.1.100 #服務器ip
uid = www_app
gid = www_user


#use chroot = yes 
read only = yes


#limit access to private LANs
#hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0 
#hosts deny=*


max connections = 5
#motd file = /etc/rsyncd.motd
#This will give you a separate log file
log file = /home/www_op/rsync/rsync.log

#This will log every file transferred - up to 85,000+ per user, per sync
#transfer logging = yes

log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

[test]
path = /home/www_app/testdir
list=yes
ignore errors
auth users = www_app
secrets file = /etc/rsync/web.pas
comment = This is 192.168.1.100  testhome
#exclude = easylife/ samba/ 
#

[web]
path = /home/www_app/wwwroot/webhome/
list=yes
ignore errors
auth users = www_app
secrets file = /etc/rsync/web.pas
comment = This is 192.168.1.100  web home

3、啓動

rsync --daemon --config=/etc/rsync/rsyncd.conf 

4、重啓 

查詢進程:ps -ef | grep rsync

殺掉進程:kill 進程號

啓動進程:rsync --daemon --config=/etc/rsync/rsyncd.conf 


二、客戶端(191.168.1.10)

1、編輯密碼文件,服務端配置的密碼

echo "test" > web.pas 

 rsync --list-only --password-file=web.pas [email protected]::test

三、常見問題

1、場景一

@ERROR: auth failed on module test

rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]

答:意思爲認證失敗

可能1:服務端web.pas 格式爲 user:passwd,客戶端web.pas 格式爲:passwd

可能2:服務端 rsyncd.conf 密碼文件配置錯誤

2、場景二

@ERROR: chroot failed

rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]

答:服務端web.pas 權限不對,必須爲chmod 600 web.pas



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