centos7安裝rsync及兩台機器進行文件同步


安裝及配置

yum -y install rsync  
#啟動rsync服務
systemctl start rsyncd.service
systemctl enable rsyncd.service

#檢查是否已經成功啟動
netstat -lnp|grep 873

服務端配置

# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

uid = root
gid = root
port = 873
use chroot = no
# read only = no
# list = no
max connections = 4
# pid file = /var/run/rsyncd.pid
exclude = lost+found/
transfer logging = yes
timeout = 900
motd file = /etc/rsyncd/rsyncd.motd
log file = /var/log/rsyncd.log
lock file = /var/run/rsyncd.lock
ignore nonreadable = yes
dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

[simba]
path = /root/************/
comment=simba
ignore errors
read only = no
write only = no
list = no
auth users = root
secrets file = /etc/rsyncd.pass
hosts allow = *

給rsync定義身份,如下:

echo 'root:123456'>/etc/rsyncd.passwd   //文件用戶名和路徑為上面定義,別寫錯,密碼自己定
chmod 600 /etc/rsyncd.passwd        //修改權限

 

重啟服務

systemctl restart rsyncd.service

 

客戶端配置

創建密碼

echo '123456' >>/etc/rsyncd-test.passwd     //注意這里只需要服務器rsyncd.passwd 中的密碼
chmod 600 /etc/rsyncd-test.passwd

同步

rsync -auv --password-file=/etc/rsyncd-test.passwd  /root/*********/ root@120.x.x.x::simba

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM