天天看點

linux 6.5 資料同步,CentOS 6.5下Rsync遠端同步

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

Linux系統:CentOS 6.5

推薦閱讀:

一.伺服器配置

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

Rsync 的詳細介紹:請點這裡

Rsync 的下載下傳位址:請點這裡

linux 6.5 資料同步,CentOS 6.5下Rsync遠端同步