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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

rsync+sersync大数据T级以上进行同步方法

發(fā)布時(shí)間:2025/3/17 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 rsync+sersync大数据T级以上进行同步方法 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

操作系統(tǒng):rhel 5.7

rsync地址: http://rsync.samba.org/download.html

serync下載地址:https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz

這次的實(shí)驗(yàn)主要有兩臺(tái)機(jī)器,172.16.54.114和172.16.54.115,我們把115做為源服務(wù)器,114做為目標(biāo)服務(wù)器

主要是把115上/home/md中的所有數(shù)據(jù)實(shí)時(shí)同步到114上的/home/md中

1,先關(guān)閉防火墻

vi /etc/selinux/config #編輯防火墻配置文件

#SELINUX=enforcing #注釋掉

#SELINUXTYPE=targeted #注釋掉

SELINUX=disabled #增加

:wq! #保存,退出

setenforce 0 #立即生效

?

2,查看端口是否被占用(直接在命令行輸入)及安裝

netstat –apn | grep 873

?

安裝rsync,在兩臺(tái)服務(wù)器上都要進(jìn)行這個(gè)步驟

首先將下載的包解壓

tar -xzvf ?rsync-3.1.0.tar.gz

解壓后進(jìn)入目錄

./configure --prefix=/usr/local/rsync

?

#說(shuō)明安裝在/usr/local/rsync目錄中

在這一步之前要安裝相對(duì)就的gcc和gcc-c++

make

make install

安裝完畢

?

chkconfig rsync on #隨系統(tǒng)啟動(dòng)

這個(gè)只在114上做

創(chuàng)建rsync配置文件rsync.conf

vi /etc/rsyncd.conf #創(chuàng)建配置文件,添加以下代碼

log file = /var/log/rsyncd.log #日志文件位置,啟動(dòng)rsync后自動(dòng)產(chǎn)生這個(gè)文件,無(wú)需提前創(chuàng)建

pidfile = /var/run/rsyncd.pid? #pid文件的存放位置

lock file = /var/run/rsync.lock? #支持max connections參數(shù)的鎖文件

secrets file = /etc/rsync.pass? #用戶認(rèn)證配置文件,里面保存用戶名稱(chēng)和密碼,后面會(huì)創(chuàng)建這個(gè)文件

motd file = /etc/rsyncd.Motd? #rsync啟動(dòng)時(shí)歡迎信息頁(yè)面文件位置(文件內(nèi)容自定義)

[md] #自定義名稱(chēng)

path = /home/md/ #rsync服務(wù)端數(shù)據(jù)目錄路徑

comment = md #模塊名稱(chēng)

uid = root #設(shè)置rsync運(yùn)行權(quán)限為root

gid = root #設(shè)置rsync運(yùn)行權(quán)限為root

port=873? #默認(rèn)端口

use chroot = no #默認(rèn)為true,修改為no,增加對(duì)目錄文件軟連接的備份

read only = no? #設(shè)置rsync服務(wù)端文件為讀寫(xiě)權(quán)限

list = no #不顯示rsync服務(wù)端資源列表

max connections = 200 #最大連接數(shù)

timeout = 600? #設(shè)置超時(shí)時(shí)間

auth users = md #執(zhí)行數(shù)據(jù)同步的用戶名,可以設(shè)置多個(gè),用英文狀態(tài)下逗號(hào)隔開(kāi)

hosts allow = 172.16.54.114? #允許進(jìn)行數(shù)據(jù)同步的客戶端IP地址,可以設(shè)置多個(gè),用英文狀態(tài)下逗號(hào)隔開(kāi)

#hosts deny = 218.234.1.254 #禁止數(shù)據(jù)同步的客戶端IP地址,可以設(shè)置多個(gè),用英文狀態(tài)下逗號(hào)隔開(kāi)(這個(gè)比較隨便,也可以沒(méi)有)

:wq!? #保存,退出

?

創(chuàng)建用戶認(rèn)證文件

vi /etc/rsync.scrt? #配置文件,添加以下內(nèi)容

md:123456 #格式為 用戶:密碼,如果是多個(gè),可以一行一個(gè)

:wq!? #保存,退出

chmod 600 /etc/rsyncd.conf? #設(shè)置文件所有者讀取、寫(xiě)入權(quán)限

chmod 600 /etc/rsync.scrt? #設(shè)置文件所有者讀取、寫(xiě)入權(quán)限

?

在此,我們普及一個(gè)問(wèn)題,我們先進(jìn)入/etc/xinetd.d文件中,可以看到rsync這個(gè)文件,說(shuō)明rsync是由xinetd管理,可以通過(guò)xinetd來(lái)啟動(dòng)rsync

/etc/init.d/xinetd start? #啟動(dòng)

service xinetd stop?? #停止

service xinetd restart #重新啟動(dòng)

------------------------只在114上進(jìn)行的到此為止--------------------

?

以下只到115上進(jìn)行

vi /etc/rsync.scrt? #編輯文件,添加以下內(nèi)容

123456 #密碼

:wq! #保存退出

chmod 600 /etc/passwd.txt #設(shè)置文件權(quán)限,只設(shè)置文件所有者具有讀取、寫(xiě)入權(quán)限即可

4,安裝sersync

上傳sersync2.5.4_64bit_binary_stable_final.tar.gz到/usr/local目錄下

cd /usr/local

tar –xzvf? sersync2.5.4_64bit_binary_stable_final.tar.gz

這個(gè)解壓后會(huì)得到一個(gè)GUN-linux x86的文件夾

mv G GUN-linux x86/*?? /usr/local/sersync

cd? /usr/local/sersync #進(jìn)入sersync安裝目錄

cp confxml.xml confxml.xml-bak? #備份原文件

vi 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="/home/md/">

<remote ip="172.16.54.114" name="buspos "/>

</localpath>

<rsync>

<commonParams params="-artuz"/>

<auth start="true" users="buspos" passwordfile="/etc/rsyncd.scrt"/>

<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="true" 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>

#標(biāo)紅的可按自己的配置改,名字和IP比較隨便,是我的配置,紅色#的還得根據(jù)自己rsync配置進(jìn)行修改

?

?

5、設(shè)置sersync監(jiān)控開(kāi)機(jī)自動(dòng)執(zhí)行

vi /etc/rc.d/rc.local? #編輯,在最后添加一行

/usr/local/sersync/sersync2 -d -r -o ?/usr/local/sersync/confxml.xml? #設(shè)置開(kāi)機(jī)自動(dòng)運(yùn)行腳本

:wq!? #保存退出

?

寫(xiě)完后,首先對(duì)數(shù)據(jù)進(jìn)行一次整體同步

cd /usr/local/sersync

./sersync2 –r? #以下是輸入之后看到的

set the system param

execute錛歟cho 50000000 > /proc/sys/fs/inotify/max_user_watches

execute錛歟cho 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

daemon thread num: 10

parse xml config file

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

Start the crontab?????? Every 600 minutes rsync all the files to the remote servers entirely

use rsync password-file :

user is buspos

passwordfile is???????? /etc/rsyncd.scrt

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 錛寀se -n param to adjust the cpu rate

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

rsync the directory recursivly to the remote servers once

working please wait...

execute command: cd /home/md && rsync -artuz -R --delete ./ buspos@172.16.54.114::buspos --password-file=/etc/rsyncd.scrt >/dev/null 2>&1

run the sersync:

watch path is: /home/md

--------------------------------到此為止-----------------------------

?

我們來(lái)寫(xiě)個(gè)簡(jiǎn)單的腳本吧

vi? /home/sh/sersync.sh

#!/bin/sh

sersync="/usr/local/sersync/sersync2"

confxml="/usr/local/sersync/confxml.xml"

status=$(ps aux |grep 'sersync2'|grep -v 'grep'|wc -l)

if [ $status -eq 0 ];

then

$sersync -d -r -o $confxml &

else

exit 0;

fi

:wq??? #保存腳本

?

vi /etc/crontab #編輯,在最后添加下面一行

*/5 * * * * root /home/sh/sersync.sh > /dev/null 2>&1 ?#每隔5分鐘執(zhí)行一次腳本

service crond reload ?#重新加載服務(wù)

至此就不再管了,加入工作例程了!

?

?

?

轉(zhuǎn)載于:https://my.oschina.net/u/1013648/blog/207600

總結(jié)

以上是生活随笔為你收集整理的rsync+sersync大数据T级以上进行同步方法的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。