具体操作步骤:
配置/etc/rsyncd.conf文件:
uid = nobody
gid = nobody
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
[test01]
path = /front/test01
ignore errors
read only = true
list = false
hosts allow = 192.168.1.252
hosts deny = 192.168.1.0/24
auth users = test01
secrets file = /etc/rsync.secret
[back]
path = /front/back
ignore errors
read only = true
list = false
hosts allow = 192.168.1.252
hosts deny = 192.168.1.0/24
配置test01目录需要密码,back用户不需要
建立密码文件
[root@tonykorn front]# cat /etc/rsync.secret
test01:test01
[root@tonykorn front]#
修改启动rsync文件
[root@tonykorn etc]# cat /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it
# allows crc checksumming etc.
service rsync
{
# disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root@tonykorn etc]#
启动服务端
[root@tonykorn front]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@tonykorn front]#
也有的地方说需要运行:rsync --daemon,经过试验不需要
没有运行rsync --daemon的时候进程状态是:
[root@tonykorn front]# ps -ef | grep rsync
root 24033 15043 0 17:40 pts/0 00:00:00 grep rsync
运行后为:
[root@tonykorn front]# rsync --daemon
[root@tonykorn front]# ps -ef | grep rsync
root 24035 1 0 17:40 ? 00:00:00 rsync --daemon
root 24042 15043 0 17:40 pts/0 00:00:00 grep rsync
[root@tonykorn front]#
客户端操作
客户端同步出错:
[test01@tonykorn02 ~]$ rsync -vzrtopg --progress test01@192.168.1.250::test01 /front/test01
Password:
@ERROR: auth failed on module test01
rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=2.6.8]
[test01@tonykorn02 ~]$
原因:
secret file的文件属性有问题,该文件属性要是600的
[root@tonykorn etc]# ls -al rsync.secret
-rw-r--r-- 1 root root 14 Apr 2 17:04 rsync.secret
[root@tonykorn etc]# chmod 600 rsync.secret
[root@tonykorn etc]#
此时运行,test01需要密码,输入密码后可以,back不需要密码,直接可以同步
[root@tonykorn02 front]# rsync -vzrtopg --progress test01@192.168.1.250::test01 /front/test01
Password:
receiving file list ...
421 files to consider
sent 98 bytes received 8031 bytes 2322.57 bytes/sec
total size is 134589856 speedup is 16556.75
[root@tonykorn02 front]# rsync -vzrtopg --progress back@192.168.1.250::back /front/back
receiving file list ...
50 files to consider
sent 62 bytes received 1007 bytes 2138.00 bytes/sec
total size is 12629876 speedup is 11814.66
[root@tonykorn02 front]#
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/312079/viewspace-245849/ ,如需转载,请注明出处,否则将追究法律责任。