您的位置:首页 > 运维架构 > Linux

centos6 64X rsync 使用实战

2015-12-03 13:50 731 查看
centos rsync 使用实战

场景: 搭建服务同步源,客户端拉取同步文件

服务端(191.168.1.100)

客户端(191.168.1.10)

客户端(191.168.1.20)

一、服务端搭建
mkdir /etc/rsync

1、创建密码文件

echo "www_app:test" > /etc/rsync/web.pas #可以是非用户密码

2、创建配置文件

vim /etc/rsync/rsyncd.conf

编辑如下内容

# This line is required by the /etc/init.d/rsyncd script

#pid file = /var/run/rsyncd.pid

#port = 873

#address = 192.168.1.100 #服务器ip

uid = www_app

gid = www_user

#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.motd

#This will give you a separate log file

log file = /home/www_op/rsync/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

[test]

path = /home/www_app/testdir

list=yes

ignore errors

auth users = www_app

secrets file = /etc/rsync/web.pas

comment = This is 192.168.1.100 testhome

#exclude = easylife/ samba/

#

[web]

path = /home/www_app/wwwroot/webhome/

list=yes

ignore errors

auth users = www_app

secrets file = /etc/rsync/web.pas

comment = This is 192.168.1.100 web home

3、启动

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

4、重启

查询进程:ps -ef | grep rsync

杀掉进程:kill 进程号

启动进程:rsync --daemon --config=/etc/rsync/rsyncd.conf

二、客户端(191.168.1.10)

1、编辑密码文件,服务端配置的密码

echo "test" > web.pas

rsync --list-only --password-file=web.pas www_app@192.168.1.100::test

三、常见问题

1、场景一

@ERROR: auth failed on module test

rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]

答:意思为认证失败

可能1:服务端web.pas 格式为 user:passwd,客户端web.pas 格式为:passwd

可能2:服务端 rsyncd.conf 密码文件配置错误

2、场景二

@ERROR: chroot failed

rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]

答:服务端web.pas 权限不对,必须为chmod 600 web.pas
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: