Crazy knowledge base

rsync 镜像(同步)服务器配置

1、安装略过

2、服务端配置
(1)、创建/etc/rsyncd/目录,在目录添加rsyncd.cnf rsyncd.motd rsyncd.secrets三个文件。

(2)、rsyncd.cnf 主配置文件

pid file = /var/run/rsyncd.pid
port = 873
address = 192.168.1.100
#uid = nobody
#gid = nobody
uid = root
gid = root

use chroot = yes
read only = yes

#limit access to private LANs
#hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
#hosts deny=*

max connections = 5
motd file = /etc/rsyncd/rsyncd.motd

#This will give you a separate log file
log file = /var/log/rsync.log

#This will log every file transferred - up to 85,000+ per user, per sync
#transfer logging = yes

log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

strict modes = false

[aaa]
comment = Great stuff from remote.acme.com
path = /home/root/aaa

[android]
path = /home/root/bbb
list=yes
ignore errors
auth users = joe
secrets file = /etc/rsyncd/rsyncd.secrets
comment = joe's home
#exclude =   beinan/  samba/

(3)、rsyncd.motd 客户端连接显示欢迎信息

+++++++++++++++++++++++++++++++++++++++++++++++++++
+ Welcome to rsync service
+++++++++++++++++++++++++++++++++++++++++++++++++++

(4)、rsyncd.secrets 客户端连接帐号

joe:joe

2、启动

rsync --daemon  --config=/etc/rsyncd/rsyncd.cnf

3、打开873端口

iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT

4、 客户端查看同步内容

rsync  --list-only  joe@192.168.1.100::

5、客户端同步服务器指定目录

rsync -avzP --delete --password-file=rsyncd.passwd joe@192.168.1.100::aaa aaa

说明:
-a 参数,相当于-rlptgoD,-r 是递归 -l 是链接文件,意思是拷贝链接文件;-p 表示保持文件原有权限;-t 保持文件原有时间;-g 保持文件原有用户组;-o 保持文件原有属主;-D 相当于块设备文件;
-z 传输时压缩;
-P 传输进度;
-v 传输时的进度等信息,和-P有点关系,自己试试。可以看文档;
–delete 选项,表示客户端上的数据要与服务器端完全一致,如果 linuxsirhome目录中有服务器上不存在的文件,则删除
–password-file,登录密码可以存入rsyncd.passwd文件,注意文件权限必需设为600,否则会提示password file must not be other-accessible continuing without password file,要求重新输入

详见:http://www.linuxsir.org/main/?q=node/256

rsync 镜像(同步)服务器配置
滚动到顶部