最简单的只读同步工作。
一,服务端的配置
1,安装rsync(阿里云默认已有此程序)
略
2,生成文件rsyncd.conf,内容如下:
#secrets file = /etc/rsyncd.secrets #motd file = /etc/rsyncd.motd read>list = yes uid = xx gid = xxt 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 [hosts_sync] comment = rsync path = /usr/local/xx/ read only = yes #auth users = rsync
3,启动rsync进程,将之加入自动启动
a, /usr/bin/rsync --daemon
b,在/etc/rc.local里写入:/usr/bin/rsync –daemon (也可以其它方式实现)
二,客户端上配置:
1,crontab定时同步脚本:
*/2 * * * * /usr/bin/rsync -arv 1xx.xx.xx.xx::hosts_sync/ /usr/xxx/ >> /var/log/rsyncd.log 2>&1 同步目录 /usr/bin/rsync -arv xx.xx.xx.xx::hosts_sync/xxx.gz /back/xxx.gz 同步文件
时间: 2024-10-12 11:38:33