Linux企业实时同步服务---3688字

实时同步服务

在这里插入图片描述
正常的互联网公司架构:

  • 内容:每天服务器及服务器上的应用程序等正常使用(每天查看)比如:邮件,短信,等信息;巡检内容是否正常使用。
  • 互联网公司就是底层服务+开发、代码运行网站/软件来挣钱,主要负责服务器是否使用(类似于虚拟机能否正常使用,能否互相连通,有没有报错,每天巡检服务器的负载情况,cpu使用率等,大部分公司他们的cpu负载使用率基本在20%以下,超过云服务器等会使前端业务进行堵塞)
  • 架构:lnmp,linux,php(程序运行),mysql(数据),nginx 80,haproxy(将http域名改为https,进行内网的登录解析)
  • 开发环境需要与运维协同工作,开发向运维提出需求(运维职责之内的)提供简便方式!刚入职前1两个月熟悉公司的架构环境,部署,ip等布置信息,职能,公司会对你进行分配任务(部分东西进行容器化,自动化等
  • 每个公司的运维体系不相同,定期完善优化脚本、扩展业务;
  • 有专门的idc测试环境(非常严谨)多次测试完成,然后将其部署,否则一旦没有测试好部署上去,公司业务(网站,软件否则全部崩掉),求稳除非公司业务进行交接
  • 正常架构都会有前后端分离,为(2-3台左右)具体就要看公司的访问量nginx 3 4cpu 16g
  • php api接口服务器 (前端只进行接收请求,后端为数据)一般公司后面都会有后台任务服务器crontab(定时定量处理执行)

1.1说明

前面通过rsync+定时任务+NFS实现备份同步存储
NFS需要进行实时同步(频繁)

选择:

  • 分布式存储
  • 实时同步服务+NFS
  • 选择公有云对象存储OSS,七牛存储,腾讯存储COS(不用关注高可用,厂商直接在后面进行做好)

选择:nfs(单点)+实时同步工具

  • inotify(bug需要书写脚本,不推荐):是个命令监控指定目录是否发生变化
  • sersync(国产开源,内置inotify+rsync命令,一个命令+一个配置文件)
  • lsyncd(部分公司在进行使用)

sersync原理
在这里插入图片描述
在这里插入图片描述

部署

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

目录规划:
/app/tools/sersync/
/app/tools/sersync/bin/
/app/tools/sersync/conf
修改之前
GNU-Linux-x86/
GNU-Linux-x86/sersync2
GNU-linux-X86/confxml.xml

在这里插入图片描述
修改后的样子

cat /app/tools/sersync/conf/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"/>是否有closewrite事件 修改后的退出 (文件被修改)
	<moveFrom start="true"/> 移动改名
	<moveTo start="true"/> 移动改名
	<attrib start="false"/>文件属性变化
	<modify start="false"/>文件内容修改
    </inotify>

    <sersync>   
	<localpath watch="/opt/tongbu">监控那些目录一般为存储共享的目录
	    <remote ip="127.0.0.1" name="tongbu1"/> rsync服务端ip地址和rsync服务端的模块名称
	    <!--<remote ip="192.168.8.39" name="tongbu"/>--> xml中的注释
	    <!--<remote ip="192.168.8.40" name="tongbu"/>-->
	</localpath>
	<rsync>  
	    <commonParams params="-artuz"/>rsync命令行选项 az delete
	    <auth start="false" users="root" passwordfile="/etc/rsync.pas"/> authstart 是否开启免密码模式true users=rsync虚拟用户
	    <userDefinedPort start="false" port="874"/><!-- port=874 --> rsync服务端端口,默认是873
	    <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>

rsync服务准备

  • rsync’服务端

    [nfsbackup]

    comment = shishi tongbu nfs

    path = /nfsbackup/
    在这里插入图片描述
    在这里插入图片描述
    测试rsync客户端与服务端
    在这里插入图片描述
    修改客户端配置文件

操作前备份,操作后检查

备份原始的配置文件:
在这里插入图片描述
在这里插入图片描述

配置详解

修改前后对比

vimdiff confxml.xml confxml.xml.bak
在这里插入图片描述
启动sersync

没有systemctl启动命令方式

/app/tools/sersync/bin/sersync2 -h
在这里插入图片描述
在这里插入图片描述

ln -s /app/tools/sersync/bin/sersync2 /bin/

sersync2 -rdo /app/tools/sersync/conf/confxml.xml

在这里插入图片描述
在这里插入图片描述

watch ls -l /nfsbackup/(备份服务器backup监听)
在这里插入图片描述

rsync和sersync可以去应对企业tb级数据

在这里插入图片描述
注意:sersync功能(做开机自启动,rc.local,别放在fstab里,否则开机自启动打不开–fstab它是开机启动挂载,挂载磁盘,nfs)

接入nfs服务

服务端配置

[root@nfs01 ~]cat /etc/exports /data/ 172.16.1.0/24(rw)

客户端挂载

mount -t nfs 172.16.1.131:/data/ /upload

在这里插入图片描述
在这里插入图片描述

联调

核心:在web服务端入口创建文件,查看backup服务器是否有文件

  • 30
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值