yum 安裝兩個包
yum install rsync xinetd
打開rsync服務,重啓xinetd服務,關閉SeLinux
chkconfig rsync on
service xinetd restart
setenforce 0
手工配置xinetd服務中rsync的內容
指定服務啓動參數, 找到包含server_args 的行。
vi /etc/xinetd.d/rsync
disable = no
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