本文共 2503 字,大约阅读时间需要 8 分钟。
具体操作步骤:
配置/etc/rsyncd.conf文件:
uid = nobody
gid = nobodyuse chroot = nomax connections = 4 pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog file = /var/log/rsyncd.log[test01]
path = /front/test01ignore errorsread only = truelist = falsehosts allow = 192.168.1.252hosts deny = 192.168.1.0/24auth users = test01secrets file = /etc/rsync.secret[back]
path = /front/backignore errorsread only = truelist = falsehosts allow = 192.168.1.252hosts 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 = yessocket_type = streamwait = nouser = rootserver = /usr/bin/rsyncserver_args = --daemonlog_on_failure += USERID}[root@tonykorn etc]#启动服务端
[root@tonykorn front]# service xinetd restartStopping xinetd: [ OK ]Starting xinetd: [ OK ][root@tonykorn front]#也有的地方说需要运行:rsync --daemon,经过试验不需要
没有运行rsync --daemon的时候进程状态是:[root@tonykorn front]# ps -ef | grep rsyncroot 24033 15043 0 17:40 pts/0 00:00:00 grep rsync运行后为:
[root@tonykorn front]# rsync --daemon[root@tonykorn front]# ps -ef | grep rsyncroot 24035 1 0 17:40 ? 00:00:00 rsync --daemonroot 24042 15043 0 17:40 pts/0 00:00:00 grep rsync[root@tonykorn front]#客户端操作
客户端同步出错:[test01@tonykorn02 ~]$ rsync -vzrtopg --progress /front/test01Password: @ERROR: auth failed on module test01rsync 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 /front/test01Password: receiving file list ... 421 files to considersent 98 bytes received 8031 bytes 2322.57 bytes/sec
total size is 134589856 speedup is 16556.75[root@tonykorn02 front]# rsync -vzrtopg --progress /front/backreceiving file list ... 50 files to considersent 62 bytes received 1007 bytes 2138.00 bytes/sec
total size is 12629876 speedup is 11814.66[root@tonykorn02 front]#来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/312079/viewspace-245849/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/312079/viewspace-245849/