rsync同步配制
2019獨角獸企業重金招聘Python工程師標準>>>
1、下載安裝rsync
wget http://rsync.samba.org/ftp/rsync/rsync-3.1.2.tar.gz tar zxvf rsync-3.1.2.tar.gz cd rsync-3.1.2 ./configure --prefix=/usr ;make ;make install? ?2、配制rsync.conf
# vim /etc/rsyncd/rsyncd.conf
uid = nobody gid = nobody port = 873 # 指定運行端口,默認是873,您可以自己指定 hosts allow = 192.168.102.101 # 允許訪問的客戶機,多個以逗號隔開 #hosts deny = 0.0.0.0/32 #拒絕訪問的 use chroot = no max connections = 10 timeout = 500000 pid file = /var/run/rsyncd.pid ##pid文件的存放 lock file = /var/run/rsync.lock ##鎖文件的存放位置 log file = /var/log/rsyncd.log ##日志記錄文件的存放 #motd file = /etc/rsyncd.motd #歡迎 secrets file = /etc/rsyncd/rsyncd.passwd ## 指定認證文件 ## 上面這段是全局配置,下面的模塊可以有 [test] ## 模塊名字,自己命名 path = /home/rsync/test #指定文件目錄所在位置,這是必須指定 comment = rsync files ##注釋 ignore errors ##忽略IO read only = no #list = no ## 是否把rsync 服務器上提供同步數據的目錄顯示 ## 下面這一行,同步驗證時用的賬號,如果沒有這項就是匿名同步,client同步時不用用戶名也能同步。 auth users = rsync3、生成密碼文件
#vim /etc/rsyncd/rsyncd.passwd
rsync:123456@7894、文件權限修改
chmod 644 /etc/rsyncd/rsyncd.conf chmod 600 /etc/rsyncd/rsyncd.passwd5、啟動rsync
/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf也可以將上面的命令寫到/etc/rc.local里,實現開機自啟動rsync服務
6、客戶端配制
基本同服務器的配制.
7、手動同步
rsync -avzP david@192.168.1.16::test ?/tmp/david/
8、自動同步加入定時任務里
0 9 * * * /usr/bin/rsync -vzrtopg --delete --progress rsync@192.168.1.16::test /home/data/nginx/html/ --password-file=/etc/rsyncd/rsyncd.passwd?
轉載于:https://my.oschina.net/u/933928/blog/743570
總結
- 上一篇: MyPython--进阶篇--异常
- 下一篇: freeswitch呼叫流程分析