rsync配置
爲實現同步更新文件配置了下rsync
在redhat系統上配置 rsync-2.6.3-1
服務端相關配置
1.在/etc/下創建三個文件
rsyncd.conf rsyncd.motd rsyncd.secrets
2.配置文件
vi rsyncd.conf
motd file = /etc/rsyncd.motd #歡迎文件
read only = no
list = yes
uid = root
gid = root
hosts allow = 192.168.128.133
hosts deny =192.168.128.0/24
max connections = 2
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
#define dirctory for rsync
[test]
comment = nagios's directory from 192.168.128.133
path =/test
secrets file =/etc/rsyncd.secrets#密碼文件
auth users = test #rsync用戶(與linux裏的用戶無關)
read only = no
3.歡迎文件
[root@localhost test]# vi /etc/rsyncd.motd
Welcome to use the rsync services!
4.密碼文件
[root@localhost test]#vi /etc/rsyncd.secrets
test:test
5.chmod 600 /etc/rsyncd.*
6.運行rsync
/usr/local/rsync/bin/rsync --daemon /etc/rsyncd.conf
rsync的路徑 rsync配置文件
7.客戶端相關配置
a)安裝rsync包
b)創建密碼文件
[root@localhost ~]#vi /etc/rsyncd.secrets
test#客戶端只需密碼無須用戶
c)chmod 600 /etc/rsyncd.secrets
如果沒有這步會報
password file must not be other-accessible
continuing without password file
Password:
d)rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets [email protected]::test/root/test
測試連接
8.實現定時同步
8.實現定時同步
crond.rsync
*/10 * * * * rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets[email protected]::test /root/test
crontab crond.rsync
crontab -e編輯現在有crontab
crontab -l