日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Sersync+Rsync 增量实时同步

發布時間:2023/12/9 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Sersync+Rsync 增量实时同步 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?準備環境:

rsync服務器:172.16.3.21

sersync2服務器:172.16.3.23

一、?rsync服務

先把原來的rsync包刪掉yum?remove?rsync-2.6.8-3.1?-y,

然后到http://rsync.samba.org/下載rsync包我用的包如下圖所示

?

利用securecrt上傳本地

[root@acong?tongbu1]#?cd?/home/lincong/tools/

[root@acong?tools]#?ll

total?52084

drwxr-xr-x?19?root?root?????4096?Sep?20??2006?linux-2.6.18

-rw-r--r--??1?root?root?52467340?Aug??2?14:15?linux-2.6.18.tar.gz

drwxrwxr-x?10?root?root?????4096?Aug??2?23:36?rsync-3.0.9

-rw-r--r--??1?root?root???792725?Aug??2?15:34?rsync-3.0.9.tar.gz

[root@acong?tools]#?tar?zxf?rsync-3.0.9.tar.gz ##解壓

[root@acong?tools]#?cd?rsync-3.0.9 ##進入目錄

[root@acong?tools]#?./configure?--prefix=/usr

[root@acong?tools]#?make?&&?make?install ##編譯安裝

[root@acong?tools]#?mkdir?-p?/opt/tongbu1

[root@acong?tools]#?vim?/etc/rsyncd.conf

uid=root

gid=root

max?connections=36000

use?chroot=no

log?file=/var/log/rsyncd.log

pid?file=/var/run/rsyncd.pid

lock?file=/var/run/rsyncd.lock

[tongbu1] ##模塊

path=/opt/tongbu1 ##推送目錄

comment?=?xoyo?video?files

ignore?errors?=?yes

read?only?=?no

hosts?allow?=?172.16.3.0/24

hosts?deny?=?*

[root@acong?tools]#?rsync?--daemon

[root@acong?tools]#?netstat?-npl|grep?873

tcp????????0??????0?0.0.0.0:873?????????????????0.0.0.0:*???????????????????LISTEN??????6509/rsync??????????

tcp????????0??????0?:::873??????????????????????:::*????????????????????????LISTEN??????6509/rsync??????????


  • 二、?sersync2服務器:??
  • 這里有兩個連接一個是針對64位的,一個是32位的,所以一定要選好否則后面出錯了你排查不到原因,所以在這里叮囑一下。?
  • wget?http://sersync.googlecode.com/files/sersync2.5_64bit_binary_stable_final.tar.gz?
  • wget?http://sersync.googlecode.com/files/sersync2.5_32bit_binary_stable_final.tar.gz?
  • [root@acong?tools]#?tar?zxf?sersync2.5_32bit_binary_stable_final.tar.gz?

    [root@acong?tools]#?cd?GNU-Linux-x86/

    [root@acong?GNU-Linux-x86]#?ll

    total?1496

    -rwxr-xr-x?1?root?root????2217?Aug??3?00:56?confxml.xml

    -rwxr-xr-x?1?root?root?1520176?Jul??4??2010?sersync2

    [root@acong?GNU-Linux-x86]#?vim?confxml.xml?????????##找到一下模塊

    <sersync>?????

    ?<localpath?watch="/opt/tongbu1">

    ????????????<remote?ip="172.16.3.21"?name="tongbu1"/>???????????

    ##?指定?rsyncd?服務器的地址和備份的模塊名稱

    ????????????<!--<remote?ip="192.168.8.39"?name="tongbu"/>-->

    ????????????<!--<remote?ip="192.168.8.40"?name="tongbu"/>-->

    ????????</localpath>

    ????????<rsync>

    ????????????<commonParams?params="-artuz"/>

    ????????????<auth?start="false"?users="root"?passwordfile="/etc/rsync.pas"/>

    ????????????<userDefinedPort?start="false"?port="874"/><!--?port=874?-->

    ????????????<timeout?start="false"?time="100"/><!--?timeout=100?-->

    ????????????<ssh?start="false"/>

    ????????</rsync>

    <failLog?path="/var/log/rsync_fail.log"?timeToExecute="60"/><!--default?every?60mins?execute?once--> ##也可以把log文件指定到你熟悉的位置

    [root@acong?GNU-Linux-x86]#?mkdir?/opt/tongbu1?-p 建立目錄

    [root@acong?GNU-Linux-x86]#?cd?/opt/tongbu1/

    [root@liyao?GNU-Linux-x86]#?mkdir?/etc/sersync2

    [root@liyao?GNU-Linux-x86]#?cp?confxml.xml?/etc/sersync2/

    [root@liyao?GNU-Linux-x86]#?cp?sersync2?/usr/bin/

    [root@rrd?~]#?sersync2?-r?-d?-o?/etc/sersync2/confxml.xml

    set?the?system?param

    execute???echo?50000000?>?/proc/sys/fs/inotify/max_user_watches

    execute???echo?327679?>?/proc/sys/fs/inotify/max_queued_events

    parse?the?command?param

    option:?-r??????rsync?all?the?local?files?to?the?remote?servers?before?the?sersync?work

    option:?-d??????run?as?a?daemon

    option:?-o??????config?xml?name?????/etc/sersync2/confxml.xml

    daemon?thread?num:?10

    parse?xml?config?file

    host?ip?:?localhost?????host?port:?8008

    daemon?start???sersync?run?behind?the?console?

    config?xml?parse?success

    please?set?/etc/rsyncd.conf?max?connections=0?Manually

    sersync?working?thread?12??=?1(primary?thread)?+?1(fail?retry?thread)?+?10(daemon?sub?threads)?

    Max?threads?numbers?is:?22?=?12(Thread?pool?nums)?+?10(Sub?threads)

    please?according?your?cpu????use?-n?param?to?adjust?the?cpu?rate

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

    rsync?the?directory?recursivly?to?the?remote?servers?once

    working?please?wait...

    execute?command:?cd?/opt/tongbu1?&&?rsync?-artuz?-R?--delete?./?172.16.0.26::tongbu1?>/dev/null?2>&1?

    run?the?sersync:?

    watch?path?is:?/opt/tongbu1


  • #############################?
  • 測試1:sersync端?
  • 在sersync端新建一個文件,看rsync端否同步?
  • [root@acong?tongbu1]#?touch?test.sh?
  • [root@acong?tongbu1]#?ll?
  • total?0?
  • -rw-r--r--?1?root?root?0?Aug??3?03:04?test.sh?
  • 查看下rsync端?
  • [root@acong?tongbu1]#?ll?
  • total?0?
  • -rw-r--r--?1?root?root?0?Aug??3?03:04?test.sh?
  • 結論:成功!?

  • #############################?
  • 測試2:在sersync端先刪除剛才建立的test.sh,在建立一個acong.sh?
  • [root@acong?tongbu1]#?touch?acong.sh?
  • [root@acong?tongbu1]#?ll?
  • total?0?
  • -rw-r--r--?1?root?root?0?Aug??3?03:09?acong.sh??##只有這一個文件?
  • 查看下rsync端?
  • [root@acong?tongbu1]#?ll?
  • total?0?
  • -rw-r--r--?1?root?root?0?Aug??3?03:09?acong.sh??##也是一樣的?
  • 結論:成功!?

  • #############################?
  • 測試3:在rsync端建立文件,sersync端是否能一樣呢?
  • [root@acong?tongbu1]#?touch?xiaolin?
  • [root@acong?tongbu1]#?ll?
  • total?0?
  • -rw-r--r--?1?root?root?0?Aug??3?03:09?acong.sh?
  • -rw-r--r--?1?root?root?0?Aug??3?03:11?xiaolin?
  • [root@acong?tongbu1]#?ll?
  • total?0?
  • -rw-r--r--?1?root?root?0?Aug??3?03:09?acong.sh?
  • 結論:不成功,因為畢竟不是互為同步的。?
  • #############################?
  • ?

    通過以上配置可以實現對目錄的監控,以及實時的進行增量的數據同步。

    ?

    轉載于:https://blog.51cto.com/learon/980729

    總結

    以上是生活随笔為你收集整理的Sersync+Rsync 增量实时同步的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。