源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

CentOS 6.3 Rsync客户端与Win2003 cwRsyncServer服务端实现数据同步

  • 时间:2021-10-22 12:47 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:CentOS 6.3 Rsync客户端与Win2003 cwRsyncServer服务端实现数据同步
[b]说明:[/b] 1、cwRsyncServer服务端 系统:Windows Server 2003 IP地址:192.168.21.134 数据存放目录:D:\osyunwei 2、Rsync客户端 系统:CentOS 6.3 IP地址:192.168.21.132 同步的目录:/osyunwei [b]实现目的:[/b] Rsync客户端每天凌晨3:00自动同步cwRsyncServer服务端D:\osyunwei目录中的数到/osyunwei目录 [b]一、cwRsyncServer服务端配置[/b] 附件: cwRsyncServer下载地址: [url=http://www.1sucai.cn/softs/55933.html]http://www.1sucai.cn/softs/55933.html[/url] 解压cwRsyncServer_4.0.3_Installer.zip,双击cwRsyncServer_4.0.3_Installer.exe [img]http://files.jb51.net/file_images/article/201507/2015070916264016.jpg[/img] Next [img]http://files.jb51.net/file_images/article/201507/2015070916264017.jpg[/img] I Agre(同意) [img]http://files.jb51.net/file_images/article/201507/2015070916264018.jpg[/img] 安装路径,默认即可 Next [img]http://files.jb51.net/file_images/article/201507/2015070916264019.jpg[/img] Service account:SvcCWRSYNC    (新建的一个系统账户) Type password:密码 Confirm password:密码 备注:系统会自动创建一个账户:SvcCWRSYNC来运行cwRsyncServer服务端程序 以上信息默认即可 Install (安装) [img]http://files.jb51.net/file_images/article/201507/2015070916264020.jpg[/img] Close(关闭),安装完成 [img]http://files.jb51.net/file_images/article/201507/2015070916264021.jpg[/img] 开始-设置-控制面板-管理工具-服务 找到RsyncSever选项,双击打开 启动类型:自动 点“启动” [img]http://files.jb51.net/file_images/article/201507/2015070916264022.jpg[/img] 应用-确定 [img]http://files.jb51.net/file_images/article/201507/2015070916264123.jpg[/img] 打开D盘,右键单击osyunwei文件夹,选择属性,切换到安全选项,点添加 输入:SvcCWRSYNC 确定 [img]http://files.jb51.net/file_images/article/201507/2015070916264124.jpg[/img] 允许所有权限 应用,确定 [img]http://files.jb51.net/file_images/article/201507/2015070916264125.jpg[/img] 打开C:\Program Files\ICW目录 用记事本打开rsyncd.conf,修改添加以下内容(修改之前先备份文件为rsyncd.confbak) use chroot = false strict modes = false hosts allow = * log file = rsyncd.log # Module definitions # Remember cygwin naming conventions : c:\work becomes /cygwin/c/work # #[test] #path = /cygdrive/c/work #read only = false #transfer logging = yes [osyunwei] path = /cygdrive/d/osyunwei read only = true #客户端只读 list = no  #不允许列出文件 hosts allow=192.168.21.132  #允许连接IP,多个IP中间用英文状态下逗号隔,不限制IP填写 *即可 auth users =osyunwei  #允许连接的用户名 secrets file = etc/rsyncd.secrets  #存放用户名密码的认证文件路径 修好完成之后,保存退出 [img]http://files.jb51.net/file_images/article/201507/2015070916264126.jpg[/img] 在C:\Program Files\ICW\etc目录下面新建rsyncd.secrets文件 用记事本打开,输入以下内容 osyunwei:123456    #用户名:密码 最后保存退出 [b]cwRsyncServer[/b][b]服务端安装设置完成[/b] [b]二、Rsync客户端配置[/b] 1、关闭SELINUX vi /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq #保存,退出 shutdown -r now #重启系统 2、开启防火墙tcp 873端口(Rsync默认端口,Rsync作为客户端是不需要开启防火墙端口的,这里开启,方便以后扩展作为服务端) vi /etc/sysconfig/iptables #编辑防火墙配置文件 -A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT :wq! #保存,退出 /etc/init.d/iptables restart #最后重启防火墙使配置生效 3、安装Rsync客户端软件 yum install rsync xinetd   #安装,如下图所示,输入y安装 [img]http://files.jb51.net/file_images/article/201507/2015070916264127.jpg[/img] vi /etc/xinetd.d/rsync  #编辑配置文件,设置开机启动rsync 把disable = yes 修改为 disable = no :wq! #保存,退出 /etc/init.d/xinetd start  #启动(CentOS中,Rsync是以xinetd来管理的) 4、测试Rsync客户端是否与cwRsyncServer服务端通信成功(cwRsyncServer服务端防火墙需要开启tcp 873端口) yum install telnet   #安装telnet测试工具 telnet 192.168.21.134 873  #输入命令后回车,如下图所示,表示通信成功 [img]http://files.jb51.net/file_images/article/201507/2015070916264128.jpg[/img] [b]Rsync客户端安装设置完成[/b] [b]三、设置Rsync客户端与cwRsyncServer服务端同步数据([/b][b]以下操作在Rsync客户端进行)[/b] 1、测试数据同步 在终端命令行输入 rsync -vzrtopg --port=873 --progress --delete [url=http://www.osyunwei.com/cdn-cgi/l/email-protection][email protected]::osyunwei[/url] /osyunwei [img]http://files.jb51.net/file_images/article/201507/2015070916264129.jpg[/img] 提示输入密码:123456   [b]注意:此处的密码为cwRsyncServer服务端C:\Program Files\ICW\etc\rsyncd.secrets文件配置的密码[/b] 回车之后,图下图所示,表示数据同步成功 [img]http://files.jb51.net/file_images/article/201507/2015070916264130.jpg[/img] [img]http://files.jb51.net/file_images/article/201507/2015070916264131.jpg[/img] cd  /osyunwei  #进入数据同步目录 ls  #显示文件信息 可以看到数据已经存在了 2、添加计划任务,每天自动执行数据同步脚本 vi  /etc/passwd.txt    #配置文件,添加以下内容 123456  #密码 :wq!  #保存退出 chmod 600 /etc/passwd.txt   #设置文件权限,只设置文件所有者具有读取、写入权限即可 cd /home vi  osyunweibak.sh   #编辑,添加以下内容 #!/bin/sh rsync -vzrtopg --port=873 --progress --delete [url=http://www.osyunwei.com/cdn-cgi/l/email-protection][email protected][/url]::osyunwei /osyunwei --password-file=/etc/passwd.txt :wq!   #保存,退出 chmod +x /home/osyunweibak.sh  #添加脚本直接权限 yum install vixie-cron  #安装计划任务,某些系统上可能没有预装 vi  /etc/crontab   #编辑,在最后添加以下内容 0 3 * * * root /home/osyunweibak.sh     表示每天凌晨3点执行备份  :wq!  #保存,退出   chkconfig crond on #设为开机启动 service crond start #启动 /etc/rc.d/init.d/crond restart  #重启 设置完成之后, 每天凌晨3点,Rsync客户端会自动同步cwRsyncServer服务端D:\osyunwei目录数据到自己的/osyunwei目录中 [b]至此,CentOS 6.3 Rsync客户端与Windows Server 2003 cwRsyncServer服务端实现数据同步设设置完成[/b]     
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部