Rsync ERROR: auth failed on module解決方法


20130916153518.gif
Rsync 版本

[root@mail video]# rsync –version
rsync version 3.0.6 protocol version 30
Copyright (C) 1996-2009 by Andrew Tridgell, Wayne Davison, and others.
Web site: rsync.samba.org
Capabilities:
64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, xattrs, iconv, no symtimes

rsync comes with ABSOLUTELY NO WARRANTY. This is free software, and you
are welcome to redistribute it under certain conditions. See the GNU
General Public Licence for details.

服務器同步任務需求

服務器A與服務器B同步備份,這裏只說明服務器A同步到服務器B,服務器B還原到服務器A。
考慮安全因素,使用普通用戶進行同步。
使用cronjob,定時同步。

錯誤提示

錯誤發生在rsync 3.0.6版本,64位 CentOS5.5 系統。

首頁這篇文章主要解決的錯誤是以下:

複製代碼 代碼如下:


@ERROR: auth failed on module ***
rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]



*** 是你/etc/rsyncd.conf 中配置的模塊,我這裏用

 

複製代碼 代碼如下:


password file must not be other-accessible
continuing without password file
Password:
@ERROR: auth failed on module ***
rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]

 

Rsync 配置

#vi /etc/rsyncd.conf

 

複製代碼 代碼如下:


uid = nobody
gid = nobody
max connections = 4
read only = true
#hosts allow = 202.207.177.180
hosts allow = *
transfer logging = true
log format = %h %o %f %l %b
log file = /var/log/rsyncd.log
slp refresh = 300
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock

 

[web]
path = /home/admin/public_html
comment = Mirror to Hk server
read only = true
list = false
auth users = lixiphp

[test]
path = /home/admin/domains/test
read only = false
auth users = lixiphp
secrets file = /etc/rsyncd.secrets

 

配置普通用戶密碼

 

複製代碼 代碼如下:

[root@mail video]# vi /etc/rsyncd.secrets

 

格式爲: username:password

 

複製代碼 代碼如下:

rsync_user:rsyncofpass

 

設置權限爲只讀:

 

複製代碼 代碼如下:

chmod 600 /etc/rsyncd.secrets

 

首次啓動rsync

 

複製代碼 代碼如下:

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

 

如果提示

 

複製代碼 代碼如下:

failed to create pid file /var/run/rsyncd.pid: File exists

 

使用指令

rm -rf /var/run/rsyncd.pid

重啓已經在運行的rsync

 

複製代碼 代碼如下:


[root@mail video]# ps -ef | grep rsync
root     27284     1  0 10:26 ?        00:00:00 rsync –daemon –config=/etc/rsyncd.conf
root     30516 29986  0 18:35 pts/3    00:00:00 grep rsync
[root@mail video]# kill -9 27284
[root@mail video]# rsync –daemon –config=/etc/rsyncd.conf

 

這樣服務器A配置成功!

服務器B配置

一般錯誤都會發生在服務器B,注意這部分的講解!
通過CentOS yum install rsync,安裝rsync服務。
在rsync安裝之後,運行以下指令同步備份:

複製代碼 代碼如下:

rsync -vzrtopg –progress –delete –password-file=/home/admin/admin_backups/password.rsync rsync://[email protected]/test /home/admin/admin_backups/test




地址rsync://[email protected]/test,lixiphp爲服務器A用戶,203.171.237.245服務器A IP地址或者域名 test爲服務器A配置模塊

密碼存放在/home/admin/admin_backups/password.rsync,這裏存放位置,可自由安排。

password.rsync內容格式爲: password

複製代碼 代碼如下:

rsyncofpass



設置權限爲只讀:

複製代碼 代碼如下:

chmod 600 /home/admin/admin_backups/password.rsync



解決錯誤

用戶密碼錯誤

複製代碼 代碼如下:


@ERROR: auth failed on module test
rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]




檢查服務器A存儲密碼文件和服務器B密碼文件。

服務器A密碼文件 /etc/rsyncd.secrets 格式爲: username:password
服務器B密碼文件 password.rsync 格式爲:password
文件權限錯誤

複製代碼 代碼如下:


password file must not be other-accessible
continuing without password file
Password:
@ERROR: auth failed on module ***
rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]



檢查服務器A存儲密碼文件和服務器B密碼文件。

服務器A密碼文件 /etc/rsyncd.secrets 權限爲600: chmod 600 /etc/rsyncd.secrets
服務器B密碼文件 password.rsync 權限爲600:chmod 600 password.rsync

定時任務

複製代碼 代碼如下:

[root@hk admin_backups]# vi backup.sh




內容如下:

複製代碼 代碼如下:


#/bin/sh
rsync -vzrtopg –progress –delete –password-file=/home/admin/admin_backups/password.rsync rsync://[email protected]/test /home/admin/admin_backups/test



添加定時任務:

複製代碼 代碼如下:

[root@hk admin_backups]# crontab –e



添加以下內容:

複製代碼 代碼如下:

*/1 * * * * /home/admin/admin_backups/backup.sh > /dev/null 2>&1



每個一分鐘從服務器A同步到服務器B!

服務器B向下備份到服務器A

複製代碼 代碼如下:

rsync -vzrtopg –progress –delete –password-file=/home/admin/admin_backups/password.rsync /home/admin/admin_backups/test rsync://[email protected]/test



請確保服務器A同步用戶lixiphp,對模塊test所在目錄有讀、寫、執行的權限。

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