服務端配置
1、環境及相關軟件介紹
操作系統:centos7.7.1908
源服務器(推送):192.168.188.201
目標服務器(備份):192.168.188.203
2、rsync安裝
yum -y install rsync
配置:
log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid lock file = /var/lock/rsyncd [common] comment = rsync info path = /tmp/test #該路徑為需要同步的路徑 ignore errors auth users = admin secrets file = /etc/rsyncd.pass hosts allow = 192.168.0.0/16 hosts deny = * list = false port = 873 address = 192.168.188.201 uid = root gid = root use chroot = no read only = no max connections = 10
3、創建認證文件
vi /etc/rsyncd.pass admin:123456 #格式是用戶名:密碼
授權:
chmod 600 /etc/rsyncd.pass
4、啟動rsync
systemctl start rsyncd
客戶端配置:
1、安裝rsync,客戶端安裝完畢,不用單獨配置
yum -y intall rsync
2、配置秘鑰文件
vi /etc/rsync.pass 123456 授權: chmod 600 /etc/rsync.pass
3、同步文件測試
rsync -avz --delete --exclude=ccaaa --password-file=/etc/rsync.pass admin@192.168.188.201::common /tmp/test/ #--exclude=ccaaa 表示不復制ccaaa文件 #--delete 表示服務端、客戶端文件完全同步