service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = –daemon
log_on_failure += USERID
}
#chkconfig rsync on
#rsync configuration file
secrets file = /etc/rsyncd.secrets
motd file = /etc/rsyncd.motd
rad>list = yes
uid = root
gid = root
use chroot = no
max connections = 5
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
# Remote sync configuration module
[home]
comment = home~~sync directory
path = /home/
auth users = test
[root@localhost web]# vi /etc/rsyncd.secrets
test:3PfesfesrserwDrsererWX
[root@localhost web]# chown root.root /etc/rsyncd.secrets
[root@localhost web]# chmod 600 /etc/rsyncd.secrets
# vi /etc/rsyncd.motd
rsyncd.motd记录了rsync服务的欢迎信息,你可以在其中输入任何文本信息,如:
Welcome to use the rsync services!
启动:
# /usr/bin/rsync –daemon
或 # /usr/local/rsync/bin/rsync –daemon
查看启动:
ps aux | grep rsync 客户端连接使用:
/usr/bin/rsync -vzrtp –progress –port=874 –delete –password-file=/etc/rsyncd.client test@你的IP::home/web/shanmao.me /home/web/
/usr/local/rsync/bin/rsync -vzrtp –progress –password-file=/etc/rsyncd/xx.sec.client test@你的ip::home/web/mxxa_com
/home/web/
一些注意小技巧:
1.多个不同目录同步使用:在主服务器下新增一个模块:
[home]
comment = home~~sync directory
path = /home/
auth users = test
[www]
comment = home~~sync directory
path = /www/
auth users = test
2.rsync排除不同步目录
–exclude=ssl_path/data/ 排除当前模块下的这个目录,排除单文件(夹)。
排除多文件夹 –exclude-from=/tmp/rsyncext.list 其中 rsyncext.list 中一行一个
3.定时自动同步:
crontab -e
一分钟同步一次:*/1 * * * * sh /tmp/rsynctemaihui.sh >> /home/cornlog/www_jinritemaihui__rsync.txt
其中:rsynctemaihui.sh 脚本就是上面的客户端使用的同步脚本