CentOS6.5 Rsync遠程同步

實驗需求:在服務器(192.168.100.1)端搭建rsync服務,將/usr/src目錄同步到客戶端/rsync目錄

一.服務器配置

1.開啓服務

#vim /etc/xinetd.d/rsync

……

   disable = no                   //把disable = yes改成no    

……

或者執行以下命令也能開啓服務

# chkconfig rsync on

#service xinetd start


2.建立rsync賬號文件

# vim /etc/rsync_users

 ruser:123456

# chmod 600 /etc/rsync_users           //修改權限


3.創建rsync主配置文件

# vim /etc/rsyncd.conf              //默認不存在

uid = nobody

gid = nobody

use chroot = yes

pid file = /var/run/rsyncd.pid

log file = /var/log/rsyncd.log


[tools]

path = /usr/src

comment = Rsync share test

auth users = ruser

secrets file = /etc/rsync_user

read only = yes


4.重啓xinetd服務

# service xinetd restart


二.客戶端配置

1.創建測試目錄

# mkdir /rsync


2.同步rsync共享目錄

# rsync [email protected]::tools    //瀏覽共享

# vim /root/rsync_pass                   //設定密碼文件

  123456                                //只需寫登錄用戶密碼,要與服務器端設置密碼一致

# chmod 600 /root/rsync_pass             //不修改權限會報錯

# rsync -az --password-file=/root/rsync_pass [email protected]::tools /rsync  //同步



3.將rsync放入crontab計劃任務,每天同步一次

#crontab -e
0 5 * * * /usr/bin/rsync -a --password-file=/root/rsync_pass [email protected]::tools /rsync


                   


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章