下载地址:http://rsync.samba.org/ftp/rsync/
主机:192.168.202.130
从机:192.168.202.129
1. 在主从机上新建rsyncd.conf
Vi /etc/rsyncd.conf
uid =root
gid =root
use chroot =yes
log file =/var/log/rsyncd.log
pid file =/var/run/rsyncd.pid
hosts deny =*
[picData]
comment =backup for picServer
path =/home/Gzh/rsyncBak
read only =no
auth users =root
secrets file =/etc/rsyncd.secrets
hosts allow =192.168.202.129(从机改为:192.168.202.129)
2.1) useradd Gzh
2) passwd Gzh
3) 123456(Gzh用户的密码)
4)vi /etc/rsyncd.secrets
主:123456(Gzh的密码),从:Gzh:123456
3.chmod 600 /etc/rsyncd.secrets
chmod 600 /etc/ rsyncd.conf
注意:最好就600的权限(其它的好象不行,如777)
4 . vi /etc/xinetd.d/rsync
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon --config=/etc/rsyncd.conf
log_on_failure += USERID
}
5.service xinetd restart
6.mkdir –p /home/Gzh/ rsyncBak
7.chmod -R 600 /home/Gzh/rsyncBak
8.vi /usr/local/ rsync_start.sh
/usr/bin/rsync --password-file=/etc/rsyncd.secrets -vzrtopg /home/Gzh/rsyncBak(同步数据的目录) [email protected]::picData --delete --progress
9. vi /usr/local/rsync_ontime.sh
*/1 * * * * /usr/local/rsync_start.sh > /dev/null 2>&1
10. crontab -u root rsync_ontime.sh
11.vi /etc/sysconf/iptables 开放端口: 873
Service iptables restart
uid = nobody
gid = nobody
use chroot = no # 不使用chroot
max connections = 4 # 最大连接数为4
pid file = /var/run/rsyncd.pid #进程ID文件
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log # 日志记录文件
secrets file = /etc/rsyncd.pwd # 认证文件名,主要保存用户密码,权限建议设为600,所有者root
[module] # 这里是认证的模块名,在client端需要指定
path = /var/mail # 需要做镜像的目录(我的理解是存放 主服务同步下来的文件)
comment = backup xxxx # 注释
ignore errors # 可以忽略一些无关的IO错误
read only = yes # 只读
list = no # 不允许列文件
auth users = postfix # 认证的用户名,如果没有这行,则表明是匿名