linux sync檔案同步之經驗總結

來源:互聯網
上載者:User

今天研究了一下關於 在linux上資料同步的問題。

A伺服器上的檔案同步到B、C伺服器

rsync服務端做的設定如下:(rsync安裝省略)

在A伺服器上做如下配置:

1, 安裝rsync服務,查看rsync服務命令是ps -ef|grep rsync,啟動rsync命令是rsync --daemon。,

2, /etc/rsyncd.conf檔案配置如下:(rsync.conf檔案手動建立)

   uid = root
   gid = root
   use chroot = no
   max connections = 20
   log file = /var/log/rsyncd.log
   #lock file = /var/run/rsync.lock
   syslog facility = local5
   pid file = /var/run/rsyncd.pid
[wwwroot]
   path = 同步檔案路勁
   comment = wwwroot mapping jlWW WEB
   hosts allow = B、C伺服器IP

3:啟動服務:rsync --daemon

查看是否啟動:ps - ef|grep rsync

若出現rsync --daemon進程,則啟動成功。

4:在B、C伺服器上配置:

在root下建立websync.sh

編輯:rsync -vzrtopg --delete A伺服器IP::同步資料夾名稱  同步資料夾至那個路勁下

註解:

v是verbose,z是壓縮,topg是保持檔案原有屬性(屬主,時間參數)。

--delete是指 如果服務端刪除了這個檔案,那麼可換段也會刪除相對應的檔案

5;執行crontab -e

編輯:*/2 * * * * /root/websync.sh

6::執行crontabl -l

若出現error:

1:檢查rsync.config和websync.sh是否具有執行許可權。

2:編輯 vi /etc/service輸入rsync   873/tcp和rsync 873/udp

3:檢查設定檔有誤符號和拼字錯誤。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.