Centos 6.3下rsync+sersync安裝配置筆記

來源:互聯網
上載者:User

最近單位活比較多,所以就很少更新,晚上上網碰巧看到一篇關於sersync的介紹,個人感覺較rsync+inotify配置更加規範,剛好最近手癢,就總結了下,分享給大家。

目前業內比較靠譜的同步解決方案有:

rsync+inotify-tools,Openduckbill+inotify-tools和rsync+sersync

前兩者由於是基於指令碼語言編寫,所以規範程度,執行效率相對rsync+sersync就稍微弱一些。

sersync是使用c++編寫,基於boost1.43.0,inotify api,rsync command開發,主要用於伺服器同步,web鏡像等功能。其對linux系統檔案系統產生的臨時檔案和重複的檔案操作能夠進行過濾,所以在結合rsync同步的時候,節省了運行時耗和網路資源。因此更快,更適合線上使用。

本篇博文就是為了實現將sersync推送端/data下的資料即時同步到rsync接收端/data目錄下,實現rsync伺服器為sersync的鏡像伺服器

註:使用rsync+crontab做定時同步時,主伺服器端開啟rsync守護進程,而鏡像伺服器是運行rsync用戶端,平時一般會利用crontab定時擷取rsync伺服器上的資料。

但使用rsync+sersync做即時同步時,用於推送檔案的伺服器運行sersync服務,用於接收檔案的伺服器則運行rsync守護進程,簡單來說就是sersync會利用rsync命令將檔案推送到rsync伺服器,實際線上使用一般會把sersync作為主伺服器,rsync作為鏡像伺服器,實現資料同步備份,web鏡像等功能

解決方案:

作業系統:    centos6.3 x86

rsync:       centos內建yum源

sersync:     sersync2.5_32bit

sersync 推送端  192.168.100.74

rsync   接收端  192.168.100.29

環境搭建:(接收端,推送端)

一.首先關閉selinux與iptables

# vi /etc/sysconfig/selinux

---------

SELINUX=disabled

---------

# setenforce 0

# service iptables stop

在使用sersync之前,我們必須安裝配置好rsync伺服器

rsync (接收端)

一.安裝rsync(centos6.3預設已安裝)

# yum install rsync -y

# yum install xinetd -y

二.啟動rsync依賴服務

# /etc/init.d/xinetd start

# chkconfig xinetd on

三.配置:

# vi /etc/rsyncd.conf

--------------------

uid = root

gid = root

use chroot = no

max connections = 10

strict modes = yes

port = 873

address = 192.168.100.29

[data] # rsync模組名,後面配置sersync會用到

path = /data  # 該同步目錄只要uid所指定的使用者有寫入權限即可

comment = mirror for test

ignore errors

read only = no

list = no

auth users = user

secrets file = /etc/rsync.pas # 密碼認證檔案,必須為600許可權,否則rsync傳輸會報錯

hosts allow = *

# hosts deny = 0.0.0.0/0

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

--------------------

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.