一、环境
1、linux系统的数据需要同步到windows
2、linux系统为centos7,windows系统为server 2012 R2
3、centos7部署rsync服务端(192.168.124.49),server 2012部署客户端(192.168.124.54)
4、附下载地址【如果失效请联系发文者获取】:
链接:https://pan.baidu.com/s/1BGt5yWtsaVi2UefI3D1Adg
提取码:x9an
二、服务端安装
1、安装rsync服务
yum install -y rsync
2、设置配置文件,添加一下内容
vi /etc/rsyncd.conf
uid = rsync
gid = rsync
use chroot = no
max connections = 200
timeout = 300
[input]
#path = /home/web/test/
path = /home/web/patientCardApply/
read only = false
#write only = true
list = false
auth users = rsync
secrets file = /etc/rsyncd.secrets
说明:
path :需要提供数据的访问目录
auth:声明访问用户
secrets:声明存放用户密码的文件
3、设置目录权限
chown -R rsync.rsync /home/web/patientCardApply/
4、设置密码文件权限600,只能设置为600
chmod 600 /etc/rsyncd.secrets
5、启动服务
systemctl start rsyncd
6、查看是否启动成功
7、防火墙开启端口837
firewall-cmd --zone=public --add-port=837/tcp --permanent
systemctl restart firewalld
三、客户端安装
1、安装服务,双击安装文件,点击下一步
2、按照提示点击同意
3、保持默认
4、定义需要将服务安装到那个目录,也可以默认。我选择自定义安装目录
5、安装完毕
6、通过cmd方式进入rsync的bin目录
7、按照正常情况下,我们应该在客户端防止一个密码文件,这里采用直接输入的方式
8、执行同步任务:
E:\rsync\cwRsync\bin>rsync -vzrtopg --progress rsync@192.168.124.49::input /cygd
rive/e/nfs/patientCardApply
说明:
1、如果需要删除客户端与服务端不一致的文件,可以加参数–delete
2、/cygdrive/e,表示盘符E
注:如果服务端是windows操作系统的,按照提示安装,进入安装目录修改配置文件,参数和linux下一样设置
参考:
https://www.linuxidc.com/Linux/2017-06/144757.htm
http://blog.sina.com.cn/s/blog_4da051a60101h8am.html
https://www.cnblogs.com/janas/p/3321087.html