准备两台centos7
服务机:192.168.1.17
客户机:192.168.1.120
服务端安装rsync
安装
[root@localhost fdfs]# yum -y install rsync
修改配置文件
[root@localhost fdfs]# vim /etc/rsyncd.conf
添加以下行
motd file=/etc/rsyncd.welcome
[test]
path=/world
自定义欢迎信息
[root@localhost fdfs]# vim /etc/rsyncd.welcome
启动服务,关闭防火墙, 降低沙盒。
[root@localhost ~]# systemctl start rsyncd.service
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
创建文件,稍后做测试用
[root@localhost ~]# mkdir /world
[root@localhost ~]# touch /world/{1…10}.txt
客户端配置
[root@localhost ~]# yum -y install rsync
[root@localhost ~]# rsync -v 192.168.1.17::
创建同步目录并同步
[root@localhost ~]# mkdir /databak
[root@localhost ~]# rsync -a 192.168.1.17::test /databak
查看是否成功
[root@localhost ~]# cd /databak/
[root@localhost databak]# ls
10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
启动定时任务
[root@localhost databak]# crontab -e
*/30 * * * * /usr/bin/rsync -a 192.168.1.17::test /databak/