seRsync + Rsync 实时同步

news2024/10/4 18:53:03

文章目录

  • 1,结构图
  • 2,节点A
    • 2.1 安装rsync
    • 2.2 安装seRsync
    • 2.3, 创建seRsync的守护进程用systemd管理并启动
    • 2.4,上传rsync.pass密码文件到配置文件目录:/etc/
    • 2.5 ,重新加载systemd,启动sersyncd守护进程并配置开机自启
  • 3,节点B
    • 3.1 ,安装Rsync
    • 3.2创建Rsync配置文件`rsyncd.conf`、密码文件`rsync.pass`到配置文件目录:`/etc/`
    • 3.3,启动Rsyncd
    • 3.4, 安装seRsync
    • 3.5 创建seRsync的守护进程用systemd管理并启动
    • 上传sersyncd4tomcat.service和sersyncd4www.service到systemd配置文件路径:`/usr/lib/systemd/system/`
  • 4,节点C
    • 4.1 安装Rsync
    • 4.2、配置Rsync
    • 4.3、启动Rsync

1,结构图

在这里插入图片描述

2,节点A

2.1 安装rsync

yum install -y rsync

2.2 安装seRsync

下载这个压缩包sersync2.5.4_64bit_binary_stable_final.tar.gz
解压后,将sersync2复制到系统可执行程序路径:/usr/local/bin/;创建sersync配置目录,并在里面创建配置文件tomcat.xml 和www.xml并写入数据

tar -xvzf sersync2.5.4_64bit_binary_stable_final.tar.gz
cp ./GNU-Linux-x86/sersync2 /usr/local/bin/
mkdir /etc/sersync
vim /etc/sersync/tomcat.xml
vim /etc/sersync/www.xml
  • tomcat.xml具体内容
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="true"/>
    <fileSystem xfs="false"/>
    <filter start="true">
    <exclude expression="^logs/*"></exclude>
    <exclude expression="^webapps/pcPublish/*"></exclude>
    </filter>
    <inotify>
    <delete start="true"/>
    <createFolder start="true"/>
    <createFile start="true"/>
    <closeWrite start="true"/>
    <moveFrom start="true"/>
    <moveTo start="true"/>
    <attrib start="false"/>
    <modify start="false"/>
    </inotify>


    <sersync>
    <localpath watch="/vdb/eastmoney/apache-tomcat-8.5.27/">
        <remote ip="10.195.24.97" name="tomcat"/>
        <!--<remote ip="192.168.8.39" name="tongbu"/>-->
        <!--<remote ip="192.168.8.40" name="tongbu"/>-->
    </localpath>
    <rsync>
        <commonParams params="-artuz"/>
        <auth start="true" users="rsync" passwordfile="/etc/rsync.pass"/>
        <userDefinedPort start="false" port="873"/><!-- 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="720"><!--600mins-->
        <crontabfilter start="true">
            <exclude expression="^logs/*"></exclude>
            <exclude expression="^webapps/pcPublish/*"></exclude>
        </crontabfilter>
    </crontab>
    <plugin start="false" name="command"/>
    </sersync>
</head>

-www.xml具体内容

<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="true"/>
    <fileSystem xfs="false"/>
    <filter start="true">
    <exclude expression="^load-control.html*"></exclude>
    </filter>
    <inotify>
    <delete start="true"/>
    <createFolder start="true"/>
    <createFile start="true"/>
    <closeWrite start="true"/>
    <moveFrom start="true"/>
    <moveTo start="true"/>
    <attrib start="false"/>
    <modify start="false"/>
    </inotify>


    <sersync>
    <localpath watch="/vdb/eastmoney/data0/htdocs/www/">
        <remote ip="10.195.24.97" name="www"/>
        <!--<remote ip="192.168.8.39" name="tongbu"/>-->
        <!--<remote ip="192.168.8.40" name="tongbu"/>-->
    </localpath>
    <rsync>
        <commonParams params="-artuz"/>
        <auth start="true" users="rsync" passwordfile="/etc/rsync.pass"/>
        <userDefinedPort start="false" port="873"/><!-- 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="720"><!--600mins-->
        <crontabfilter start="true">
            <exclude expression="^load-control.html*"></exclude>
        </crontabfilter>
    </crontab>
    <plugin start="false" name="command"/>
    </sersync>
</head>

2.3, 创建seRsync的守护进程用systemd管理并启动

创建sersyncd4tomcat.servicesersyncd4www.service到systemd配置文件路径:/usr/lib/systemd/system/

  • sersyncd4tomcat.service 具体内容
[Unit]
Description=Client for rsync
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/sersync2 -rdo /etc/sersync/tomcat.xml
ExecReload=pidof sersync2|xargs kill -1
ExecStop=pidof sersync2|xargs kill -3
[Install]
WantedBy=multi-user.target
  • sersyncd4www.service具体内容
[Unit]
Description=Client for rsync
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/sersync2 -rdo /etc/sersync/www.xml
ExecReload=pidof sersync2|xargs kill -1
ExecStop=pidof sersync2|xargs kill -3
[Install]
WantedBy=multi-user.target

2.4,上传rsync.pass密码文件到配置文件目录:/etc/

rsync.pass密码文件具体内容是

r_SynC-2021#@2021-RsyN_c

密码文件中,“r_SynC-2021#@2021-RsyN_c”与同步逻辑下游节点B的rsync配置文件相对应。
为节点B的rsyncd.conf中“auth users”字段配置的同步用rsync用户密码,节点B的密码保存在节点B的rsync.pass密码文件中。(非操作系统用户)
rsync.pass权限应为600

chmod 600 /etc/rsync.pass

2.5 ,重新加载systemd,启动sersyncd守护进程并配置开机自启

systemctl daemon-reload
systemctl enable sersyncd4tomcat
systemctl enable sersyncd4www
systemctl start sersyncd4tomcat
systemctl start sersyncd4www

3,节点B

3.1 ,安装Rsync

yum install rsync -y
vim /etc/rsyncd.conf
vim /etc/rsync.pass

3.2创建Rsync配置文件rsyncd.conf、密码文件rsync.pass到配置文件目录:/etc/

  • rsyncd.conf内容长这样:
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
lock file = /var/run/rsyncd.lock
motd file = /etc/rsyncd.motd
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
uid = root
gid = root
port = 873
read only = no
write only = yes
list = no
auth users = rsync
secrets file = /etc/rsync.pass
use chroot = no
max connections = 300
hosts allow = 10.195.24.97
hosts deny = 0.0.0.0/0
timeout = 300
[tomcat]
path = /vdb/eastmoney/apache-tomcat-8.5.27/
exclude = logs/ webapps/load-control.html* webapps/pcPublish
[www]
path = /vdb/eastmoney/data0/htdocs/www/
exclude = load-control.html*

-rsync.pass内容长这样:

r_SynC-2021#@2021-RsyN_c
rsync:r_SynC-2021#@2021-RsyN_c
  • 密码文件中,第1行的“r_SynC-2021#@2021-RsyN_c”与同步逻辑下游节点C的rsync配置文件相对应。为节点C的rsyncd.conf中“auth users”字段配置的同步用rsync用户密码,节点C的密码保存在节点C的rsync.pass密码文件中。(非操作系统用户)
  • 密码文件中,第2行的“rsync:r_SynC-2021#@2021-RsyN_c”与同步逻辑上游节点A的sersync配置文件相对应。为节点A的tomcat.xml和www.xml中head.rsync.auth的user用户和passoredfile指定密码文件中的密码。
    写法为<上游同步用用户>:<上游同步用用户密码>(非操作系统用户)
    rsync.pass权限应为600
chmod 600 /etc/rsync.pass

3.3,启动Rsyncd

启动rsyncd守护进程并配置开机自启。

systemctl enable rsyncd
systemctl start rsyncd

3.4, 安装seRsync

同样地把刚才解压的那个sersync2文件复制到节点B的系统可执行程序路径:/usr/local/bin/;创建sersync配置目录/etc/sersync/并上传配置文件tomcat.xmlwww.xml

  • tomcat.xml 内容长这样:
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="true"/>
    <fileSystem xfs="false"/>
    <filter start="true">
    <exclude expression="^logs/*"></exclude>
    <exclude expression="^webapps/pcPublish/*"></exclude>
    </filter>
    <inotify>
    <delete start="true"/>
    <createFolder start="true"/>
    <createFile start="true"/>
    <closeWrite start="true"/>
    <moveFrom start="true"/>
    <moveTo start="true"/>
    <attrib start="false"/>
    <modify start="false"/>
    </inotify>


    <sersync>
    <localpath watch="/vdb/eastmoney/apache-tomcat-8.5.27/">
        <remote ip="10.205.204.199" name="tomcat"/>
        <!--<remote ip="192.168.8.39" name="tongbu"/>-->
        <!--<remote ip="192.168.8.40" name="tongbu"/>-->
    </localpath>
    <rsync>
        <commonParams params="-artuz"/>
        <auth start="true" users="rsync" passwordfile="/etc/rsync.pass"/>
        <userDefinedPort start="false" port="873"/><!-- 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="720"><!--600mins-->
        <crontabfilter start="true">
            <exclude expression="^logs/*"></exclude>
            <exclude expression="^webapps/pcPublish/*"></exclude>
        </crontabfilter>
    </crontab>
    <plugin start="false" name="command"/>
    </sersync>
</head>

-www.xml 内容长这样

<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
    <host hostip="localhost" port="8008"></host>
    <debug start="true"/>
    <fileSystem xfs="false"/>
    <filter start="true">
    <exclude expression="^load-control.html*"></exclude>
    </filter>
    <inotify>
    <delete start="true"/>
    <createFolder start="true"/>
    <createFile start="true"/>
    <closeWrite start="true"/>
    <moveFrom start="true"/>
    <moveTo start="true"/>
    <attrib start="false"/>
    <modify start="false"/>
    </inotify>


    <sersync>
    <localpath watch="/vdb/eastmoney/data0/htdocs/www/">
        <remote ip="10.205.204.199" name="www"/>
        <!--<remote ip="192.168.8.39" name="tongbu"/>-->
        <!--<remote ip="192.168.8.40" name="tongbu"/>-->
    </localpath>
    <rsync>
        <commonParams params="-artuz"/>
        <auth start="true" users="rsync" passwordfile="/etc/rsync.pass"/>
        <userDefinedPort start="false" port="873"/><!-- 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="720"><!--600mins-->
        <crontabfilter start="true">
            <exclude expression="^load-control.html*"></exclude>
        </crontabfilter>
    </crontab>
    <plugin start="false" name="command"/>
    </sersync>
</head>

3.5 创建seRsync的守护进程用systemd管理并启动

上传sersyncd4tomcat.service和sersyncd4www.service到systemd配置文件路径:/usr/lib/systemd/system/

  • sersyncd4tomcat.service内容长这样:
[Unit]
Description=Client for rsync
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/sersync2 -rdo /etc/sersync/tomcat.xml
ExecReload=pidof sersync2|xargs kill -1
ExecStop=pidof sersync2|xargs kill -3
[Install]
WantedBy=multi-user.target
  • sersyncd4www.service内容长这样:
[Unit]
Description=Client for rsync
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/bin/sersync2 -rdo /etc/sersync/www.xml
ExecReload=pidof sersync2|xargs kill -1
ExecStop=pidof sersync2|xargs kill -3
[Install]
WantedBy=multi-user.target
  • 重新加载systemd,启动sersyncd守护进程并配置开机自启。
systemctl daemon-reload
systemctl enable sersyncd4tomcat
systemctl enable sersyncd4www
systemctl start sersyncd4tomcat
systemctl start sersyncd4www

4,节点C

4.1 安装Rsync

yum install -y rsync

4.2、配置Rsync

上传Rsync配置文件rsyncd.conf 、密码文件rsync.pass 到配置文件目录:/etc/

  • rsyncd.conf 内容长这样:
pid file = /var/run/rsyncd.pid
log file = /var/log/rsyncd.log
lock file = /var/run/rsyncd.lock
motd file = /etc/rsyncd.motd
dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
uid = root
gid = root
port = 873
read only = no
write only = yes
list = no
auth users = rsync
secrets file = /etc/rsync.pass
use chroot = no
max connections = 300
hosts allow = 10.195.24.97
hosts deny = 0.0.0.0/0
timeout = 300
[tomcat]
path = /vdb/eastmoney/apache-tomcat-8.5.27/
exclude = logs/ webapps/load-control.html* webapps/pcPublish
[www]
path = /vdb/eastmoney/data0/htdocs/www/
exclude = load-control.html*
  • rsync.pass 内容长这样:
rsync:r_SynC-2021#@2021-RsyN_c

rsync.pass权限应为600

chmod 600 /etc/rsync.pass

密码文件中,“rsync:r_SynC-2021#@2021-RsyN_c”与同步逻辑上游节点B的sersync配置文件相对应。为节点B的tomcat.xml和www.xml中head.rsync.auth的user用户和passoredfile指定密码文件中的密码。
写法为<上游同步用用户>:<上游同步用用户密码>(非操作系统用户)

4.3、启动Rsync

启动rsyncd守护进程并配置开机自启。

systemctl enable rsyncd
systemctl start rsyncd

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

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

相关文章

CSPM.pdf

PDF转图片 归档&#xff1a;

直播领域新宠—第三代大模型无人直播系统:提升销售业绩的秘密武器

随着科技的飞速发展和人们对智能化生活的追求&#xff0c;直播领域也迎来了革新性的突破。第三代大模型无人直播系统&#xff0c;作为直播领域的新宠&#xff0c;正以其独特的魅力和优势&#xff0c;成为提升销售业绩的秘密武器。 首先&#xff0c;第三代大模型无人直播系统具…

3---C++之list(逻辑梳理、简单使用演示、部分源码实现)

一、先决知识点1——认识list&#xff1a; list底层实现是双向链表&#xff0c;但是不是循环链表。list是否使用哨兵节点&#xff0c;是细节问题&#xff0c;C标准并未规定。list是链表&#xff0c;他的优势在于对节点的操作会十分灵活&#xff0c;因此它在需要频繁插入和删除元…

压力测试JMeter

压力测试JMeter 1 下载JMeter1.1 测试计划1.2 JMeter Address Already in use 错误解决1.3 java 内存模型1.4 jconsole与jvisualvm1.5 优化方向1.6 Nginx动静分离 1 下载JMeter 官网地址&#xff1a;https://jmeter.apache.org/download_jmeter.cgi 运行apache-jmeter-5.6.3\…

鸿蒙应用Stage模型【应用/组件级配置】

应用/组件级配置 在开发应用时&#xff0c;需要配置应用的一些标签&#xff0c;例如应用的包名、图标等标识特征的属性。本文描述了在开发应用需要配置的一些关键标签。 应用包名配置 应用需要在工程的AppScope目录下的[app.json5配置文件]中配置bundleName标签&#xff0c;…

万字长文详解QUIC协议,为什么有了TCP我们还需要QUIC?

本文目录 1.前言2. HTTP缺点缺点一&#xff1a;建立连接的握手延迟大缺点二&#xff1a;多路复用的队首阻塞缺点三&#xff1a;TCP协议的更新滞后 3.TCP缺点3.QUIC优点一&#xff1a;避免队首阻塞的多路复用优点二&#xff1a;支持连接迁移优点三&#xff1a;可插拔的拥塞控制优…

YAML快速编写示例

一、案例 1.1 自主式创建service关联上方的pod 资源名称my-nginx-kkk命名空间my-kkk容器镜像nginx:1.21容器端口80标签njzb:my-kkk 1.1.1 创建一个demo文件夹 1.1.2 创建并获取模版文件 1.1.3 查看服务并编写yaml文件 1.1.4 编写yaml文件并部署&#xff0c;查看服务是否运行成…

Kotlin和Swift的前世一定是兄弟

Swift介绍 Swift这门编程语言主要用于iOS和MacOS的开发&#xff0c;可以说是非常流行的一门编程语言&#xff0c;我只想说&#xff0c;如果你会Kotlin&#xff0c;那么你学习Swift会非常容易&#xff0c;反之亦然。下载XCode&#xff0c;然后你就可以创建Playground练习Swift语…

Qt图像处理技术十:得到QImage图像的高斯模糊

效果图 参数为5 参数为20 原理 高斯模糊使用正态分布来分配周围像素的权重。具体来说&#xff0c;距离中心点越近的像素对最终结果的影响越大&#xff0c;权重也越高&#xff1b;随着距离的增加&#xff0c;权重逐渐减小。 这种权重分配方式确保了图像在模糊处理时&#xff0…

Docker(Centos7+)

先确定是否 Centos 7 及以上的版本 查看是否 ping 通外网 linux centos7运行下面的代码&#xff0c;基本上都可以正常安装 # 删除之前的docker残留 yum -y remove docker*yum install -y yum-utilsyum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/…

中草药识别系统Python+深度学习人工智能+TensorFlow+卷积神经网络算法模型

一、介绍 中草药识别系统。本系统基于TensorFlow搭建卷积神经网络算法&#xff08;ResNet50算法&#xff09;通过对10中常见的中草药图片数据集&#xff08;‘丹参’, ‘五味子’, ‘山茱萸’, ‘柴胡’, ‘桔梗’, ‘牡丹皮’, ‘连翘’, ‘金银花’, ‘黄姜’, ‘黄芩’&…

我给线程池管理框架hippo4j找bug

1 虚拟机参数不生效 hippo4j的docker启动脚本位于 docker/docker-startup.sh 。从下图可以看到 JAVA_OPT放在了jar包名 hippo4j-server.jar之后&#xff0c;而只有项目参数才放在jar包名之后。 实际上这里JAVA_OPT中包含虚拟机参数&#xff0c;而虚拟机参数要放在jar包名之前…

windows配置dns访问git , 加快访问速度保姆级教程

设置 DNS 访问 Git 需要修改电脑的 DNS 配置。下面是具体的操作流程&#xff1a; 第一步&#xff1a;打开命令提示符或终端窗口 在 Windows 系统中&#xff0c;可以按下 Win R 组合键&#xff0c;然后输入 “cmd”&#xff0c;按下 Enter 键打开命令提示符窗口。在 macOS 或 …

【tomcat 源码分析总结】

文章目录 tomcat官网路径目录结构介绍&#xff1a;Tomcat 系统架构 和 原理剖析http 的请求的处理过程 Tomcat 请求处理大致过程 tomcat官网路径 目录结构介绍&#xff1a; confserver.xml 端口的指定tomcat-users.xml 角色web.xml : tomcat 全局的xmllogging.properties 日志…

深入剖析 Kubernetes 原生 Sidecar 容器

1 Sidecar 容器的概念 sidecar 容器的概念在 Kubernetes 早期就已经存在。一个明显的例子就是 2015 年的这篇 Kubernetes 博客文章&#xff0c;其中提到了 sidecar 模式。多年来&#xff0c;sidecar 模式在应用程序中变得越来越普遍&#xff0c;使用场景也变得更加多样化。 其…

华为官网的自助申诉

代码&#xff1a;如下 <!DOCTYPE html> <html lang"en"> <head> <meta charset"UTF-8"> <meta name"viewport" content"widthdevice-width, initial-scale1.0"> <title>Document</title> …

乐观锁 or 悲观锁 你怎么选?

你有没有听过这样一句话&#xff1a;悲观者正确&#xff0c;乐观者成功​。那么今天我来分享下什么是乐观锁​和悲观锁。 乐观锁和悲观锁有什么区别&#xff0c;它们什么场景会用 乐观锁 乐观锁基于这样的假设&#xff1a;多个事务在同一时间对同一数据对象进行操作的可能性很…

Qt图像处理技术九:得到QImage图像的灰度直方图

效果 原理 得到灰度化值&#xff0c;将灰度化的值带入0-255内&#xff0c;增加&#xff0c;得到可视化图形 源码 // 绘制直方图 QImage drawHistogram(const QImage &image) {QVector<int> histogram(256, 0);// 计算图像的灰度直方图for (int y 0; y < image…

【linux】在linux操作系统下快速熟悉开发环境并上手开发工具——体验不一样的开发之旅

个人主页&#xff1a;东洛的克莱斯韦克-CSDN博客 祝福语&#xff1a;愿你拥抱自由的风 目录 vim编辑器 Linux编译器&#xff1a;gcc/g使用 gcc和g的选项 编译过程 动静态库的链接 Linux项目的自动化构建 生成可执行程序 清理可执行程序 Linux调试器-gdb使用 git和git…

【嵌入式硬件】DRV8874电机驱动

目录 1 芯片介绍 1.1 特性简介 1.2 引脚配置 1.3 最佳运行条件 2 详细说明 2.1 PMODE配置控制模式 2.1.1 PH/EN 控制模式 2.1.2 PWM 控制模式 2.1.3 独立半桥控制模式 2.2 电流感测和调节 2.2.1 IPROPI电流感测 2.2.2 IMODE电流调节 3.应用 3.1设计要求 3.2 设计…