rsync配置

来源:互联网 发布:广州淘宝代运营 编辑:程序博客网 时间:2024/05/01 07:59
之前折腾了好久的rsync,每次都报错验证失败,研究了好久,今天终于配置成功了。个人认为rsyncd抽风,一模一样的配置今天就可以了。。。



下面的是rsync的配置
1.在主从上安装rsync

apt-get install rsync

2.主的配置

mkdir /etc/rsyncd
vi /etc/rsyncd.conf
# Minimal configuration file for rsync daemon
# See rsync(1) and rsyncd.conf(5) man pages for help
# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root
gid = root
use chroot = no
read only = yes
#limit access to private LANs
hosts allow=10.26.13.193 10.26.13.195
hosts deny=*
max connections = 5
pid file = /var/run/rsyncd.pid
secrets file = /etc/rsyncd/rsyncd.secrets
#lock file = /var/run/rsync.lock
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
# MODULE OPTIONS
[chinatmp]
path = /tmp/china/
list=yes
ignore errors
auth users = china
comment = tmp_china
[test]
path = /tmp/china1/
list=yes
ignore errors
auth users = haha
comment = hahaha

path 是主服务准备传文件的路径
auth users 这个user不用是系统用户,可以随意起名
comment 随便写
[test] 或 [chinatmp] 这个是认证名,远程连接时要用

然后 vi /etc/default/rsync
RSYNC_ENABLE=true

ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf

以上主服务就配置好了


3.从服务安装rsync后直接连接

rsync -avzP haha@10.26.13.195::test /tmp/hina
-avzP 这些参数根据自己需要填写
haha 这个是主服务上面的用户
10.26.13.195 主服务允许访问的地址
test 主服务配置文件里[test]模块名
/tmp/hina 这个地址是从主传到本地的位置,如果不存在会自动创建

以上最简单的rsync就配置好了。有疑问可以看日志 /var/log/rsync.log





0 0
原创粉丝点击