服务器文件同步机制配置(rsync Sersync)

news2024/9/28 13:25:03

参考文章链接:http://static.kancloud.cn/curder/linux/78148

在上述参考文章中,对与主从同步部署过程做了详细的操作解释,但对于三台服务器如何互相同步(即三个都是master),本文针对三台master相互同步进行配置。

1. 实现思想

三台服务器均为master,手写设定master1可以同步到master2和master3,然后设定master2和master3分别往master1同步,以此成功实现三台服务器同步机制。
在这里插入图片描述

2. 配置步骤

直接参考2.3.3 master上配置rsync客户端部分,分别为三台服务器配置,配置文件参考2.3.1.2 部署rsync服务 (Slave服务器上相关操作)
注意,参考文章中的slave和master节点密码文件不一致,master是rsync.password,slave是 rsyncd.password,最好统一使用rsync.password。

2.1 三个master的rsyncd.conf文件

  • 三个master节点ip

    • master1 : 192.168.0.196
    • master2 : 192.168.0.143
    • master3 : 192.168.0.150
  • 以下是我的Master1配置文件

# Minimal configuration file for rsync daemon
#See rsync(1) and rsyncd.conf(5) man pages for help
# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root                         
gid = root                                  
use chroot = no
read only = false
#limit access to private LANs
# 192.168.0.143———master2的IP,192.168.0.150 ——master3的ip
hosts allow=192.168.0.143/24,192.168.0.150/24
hosts deny=*
ignore errors
max connections = 2000
pid file = /var/run/rsyncd.pid
auth users = rsync_backup
secrets file = /etc/rsyncd.password
#lock file = /var/run/rsync.lock
motd file = /etc/rsyncd/rsyncd.motd
#This will give you a separate log file
log file = /data/log/rsync.log
#This will log every file transferred - up to 85,000+ per user, per sync
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
# MODULE OPTIONS
[master1]  /当前节点名称
comment = synchronize data
# /data/ouna/upload/firmware同步的文件路径
path = /data/ouna/upload/firmware
  • 以下是我的Master2配置文件
# Minimal configuration file for rsync daemon
#See rsync(1) and rsyncd.conf(5) man pages for help
# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root                         
gid = root                                  
use chroot = no
read only = false
#limit access to private LANs
# 192.168.0.196———master1的IP
hosts allow=192.168.0.196/24
hosts deny=*
ignore errors
max connections = 2000
pid file = /var/run/rsyncd.pid
auth users = rsync_backup
secrets file = /etc/rsyncd.password
#lock file = /var/run/rsync.lock
motd file = /etc/rsyncd/rsyncd.motd
#This will give you a separate log file
log file = /data/log/rsync.log
#This will log every file transferred - up to 85,000+ per user, per sync
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
# MODULE OPTIONS
[master2]  /当前节点名称
comment = synchronize data
# /data/ouna/upload/firmware同步的文件路径
path = /data/ouna/upload/firmware
  • 以下是我的Master3配置文件
# Minimal configuration file for rsync daemon
#See rsync(1) and rsyncd.conf(5) man pages for help
# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root                         
gid = root                                  
use chroot = no
read only = false
#limit access to private LANs
# 192.168.0.196———master1的IP
hosts allow=192.168.0.196/24
hosts deny=*
ignore errors
max connections = 2000
pid file = /var/run/rsyncd.pid
auth users = rsync_backup
secrets file = /etc/rsyncd.password
#lock file = /var/run/rsync.lock
motd file = /etc/rsyncd/rsyncd.motd
#This will give you a separate log file
log file = /data/log/rsync.log
#This will log every file transferred - up to 85,000+ per user, per sync
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
# MODULE OPTIONS
[master3]  /当前节点名称
comment = synchronize data
# /data/ouna/upload/firmware同步的文件路径
path = /data/ouna/upload/firmware

2.2 三台master的sersync配置文件 confxml.xml

主要修改的地方
在这里插入图片描述

sersync阿里云资源:https://www.aliyundrive.com/s/Cpy6z2KigKm

  • master1 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/ouna/upload/firmware">
			<!-- master2的ip master2名称-->
    		<remote ip="192.168.0.143" name="master2"/>
			<!-- master3的ip master3名称-->
    		<remote ip="192.168.0.150" name="master3"/>
    	</localpath>
   
    	<rsync>
    	    <commonParams params="-artuz"/>
			<!-- rsync.password密码授权,如果你创建的是rsyncd.password,则用rsyncd.password-->
    	    <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
    	    <userDefinedPort start="false" port="873"/><!-- port=873 -->
    	    <timeout start="true" time="100"/><!-- timeout=100 -->
    	    <ssh start="false"/>
    	</rsync>
    	<failLog path="/usr/local/sersync/logs/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>
  • master2的配置文件 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/ouna/upload/firmware">
			<!-- master1的ip master1名称-->
    		<remote ip="192.168.0.196" name="master1"/>
    	</localpath>
   
    	<rsync>
    	    <commonParams params="-artuz"/>
			<!-- rsync.password密码授权,如果你创建的是rsyncd.password,则用rsyncd.password-->
    	    <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
    	    <userDefinedPort start="false" port="873"/><!-- port=873 -->
    	    <timeout start="true" time="100"/><!-- timeout=100 -->
    	    <ssh start="false"/>
    	</rsync>
    	<failLog path="/usr/local/sersync/logs/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>
  • master3配置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/ouna/upload/firmware">
			<!-- master1的ip master1名称-->
    		<remote ip="192.168.0.196" name="master1"/>
    	</localpath>
   
    	<rsync>
    	    <commonParams params="-artuz"/>
			<!-- rsync.password密码授权,如果你创建的是rsyncd.password,则用rsyncd.password-->
    	    <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
    	    <userDefinedPort start="false" port="873"/><!-- port=873 -->
    	    <timeout start="true" time="100"/><!-- timeout=100 -->
    	    <ssh start="false"/>
    	</rsync>
    	<failLog path="/usr/local/sersync/logs/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>

3. 修改完成后,启动即可,

sersync -r -d -o /usr/local/sersync/conf/confxml.xml

其他详细的信息可以参考本文开头链接文章,本文不在进行详细叙述。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/637139.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

一文读懂redis持久化机制

持久化官网相关参考资料 https://redis.io/docs/manual/persistence/ 持久化就是把redis内存里面保存的数据保存磁盘中&#xff0c;在redis重启或者能够使得数据不会丢失。目前常用的持久化方式有&#xff1a;RDB方式、AOF方式以及RDB AOF两种方式 RDB持久化方式 所谓的RDB…

实现无间断的自动化:Jenkins与GitLab的定时任务工作流程

简介&#xff1a; Jenkins是一个流行的开源自动化服务器&#xff0c;而GitLab是一个强大的代码托管和协作平台。通过结合Jenkins和GitLab&#xff0c;我们可以建立一个强大的定时任务自动化工作流程&#xff0c;实现代码拉取、构建、测试和部署的自动化。本篇博客将介绍如何使…

大屏数据可视化开源项目

一、DataGear —— 数据可视化项目 官网&#xff1a;DataGear - 开源免费的数据可视化分析平台 DataGear 是一款开源免费的数据可视化分析平台&#xff0c;数据可视化看板。 功能特性&#xff1a; 1、多种数据源&#xff0c;支持运行时接入任意提供 JDBC 驱动的数据库&#…

Web网页端IM产品RainbowChat-Web的v5.0版已发布

一、关于RainbowChat-Web RainbowChat-Web是一套Web网页端IM系统&#xff0c;是RainbowChat的姊妹系统&#xff08;RainbowChat是一套基于开源IM聊天框架 MobileIMSDK(Github地址) 的产品级移动端IM系统&#xff09;。 ► 详细介绍&#xff1a;http://www.52im.net/thread-248…

Python的pip install安装路径修改

背景 当我们在安装python的依赖包的时候&#xff0c;不知道默认安装在什么位置&#xff0c;或者不想安装在默认的位置&#xff0c;这时候我们可以手动修改pip install的安装位置。 1.打开cmd窗口, 执行python -m site 输入 python -m site 这个命令可以看到目前的USER_BASE和…

HarmonyOS ArkTS Ability内页面的跳转和数据传递

HarmonyOS ArkTS Ability的数据传递包括有Ability内页面的跳转和数据传递、Ability间的数据跳转和数据传递。本节主要讲解Ability内页面的跳转和数据传递。 打开DevEco Studio&#xff0c;选择一个Empty Ability工程模板&#xff0c;创建一个名为“ArkUIPagesRouter”的工程为…

亚马逊美国站 CPC认证-儿童毛绒玩具产品 毛绒玩具的作用

毛绒玩具等毛绒东西&#xff0c;其实能给孩子带来愉快和安全感&#xff0c;接触舒适&#xff0c;是儿童依恋的重要部分。我们常常能见到一些孩子晚上睡觉前一定要搂着毛绒玩具、或者一定要盖着毛绒毯子才能睡&#xff0c;丢掉了毛绒玩具&#xff0c;或者盖了其他布质的被子就会…

vue时间组件重置

<el-form-item label"注册日期" label-width"210px"><el-date-picker clearablev-model"registerTime"type"daterange"range-separator"至"value-format"yyyy-MM-dd"start-placeholder"开始日期&qu…

[论文笔记] Atos: A Task-Parallel GPU Scheduler for Graph Analytics

Atos: A Task-Parallel GPU Scheduler for Graph Analytics Atos: 用于图分析的任务并行 GPU 调度程序 [Paper] [Slides] ICPP’22 摘要 提出了 Atos, 一个特别针对动态不规则应用的任务并行 GPU 动态调度框架. 支持消除依赖关系的应用的任务并行公式来暴露额外的并发性除了…

MacBook苹果笔记本电脑卡顿怎么解决?

MacBook使用时间久了之后很容易出现卡顿的问题。那么出现卡顿的原因有哪些呢&#xff1f;MacBook卡顿怎么处理呢&#xff1f;下面为大家介绍几种可能的解决方案。虽然mac系统相对来说比较稳定&#xff0c;但遇到软件崩溃的情况也会突然卡顿而无法使用。那么&#xff0c;遇上mac…

C#运行程序修改数据后数据表不做更新【已解决】

前言 近日&#xff0c;在使用C#连接数据库的时候&#xff0c;对数据库中的表做更新后&#xff0c;在当前启动项目中去显示表数据时虽然会发生一个更新&#xff0c;但是在结束程序运行后再去观察数据表中的记录时发现并没有发生一个变化&#xff0c;在重复尝试了好几次后还是同样…

【Linux】中不小心误卸载了rpm命令如何恢复?

&#x1f341;博主简介 &#x1f3c5;云计算领域优质创作者   &#x1f3c5;华为云开发者社区专家博主   &#x1f3c5;阿里云开发者社区专家博主 &#x1f48a;交流社区&#xff1a;运维交流社区 欢迎大家的加入&#xff01; 文章目录 问题复现问题解决方案补全 whereis r…

Mac电脑把位图转换成矢量图的软件

Super Vectorizer for Mac是一款强大的位图转换工具&#xff0c;运行在Mac OS平台&#xff0c;可以轻松将数位图转换为矢量图。 矢量图以其放大后图像不会失真的优点&#xff0c;在社会各处的使用范围越来越广&#xff0c;但是网络上找到的图片又往往是数位图&#xff0c;这时…

【APP Debug抓包工具】Stream - Network Debug Tool

【APP Debug工具】 Stream - Network Debug Tool

Flutter进阶篇-Local Key和Global Key

简介: key是widget、element和semanticsNode的唯一标识&#xff0c;同一个parent下的所有element的key不能重复&#xff0c;但是在特定条件下可以在不同parent下使用相同的key&#xff0c;比如page1和page2都可以使用ValueKey(1) 。 常用key的UML关系图如上&#xff0c;整体上…

阿里云安装2019版sql server服务

1、添加 Microsoft 的 yum 存储库 [rootiZ22312ginudnbnifn438Z ~]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo 这里地址一定要选择https://packages.microsoft.com/config/rhel/7/mssql-server-2019…

华为OD机试真题 JavaScript 实现【记票统计】【牛客练习题】

一、题目描述 请实现一个计票统计系统。你会收到很多投票&#xff0c;其中有合法的也有不合法的&#xff0c;请统计每个候选人得票的数量以及不合法的票数。 &#xff08;注&#xff1a;不合法的投票指的是投票的名字不存在n个候选人的名字中&#xff01;&#xff01;&#x…

JavaScript DOM

1、DOM介绍 DOM(Document Object Model)&#xff1a;文档对象模型。 将 HTML 文档的各个组成部分&#xff0c;封装为对象。借助这些对象&#xff0c;可以对 HTML 文档进行增删改查的动态操作。 1.1、Element元素的获取操作 具体方法 方法名说明getElementById (id 属性值)根…

原因分析必知必会的十大要点

原因分析是对选定的现象进行全面深入的研究&#xff0c;找到现象背后的真正原因与深层次原因&#xff0c;然后采取合适的措施纠正问题、预防问题。如果没有找到真正的根因就采取措施&#xff0c;往往事倍功半&#xff0c;浪费了投入。那么在原因分析时&#xff0c;有哪些成功要…

adb 导入导出安卓设备里面的apk和文件

安卓设备上导出apk到电脑 &#xff1a; 第一条指令查&#xff1a;adb shell pm list package -3 //列出所有非系统三方应用如下 package:com.sangfor.vpn.client.phonepackage:com.spd.mdm.other.funcpackage:com.supcon.supplant第二条指令查路径&#xff1a;adb shell pm pa…