由于之前使用WINDOWS DFS来同步F1和F2之间的图片目录时,DFS的不透明和可控性较低,
导致有的产品目录不能及时上线。
我将这一同步过程更改为通过cwRsync软件(Windows Version )来实现。
下面给出建立服务器,客户端,配置文件,免手工密码输入,BAT,计划任务过程。
作为KB存档。为以后建立类似服务和解决问题故障提供参照。。
第一步,安装服务器端和客户端
http://sourceforge.net/projects/sereds/files/cwRsync/4.0.5/
此处可下载cwRsync4.05版本的SERVER 和CLIENT。
本次布置的方案是以F1为SERVER
F2为CLIENT。
然后,F1定期从F2接受更新同步的数据。
安装过程默认安装即可。
安装过程中要设置管理用户名和密码(用户名默认为SvcCWRSYNC,密码设置为********),安装完成之后,将SERVICE调为AUTOSTART。
第二步,配置rsyncd.conf文件。
文件所在位置:
C:\Program Files (x86)\ICW
文件的具体含义如下:
1.
use chroot = false #
不使用
chroot
2.
strict modes = false #
静态模式
3.
hosts allow = * #
所有
IP
均可
4.
log file = rsyncd.log #log
文件名,可以指定路径
5.
pid file = rsyncd.pid
6.
port = 8173 #
默认端口
873
7.
uid = 0 #
不指定
uid
,不加这一行将无法使用任何账户
8.
gid = 0 #
不指定
gid
9.
max connections = 10 #
最大连接数
10
10.
11.
# Module definitions
12.
# Remember cygwin naming conventions : c:work becomes /cygwin/c/work
13.
[web_1]
14.
path = /cygdrive/d/www/web_1 #
需要备份的路径
(D
盘
www/web_1
目录
)
15.
read only = false #
只读
16.
transfer logging = yes #
记录传输日志
17.
ignore errors #
忽略无关的
IO
错误
18.
list = no #
不列文件表
19.
hosts allow = 10.8.5.0/255.255.255.0 #
允许访问的
IP
20.
hosts deny = * #
不允许
hosts allow
以外的任何
IP
访问
21.
22.
23.
[web_2]
24.
path = /cygdrive/d/www/web_2 #
需要备份的路径
(D
盘
www/web_2
目录
)
25.
read only = false #
只读
26.
transfer logging = yes #
记录传输日志
27.
ignore errors #
忽略无关的
IO
错误
28.
list = no #
不列文件表
29.
hosts allow = 10.8.5.0/255.255.255.0 #
允许访问的
IP
30.
hosts deny = * #
不允许
hosts allow
以外的任何
IP
访问
我所用的配置如下:
use chroot = false
strict modes = false
read only = yes
list = no
hosts allow = *
max connections = 10
lock file = rsyncd.lock
motd file = rsyncd.motd
log file = rsyncd.log
pid file = rsyncd.pid
transfer logging = yes
uid = 0
gid = 0
auth users= rsyncuser
secrets file = rsyncd.secrets
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[All-P]
path = /cygdrive/C/F1/All-P
read only = false
transfer logging = yes
第三步:在服务器端创建rsyncd.secrets文件,
在里面输入相应的用户名和密码:
rsyncuser:********
第四步,配置CWRSYNC客户端
创建一个RSYNCD.SECRETS文件,在文件里仅输入密码
********
第五步,建立BAT及计划任务
将同步的任务作成计划BAT:
@echo off
C:\"Program Files"\cwRsync\bin\rsync -vzrtopg --progress rsyncuser@XX.XX.XX.XX::All-P /cygdrive/E/images/All-P/ --password-file=/cygdrive/e/images/rsyncd.secrets
如果在以上过程中,需要提示输入密码的话,以下URL值得参考:
http://interice.blog.163.com/blog/static/2427811220123204582894/
。。。
10、测试执行及故障的排除。
配置完成后执行批处理文件bak.bat,提示密码文件的所有者必须是root
ERROR: password file must be owned by root when running as root
被这一问题困扰了很长时间,从网上也查不到很好的解决办法,最后还是自己琢磨出来了。
解决方法:
在命令行窗口进入cwRsync安装路径的bin目录下,
执行ls -l /cygdrive/c/pwd.conf,可以看到pwd.conf文件的所有者是4294967295,我了个去。
于是用命令修改,chown Administrator /cygdrive/c/pwd.conf
因为按照提示把所有者改为root,会提示root为不可用的用户 invalid user: `root'
所以试着把所有者改为Administrator,再次ls -l 查看,看到所有者已经变更了
需要注意的是如果bin目录下没有ls.exe、chown.exe等文件,是因为cwRsync客户端不安装这些文件,但是服务器端的bin目录下是有的,所以需要把这些文件拷贝过来。我太有才了。
。。。
同步过程中的截图: