> CentOS > CentOS教程 >

centos6.8 安装配置rsync

yum 安装两个包

yum install rsync xinetd

打开rsync服务,重启xinetd服务,关闭SeLinux

chkconfig rsync on
service xinetd restart
setenforce 0

手工配置xinetd服务中rsync的内容

指定服务启动参数, 找到包含server_args 的行。

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

手工创建/etc/syscnd/目录及文件

cd /etc/
mkdir rsyncd
cd rsyncd
touch /etc/rsyncd/rsyncd.conf
touch rsyncd.passwd rsyncd.passwd
chmod 600 rsyncd.passwd
vi rsyncd.conf

rsyncd.conf文件内容示例

uid = root
gid = root

use chroot = no
read only = yes

#limit access to private LANs
hosts allow=124.3.1.3/255.255.255.0 11.16.52.249/255.255.255.0
hosts deny=*
max connections = 5

pid file = /var/run/rsyncd.pid

secrets file = /etc/rsyncd/rsyncd.passwd
#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
[module]
path = /var/www/html/test/
list=yes
ignore errors
auth users = username
comment = test
# exclude = cache/

配置rsyncd.passwd

vi /etc/rsyncd/rsyncd.passwd

添加用户名和密码

username:password

打开防火墙iptables端口

vi /etc/sysconfig/iptables

在适当位置添加新行

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

rsync命令示例

rsync -avz --progress  username@11.16.52.249::module ./test

提示输入密码,输入password。

遇到问题,注意查看系统状态

getenforce
netstat -an | grep 873


(责任编辑:IT)