Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> 學習 Linux

CentOS 6.8 安裝與設定 rsync 服務端完整教學

一、安裝套件

rsync 由 xinetd 管理,兩個都要裝:

yum install rsync xinetd

二、啟動服務並關閉 SELinux

chkconfig rsync on
service xinetd restart
setenforce 0

三、指定 xinetd 的啟動參數

找到包含 server_args 的那一行,改成:

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

四、建立設定目錄與檔案

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

rsyncd.conf 內容範例

uid = root
gid = root
use chroot = no
read only = yes
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
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

[module]
path = /var/www/html/test
list = yes
ignore errors
auth users = username
comment = test
# exclude = cache/

hosts allow 建議只放行可信的來源網段,避免服務暴露在不相關的網路中。

五、設定密碼檔

vi /etc/rsyncd/rsyncd.passwd

格式為一行一組帳號:

username:password

六、放行防火牆

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT

七、客戶端同步測試

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

依提示輸入上一步設定的密碼即可。

八、除錯

遇到問題時先確認 SELinux 狀態與埠是否監聽:

getenforce
netstat -an | grep 873

https://xxxxxx/Linuxjc/1184804.html TechArticle

Copyright © Linux教程網 All Rights Reserved