rsync---完全配置
先查看本机是否装有rsync-2.6.3-1软件包
Shell> rpm -qa |grep rsync
修改名为/etc/xinetd.d/rsync文件
把disable = yes 改成
disable = no
配置远程同步主配置文件rsyncd.conf
Shell> vi /etc/rsyncd.conf
配置成以下内容:
# Global Settings
secrets file = /etc/rsyncd.pwd
uid = nobody
gid = nobody
use chroot= no
max connections = 4
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
# Share Definitions
[share]
comment = site of foxshare 's directory from 192.168.1.250
path = /var/www/share
auth users = rsync
read only = yes
ignore errors
list = no
建立密码认证文件
Shell> vi /etc/ rsyncd.pwd
Rsync:123456
注意密码文件的权限是root用户,而且权限必须是600
重新启动超级守护进程
Shell> service xinetd restart
如果想让客户机同步服务器的时候不输入密码,则需要在客户机上建立密码文件/etc/ rsyncd.pwd,此密码文件只包含密码,和主服务器的密码一样,并且权限必
须是600。
Shell> more /etc/rsyncd.pwd
123456
在客户机上执行rsync命令,以同步主服务器文件
Shell>/usr/bin/rsync -vazu --delete /var/www/share1/ --password-file=/etc/rsyncd.pwd
然后,通过crontab设定,让这个命令每10分钟运行一次。
Shell> */10 * * * * /usr/bin/rsync -vazu --delete --progress /var/www/share1/ --password-file=/etc/rsyncd.pwd
这时,同步文件就开始了。
注意:文件同步的时候把文件的权限也同步了,所以需要在服务器和客户机之间需要有相同的uid和gid。