centos7安装sersync2+rsync+inotify-tools实现文件实时同步

简介:

服务器准备:

A:100.251.70.190 (客户图片文件的上传)从A同步到B

B:100.251.70.191 (客服浏览器浏览下载)

C:100.251.70.192 (客服浏览器浏览下载)

操作步骤:

(A和B服务器都必须安装的)

# rpm -qa|grep rsync

rsync-3.0.9-15.el7.x86_64

# yum install rsync(没有rsync就安装一下)

(B和C服务器安装配置)

vi /etc/rsyncd.conf

#工作中指定用户(需要指定用户)

uid = root

gid = root

#相当于黑洞.出错定位

use chroot = no

#有多少个客户端同时传文件

max connections = 200

#超时时间

timeout = 300

#进程号文件

pid file = /var/run/rsyncd.pid

#日志文件

lock file = /var/run/rsync.lock

#日志文件

log file = /var/log/rsyncd.log

#模块开始

#这个模块对应的是推送目录

#模块名称随便起

[tongbu]

#需要同步的目录

path = /opt/uploads

#表示出现错误忽略错误

ignore errors

#表示网络权限可写(本地控制真正可写)

read only = false

#这里设置IP或让不让同步

list = false

#指定允许的网段

hosts allow = 100.251.70.190

#拒绝链接的地址,以下表示没有拒绝的链接。

hosts deny = 0.0.0.0/32

#不要动的东西(默认情况)

#虚拟用户

auth users = root

#虚拟用户的密码文件

secrets file = /etc/rsync.password


配置访问账号密码

vi /etc/rsync.password

root:123456789

chmod 600 /etc/rsync.password


启动rsync 服务

rsync --daemon

ps -ef|grep rsync

netstat -tnulp|grep rsync


(A服务器安装配置)

配置访问账号密码

vi /etc/rsync.password

123456789

chmod 600 /etc/rsync.password


启动rsync 服务

rsync --daemon

ps -ef|grep rsync

netstat -tnulp|grep rsync


cd /opt

tar -zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz

mv GNU-Linux-x86 /opt/sersync2

vi /opt/sersync2/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="/opt/uploads">

            <remote ip="100.251.70.191" name="tongbu"/>

            <remote ip="100.251.70.192" name="tongbu"/>

            <!--<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="root" passwordfile="/etc/rsync.password"/>

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

# cd /opt/sersync2

# ./sersync2 -d

# ps -ef|grep rsync

# rsync -avSH ./uploads/ root@100.251.70.191::tongbu

# rsync -avSH ./uploads/ root@100.251.70.191::tongbu




本文转自 guowang327 51CTO博客,原文链接:http://blog.51cto.com/guowang327/1784369,如需转载请自行联系原作者

相关文章
|
5天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
54 25
|
15天前
|
监控 Linux PHP
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
65 20
|
21天前
|
存储 Prometheus 监控
Centos7.9版本安装collectd并开启写入rrd文件功能
Centos7.9版本安装collectd并开启写入rrd文件功能
77 13
|
1月前
|
存储 分布式计算 Hadoop
Centos7.9安装kerberos
Centos7.9安装kerberos
86 25
|
1月前
|
存储 Shell 网络安全
Centos7.9安装openldap
Centos7.9安装openldap
58 16
|
1月前
|
数据可视化 Linux 应用服务中间件
Centos7.9安装phpldapadmin
Centos7.9安装phpldapadmin
62 15
|
1月前
|
网络协议 Java 应用服务中间件
centos7环境下tomcat8的安装与配置
本文介绍了在Linux环境下安装和配置Tomcat 8的详细步骤。首先,通过无网络条件下的文件交互软件(如Xftp 6或MobaXterm)下载并解压Tomcat安装包至指定路径,启动Tomcat服务并测试访问。接着,修改Tomcat端口号以避免冲突,并部署Java Web应用项目至Tomcat服务器。最后,调整Linux防火墙规则,确保外部可以正常访问部署的应用。关键步骤包括关闭或配置防火墙、添加必要的端口规则,确保Tomcat服务稳定运行。
|
3月前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第16天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括配置系统源、安装 SQL Server 2019 软件包以及数据库初始化,确保 SQL Server 正常运行。
168 4
|
3月前
|
SQL 存储 Linux
从配置源到数据库初始化一步步教你在CentOS 7.9上安装SQL Server 2019
【11月更文挑战第8天】本文介绍了在 CentOS 7.9 上安装 SQL Server 2019 的详细步骤,包括系统准备、配置安装源、安装 SQL Server 软件包、运行安装程序、初始化数据库以及配置远程连接。通过这些步骤,您可以顺利地在 CentOS 系统上部署和使用 SQL Server 2019。
178 1
|
3月前
|
存储 安全 Linux
VMware安装CentOS7
【11月更文挑战第11天】本文详细介绍了在 VMware 中安装 CentOS 7 的步骤,包括准备工作、创建虚拟机、配置虚拟机硬件和安装 CentOS 7。具体步骤涵盖下载 CentOS 7 镜像文件、安装 VMware 软件、创建和配置虚拟机硬件、启动虚拟机并进行安装设置,最终完成 CentOS 7 的安装。在安装过程中,需注意合理设置磁盘分区、软件选择和网络配置,以确保系统的性能和功能满足需求。
429 0

热门文章

最新文章