国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

云服務器|WEB服務器|FTP服務器|郵件服務器|虛擬主機|服務器安全|DNS服務器|服務器知識|Nginx|IIS|Tomcat|

服務器之家 - 服務器技術 - 服務器知識 - sersync實現數據實時同步的方法

sersync實現數據實時同步的方法

2022-02-23 16:44慘綠少年 服務器知識

下面小編就為大家分享一篇sersync實現數據實時同步的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

1.1 第一個里程碑:安裝sersync軟件

1.1.1 將軟件上傳到服務器當中并解壓

1、上傳軟件到服務器上 rz -E

為了便于管理上傳位置統一設置為 /server/tools 中

2、解壓軟件包

?
1
2
3
4
5
6
7
8
[root@backup sersync_installdir_64bit]# tree
.
└── sersync
 ├── bin
 │ └── sersync
 ├── conf
 │ └── confxml.xml
 └── logs

1.1.2 二進制包安裝方法

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

直接解壓就可以使用

?
1
2
3
4
5
6
7
8
9
[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 第二個里程碑:編寫sersync配置文件

1.2.1 常見的語法格式

rsync 配置文件編寫:ini語法

sersync配置文件編寫:xml語法

ansible配置文件編寫:yml 語法

1.2.2 修改配置文件

編寫前備份

?
1
2
3
4
[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行表示排除同步的數據,等價于 --exclude 功能,表示排除

?
1
2
3
4
5
6
<filter start="false">
 <exclude expression="(.*)\.svn"></exclude>
 <exclude expression="(.*)\.gz"></exclude>
 <exclude expression="^info/*"></exclude>
  <exclude expression="^static/*"></exclude>
</filter>

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

?
1
2
3
4
5
6
7
8
9
10
<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服務器的地址

?
1
2
3
4
5
<localpath watch="/data"> #監控那個目錄
<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推送時的參數信息。

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

?
1
2
3
4
5
6
7
<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>

配置文件最終內容:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[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 第三里程碑: 啟動sersync

1.3.1 修改文件的權限(可執行)

首先讓程序讓文件有執行權限

?
1
2
3
4
[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 查看軟件的幫助信息

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[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
_______________________________________________________
重要參數-d:啟用守護進程模式
重要參數-r:在監控前,將監控目錄與遠程主機用rsync命令推送一遍
 參數-n: 指定開啟守護線程的數量,默認為10個
重要參數-o:指定配置文件,默認使用confxml.xml文件
 參數-m:單獨啟用其他模塊,使用 -m refreshCDN 開啟刷新CDN模塊
 參數-m:單獨啟用其他模塊,使用 -m socket 開啟socket模塊
 參數-m:單獨啟用其他模塊,使用 -m http 開啟http模塊
不加-m參數,則默認執行同步程序
________________________________________________________________

1.3.3 在程序的bin目錄下啟動程序

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

1.3.4 啟動方法二

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

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

然后sersync命令就能直接使用

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[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總結對比

1.4.1 Inotify實時并發:

結論:經過測試,每秒200文件并發,數據同步幾乎無延遲(小于1秒)

1.4.2 inotify 優點:

1)監控文件系統事件變化,通過同步工具實現實時數據同步。

1.4.3 inotify 缺點

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

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

3)監控到事件后,調用rsync同步是單進程的,而sersync為多進程同步。既然有了inotify-tools,為什么還要開發sersync?

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

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

2)真正的守護進程socket

3)可以對失敗文件定時重傳(定時任務功能)

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

5)默認多進程rsync同步

1.4.5 高并發數據實時同步方案小結:

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

2)drbd文件系統級別,文件系統級別,基于block塊同步,缺點:備節點數據不可用

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

4)程序雙寫,直接寫兩臺服務器。

5)利用產品業務邏輯解決(讀寫分離,備份讀不到,讀主)

sersync實現數據實時同步的方法

2.1 man命令的級別

centos6

?
1
2
3
4
5
6
7
8
9
10
11
12
13
[root@nfs01 ~]# man man
 The standard sections of the manual include:
 User Commands     #用戶命令
 System Calls     #系統調用
 C Library Functions    # Ç庫函數
 Devices and Special Files   #設備和特殊文件
 File Formats and Conventions  #文件格式和約定
 Games et. Al.     #游戲等。
 Miscellanea     #雜記
 System Administration tools and Daemons #系統管理工具和程序
 
 Distributions customize the manual section to their specifics,
 which often include additional sections.

centos7

?
1
2
3
4
5
6
7
8
9
10
11
[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實現數據實時同步的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持服務器之家。

原文鏈接:http://www.cnblogs.com/clsn/p/7707828.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 四虎永久免费影院 | 超级碰在线观看 | 亚洲 综合 清纯 丝袜 自拍 | 久久av一区 | 国产精品久久久久久久久久免费动 | 欧美午夜一区二区三区免费大片 | 国产一区二区三区免费看 | 久草视频网 | 国产精品亚洲一区 | 欧美一级片aaa | 一区二区在线 | 久久久国际精品 | 精品国产成人在线 | 最新高清无码专区 | 亚洲综合自拍 | 在线日韩成人 | 在线观看免费黄视频 | 蜜桃成人在线 | 亚洲激情在线观看 | av免费网站在线观看 | 爆操av | 一级黄色片网站 | 91.成人天堂一区 | 日韩欧美久久 | 久久精品一区二区国产 | 日本不卡一区二区 | 一区二区三区免费在线 | 99久久免费精品国产男女性高好 | 国产欧美精品一区二区三区 | 午夜精品久久久久 | 一区二区三区影视 | 亚洲精品乱码久久久久久金桔影视 | 欧美狠狠操 | 国产综合久久久 | 亚洲综合色视频在线观看 | 国产成人精品久久二区二区 | 亚洲2020天天堂在线观看 | 日韩电影免费在线观看中文字幕 | 亚洲精品乱码久久久久膏 | 日韩第一区| 色678黄网站全部免费 |