首頁 文件共享服務教程實時數據同步: 基于遠程shell 實現 sersync

實時數據同步: rsync daemon 實現 sersync

實戰作業:實現基于分布式的LAMP架構,并將NFS實時同步到備份服務器

運維派隸屬馬哥教育旗下專業運維社區,是國內成立最早的IT運維技術社區,歡迎關注公眾號:yunweipai
領取學習更多免費Linux云計算、Python、Docker、K8s教程關注公眾號:馬哥linux運維

基于遠程shell 實現 sersync
#不需要配置rsync daemon,只需要配置基于key驗證的ssh即可
[root@data-centos8 ~]#ssh-keygen 
[root@data-centos8 ~]#ssh-copy-id backup-server

#下載sersync,并拷貝至相應的目錄,設置PATH變量同5.5.2

#修改sersync配置文件
[root@data-centos8 ~]#cat  /usr/local/sersync/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="true"/>  #修改此行為true
    <modify start="false"/>
    </inotify>

    <sersync>
    <localpath watch="/data/www"> #修改此行,指定源數據目錄
        <remote ip="備份服務器IP" name="/data/backup"/> #修改此行指定備份服務器地址和備份目標目錄
        <!--<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="true"/> #修改此行為true,使用遠程shell方式的rsync連接方式,無需在目標主機上配置啟動rsync daemon服務

#####################################以下行不需要修改####################################
    </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>
#將中間的行可以刪除
</head>

[root@data-centos8 ~]#sersync2 -dro /usr/local/sersync/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:  /apps/sersync/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 /data/www && rsync -auz -R --delete ./  -e ssh 10.0.0.18:/data/backup >/dev/null 2>&1 
run the sersync: 
watch path is: /data/www

本文鏈接:http://www.thecarconnectin.com/36031.html

實時數據同步: rsync daemon 實現 sersync

實戰作業:實現基于分布式的LAMP架構,并將NFS實時同步到備份服務器

網友評論comments

發表回復

您的電子郵箱地址不會被公開。

暫無評論

Copyright ? 2012-2022 YUNWEIPAI.COM - 運維派 京ICP備16064699號-6
掃二維碼
掃二維碼
返回頂部
国产曰批视频免费观看完|久久久一本精品99久久精品66直播|色天使色偷偷AV一区二区三区|国产色秀视频在线播放|亚洲欧洲免费三级网站