最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

sersync實(shí)現(xiàn)數(shù)據(jù)實(shí)時(shí)同步的方法

 更新時(shí)間:2017年12月11日 16:15:35   作者:慘綠少年  
下面小編就為大家分享一篇sersync實(shí)現(xiàn)數(shù)據(jù)實(shí)時(shí)同步的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

1.1 第一個(gè)里程碑:安裝sersync軟件

1.1.1 將軟件上傳到服務(wù)器當(dāng)中并解壓

1、上傳軟件到服務(wù)器上 rz -E

為了便于管理上傳位置統(tǒng)一設(shè)置為 /server/tools 中

2、解壓軟件包

[root@backup sersync_installdir_64bit]# tree
.
└── sersync
 ├── bin
 │ └── sersync
 ├── conf
 │ └── confxml.xml
 └── logs

1.1.2 二進(jìn)制包安裝方法

二進(jìn)制包安裝軟件方法(綠色軟件安裝方法):

直接解壓就可以使用

[root@nfs01 sersync_installdir_64bit]# mv sersync/ /usr/local/
[root@nfs01 tools]# tree /usr/local/sersync/
 /usr/local/sersync/
 ├── bin
 │ └── sersync
 ├── conf
 │ └── confxml.xml
 └── logs
directories, 2 files

1.2 第二個(gè)里程碑:編寫sersync配置文件

1.2.1 常見的語法格式

rsync 配置文件編寫:ini語法

sersync配置文件編寫:xml語法

ansible配置文件編寫:yml 語法

1.2.2 修改配置文件

編寫前備份

[root@backup conf]# ll
total 4
-rw-r--r-- 1 root root 2214 Oct 26 2011 confxml.xml
[root@backup conf]# cp confxml.xml{,.bak}

6-11行表示排除同步的數(shù)據(jù),等價(jià)于 --exclude 功能,表示排除

<filter start="false">
 <exclude expression="(.*)\.svn"></exclude>
 <exclude expression="(.*)\.gz"></exclude>
 <exclude expression="^info/*"></exclude>
  <exclude expression="^static/*"></exclude>
</filter>

12-21行是利用inotify的功能監(jiān)控指定的事件,等價(jià)與 -e create,delete…… 表示指定監(jiān)控事件信息

<inotify>
 <delete start="true"/>
 <createFolder start="true"/>
 <createFile start="false"/>
 <closeWrite start="true"/>
 <moveFrom start="true"/>
 <moveTo start="true"/>
 <attrib start="false"/>
 <modify start="false"/>
 </inotify>

24-28行:推送到哪里 name=模塊 是rsync服務(wù)器的地址

 <localpath watch="/data"> #監(jiān)控那個(gè)目錄
 <remote ip="172.16.1.41" name="backup"/>
 <!--<remote ip="192.168.8.39" name="tongbu"/>-->
 <!--<remote ip="192.168.8.40" name="tongbu"/>-->
 </localpath>

29-35行 定義rsync推送時(shí)的參數(shù)信息。

注意:不要有單詞拼寫錯(cuò)誤 (true),否則程序不能正常啟動(dòng),卡死

<rsync>
 <commonParams params="-az"/>
 <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
 <userDefinedPort start="false" port="874"/><!-- port=874 -->
 <timeout start="false" time="100"/><!-- timeout=100 -->
 <ssh start="false"/>
</rsync>

配置文件最終內(nèi)容:

[root@nfs01 tools]# cat /usr/local/sersync/conf/confxml.xml 
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <head version="2.5">
 <host hostip="localhost" port="8008"></host>
 <debug start="false"/>
 <fileSystem xfs="false"/>
 <filter start="false">
 <exclude expression="(.*)\.svn"></exclude>
 <exclude expression="(.*)\.gz"></exclude>
 <exclude expression="^info/*"></exclude>
 <exclude expression="^static/*"></exclude>
 </filter>
 <inotify>
 <delete start="true"/>
 <createFolder start="true"/>
 <createFile start="false"/>
 <closeWrite start="true"/>
 <moveFrom start="true"/>
 <moveTo start="true"/>
 <attrib start="false"/>
 <modify start="false"/>
 </inotify>

 <sersync>
 <localpath watch="/data">
 <remote ip="172.16.1.41" name="nfsbackup"/>
 <!--<remote ip="192.168.8.39" name="tongbu"/>-->
 <!--<remote ip="192.168.8.40" name="tongbu"/>-->
 </localpath>
 <rsync>
 <commonParams params="-az"/>
 <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
 <userDefinedPort start="false" port="874"/><!-- port=874 -->
 <timeout start="false" time="100"/><!-- timeout=100 -->
 <ssh start="false"/>
 </rsync>
 <failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
 <crontab start="false" schedule="600"><!--600mins-->
 <crontabfilter start="false">
 <exclude expression="*.php"></exclude>
 <exclude expression="info/*"></exclude>
 </crontabfilter>
 </crontab>
 <plugin start="false" name="command"/>
 </sersync>

 <plugin name="command">
 <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
 <filter start="false">
 <include expression="(.*)\.php"/>
 <include expression="(.*)\.sh"/>
 </filter>
 </plugin>

 <plugin name="socket">
 <localpath watch="/opt/tongbu">
 <deshost ip="192.168.138.20" port="8009"/>
 </localpath>
 </plugin>
 <plugin name="refreshCDN">
 <localpath watch="/data0/htdocs/cms.xoyo.com/site/">
 <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
 <sendurl base="http://pic.xoyo.com/cms"/>
 <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
 </localpath>
 </plugin>
</head>

1.3 第三里程碑: 啟動(dòng)sersync

1.3.1 修改文件的權(quán)限(可執(zhí)行)

首先讓程序讓文件有執(zhí)行權(quán)限

[root@nfs01 bin]# chmod a+x sersync 
[root@nfs01 bin]# ll
total 1768
-rwxr-xr-x 1 root root 1810128 Oct 26 2011 sersync

1.3.2 查看軟件的幫助信息

[root@nfs01 bin]# ./sersync -h
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
_______________________________________________________
重要參數(shù)-d:啟用守護(hù)進(jìn)程模式
重要參數(shù)-r:在監(jiān)控前,將監(jiān)控目錄與遠(yuǎn)程主機(jī)用rsync命令推送一遍
 參數(shù)-n: 指定開啟守護(hù)線程的數(shù)量,默認(rèn)為10個(gè)
重要參數(shù)-o:指定配置文件,默認(rèn)使用confxml.xml文件
 參數(shù)-m:單獨(dú)啟用其他模塊,使用 -m refreshCDN 開啟刷新CDN模塊
 參數(shù)-m:單獨(dú)啟用其他模塊,使用 -m socket 開啟socket模塊
 參數(shù)-m:單獨(dú)啟用其他模塊,使用 -m http 開啟http模塊
不加-m參數(shù),則默認(rèn)執(zhí)行同步程序
________________________________________________________________

1.3.3 在程序的bin目錄下啟動(dòng)程序

./sersync -dro /usr/local/sersync/conf/confxml.xml

1.3.4 啟動(dòng)方法二

將/usr/local/sersync/bin/程序的bin目錄添加到PATH中

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/sersync/bin/

然后sersync命令就能直接使用

[root@nfs01 scripts]# sersync -dro /usr/local/sersync/conf/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: -d run as a daemon
option: -r rsync all the local files to the remote servers before the sersync work
option: -o config xml name: /usr/local/sersync/conf/confxml.xml
daemon thread num: 10
parse xml config file
host ip : localhost host port: 8008
daemon start,sersync run behind the console 
use rsync password-file :
user is rsync_backup
passwordfile is /etc/rsync.password
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 /data && rsync -az -R --delete ./ rsync_backup@172.16.1.41::nfsbackup --password-file=/etc/rsync.password >/dev/null 2>&1 
run the sersync: 
watch path is: /data

1.4 Inotify與 sersync總結(jié)對(duì)比

1.4.1 Inotify實(shí)時(shí)并發(fā):

結(jié)論:經(jīng)過測(cè)試,每秒200文件并發(fā),數(shù)據(jù)同步幾乎無延遲(小于1秒)

1.4.2 inotify 優(yōu)點(diǎn):

1)監(jiān)控文件系統(tǒng)事件變化,通過同步工具實(shí)現(xiàn)實(shí)時(shí)數(shù)據(jù)同步。

1.4.3 inotify 缺點(diǎn)

1)并發(fā)如果大于200個(gè)文件(10-100k),同步就會(huì)有延遲

2)我們前面寫的腳本,每次都是全部推送一次,但確實(shí)是增量的。也可以只同步變化的文件,不變化的不理。

3)監(jiān)控到事件后,調(diào)用rsync同步是單進(jìn)程的,而sersync為多進(jìn)程同步。既然有了inotify-tools,為什么還要開發(fā)sersync?

1.4.4 serysync功能多:(inotify+rsync命令)

1)支持通過配置文件管理

2)真正的守護(hù)進(jìn)程socket

3)可以對(duì)失敗文件定時(shí)重傳(定時(shí)任務(wù)功能)

4)第三方的HTTP接口(例如:更新cdn緩存)

5)默認(rèn)多進(jìn)程rsync同步

1.4.5 高并發(fā)數(shù)據(jù)實(shí)時(shí)同步方案小結(jié):

1)inotify(sersync)+ rsync,是文件級(jí)別的。

2)drbd文件系統(tǒng)級(jí)別,文件系統(tǒng)級(jí)別,基于block塊同步,缺點(diǎn):備節(jié)點(diǎn)數(shù)據(jù)不可用

3)第三方軟件的同步功能:mysql同步(主從復(fù)制),oracle,mongodb

4)程序雙寫,直接寫兩臺(tái)服務(wù)器。

5)利用產(chǎn)品業(yè)務(wù)邏輯解決(讀寫分離,備份讀不到,讀主)

2.1 man命令的級(jí)別

centos6

[root@nfs01 ~]# man man
 The standard sections of the manual include:
 User Commands     #用戶命令
 System Calls     #系統(tǒng)調(diào)用
 C Library Functions    # Ç庫(kù)函數(shù)
 Devices and Special Files   #設(shè)備和特殊文件
 File Formats and Conventions  #文件格式和約定
 Games et. Al.     #游戲等。
 Miscellanea     #雜記
 System Administration tools and Daemons #系統(tǒng)管理工具和程序

 Distributions customize the manual section to their specifics,
 which often include additional sections.

centos7

[root@clsn tuichu]# man ~
 Executable programs or shell commands
 System calls (functions provided by the kernel)
 Library calls (functions within program libraries)
 Special files (usually found in /dev)
 File formats and conventions eg /etc/passwd
 Games
 Miscellaneous (including macro packages and conventions), e.g.
 man(7), groff(7)
 System administration commands (usually only for root)
 Kernel routines [Non standard]

以上這篇sersync實(shí)現(xiàn)數(shù)據(jù)實(shí)時(shí)同步的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 詳解Ubuntu 從零開始搭建Python開發(fā)環(huán)境

    詳解Ubuntu 從零開始搭建Python開發(fā)環(huán)境

    本篇文章主要介紹了詳解Ubuntu 從零開始搭建Python開發(fā)環(huán)境,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-06-06
  • Apache和Tomcat有什么區(qū)別_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    Apache和Tomcat有什么區(qū)別_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    Apache 和 Tomcat 都是web網(wǎng)絡(luò)服務(wù)器,兩者既有聯(lián)系又有區(qū)別。下面通過本文給大家介紹Apache和Tomcat的區(qū)別,感興趣的朋友一起看看吧
    2017-08-08
  • Linux文件操作高頻使用命令小結(jié)

    Linux文件操作高頻使用命令小結(jié)

    這篇文章主要介紹了Linux文件操作高頻使用命令小結(jié),本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-11-11
  • Xshell連接本地Linux虛擬機(jī)方式

    Xshell連接本地Linux虛擬機(jī)方式

    這篇文章主要介紹了Xshell連接本地Linux虛擬機(jī)方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • 淺談Linux的零拷貝技術(shù)

    淺談Linux的零拷貝技術(shù)

    零拷貝主要的任務(wù)就是避免CPU將數(shù)據(jù)從一塊存儲(chǔ)拷貝到另外一塊存儲(chǔ),主要就是利用各種零拷貝技術(shù),避免讓CPU做大量的數(shù)據(jù)拷貝任務(wù),減少不必要的拷貝,需要的朋友可以參考下
    2023-04-04
  • 初窺Linux 之我最常用的20條命令總結(jié)

    初窺Linux 之我最常用的20條命令總結(jié)

    Linux中的命令的確是非常多,我們只需要了解常用的命令就可以了,本篇文章介紹了Linux 之我最常用的20條命令總結(jié),有興趣的可以了解一下。
    2016-12-12
  • apache開啟.htaccess及.htaccess的使用方法

    apache開啟.htaccess及.htaccess的使用方法

    今天本地調(diào)試PHP程序,用到了.htaccess,而默認(rèn)配置里面開啟.htaccess,在網(wǎng)上找到了開啟.htaccess的可行方法,供朋友們借鑒。
    2010-12-12
  • centos7 esxi6.7模板實(shí)際應(yīng)用詳解

    centos7 esxi6.7模板實(shí)際應(yīng)用詳解

    這篇文章主要介紹了centos7 esxi6.7模板實(shí)際應(yīng)用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • linux備份與恢復(fù)基礎(chǔ)知識(shí)

    linux備份與恢復(fù)基礎(chǔ)知識(shí)

    備份會(huì)改變atime,tar,cpio,dd都會(huì)這樣做,dump通過原始設(shè)備來讀取文件系統(tǒng),因此它不會(huì)改變atime.
    2009-03-03
  • linux php-cgi.exe占用cpu 100%的一次排障之旅

    linux php-cgi.exe占用cpu 100%的一次排障之旅

    這篇文章主要介紹了linux php-cgi.exe占用cpu 100%的一次排障之旅,需要的朋友可以參考下
    2016-09-09

最新評(píng)論

岳西县| 手游| 理塘县| 施秉县| 宜兰县| 皮山县| 靖安县| 万盛区| 铁力市| 龙口市| 五莲县| 凤山市| 洛浦县| 白沙| 惠来县| 探索| 安国市| 嘉峪关市| 玛纳斯县| 库车县| 同仁县| 巴中市| 沾化县| 舟曲县| 叶城县| 江口县| 许昌县| 秦皇岛市| 壶关县| 观塘区| 偃师市| 贵溪市| 克拉玛依市| 香河县| 阿坝县| 三门县| 左贡县| 乌拉特前旗| 疏附县| 怀宁县| 汉源县|