首页 文件共享服务教程实时数据同步: 基于远程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

本文链接:https://www.yunweipai.com/36031.html

实时数据同步: rsync daemon 实现 sersync

实战作业:实现基于分布式的LAMP架构,并将NFS实时同步到备份服务器

网友评论comments

发表回复

您的电子邮箱地址不会被公开。

暂无评论

Copyright © 2012-2022 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部