博客
关于我
Rsync + Intofy 数据实时同步方案
阅读量:599 次
发布时间:2019-03-12

本文共 1905 字,大约阅读时间需要 6 分钟。

Rsync + Intofy 数据实时同步方案

Rsync 部署

Master节点配置

  • 停止并禁用防火墙:

    systemctl stop firewalldsystemctl disable firewalldsetenforce 0
  • 安装并配置rsync:

    yum -y install rsync
    • 配置rsyncd.conf:

      vim /etc/rsyncd.confuid = rootgid = rootuse chroot = yesaddress = 192.168.0.10port 873log file = /var/log/rsyncd.logpid file = /var/run/rsyncd.pidhosts allow = 192.168.0.0/24[wwwroot]path = /var/www/htmlcomment = Document Root of www.example.comread only = yesdont compress = *.gz *.bz2 *.tgz *.zip *.rar *.zauth users = foxsecrets file = /etc/rsyncd_users.db
    • 创建并设置用户文件:

      echo "fox:123456" > /etc/rsyncd_users.dbchmod 600 /etc/rsyncd_users.db
  • 启动rsync服务:

    rsync --daemonnetstat -natp | grep rsyncmkdir -p /var/www/htmlcd /var/www/htmltouch dog.htmlcat.htmls

Slave节点配置

  • 停止并禁用防火墙:

    systemctl stop firewalldsystemctl disable firewalldsetenforce 0
  • 安装rsync并创建目录:

    yum install -y rsyncmkdir /slavechmod 777 /slave
  • 创建密钥文件并设置权限:

    echo "123456" > /etc/server.passchmod 600 /etc/server.pass
  • 使用rsync同步数据:

    rsync -az --delete --password-file=/etc/server.pass fox@192.168.0.10::wwwroot /slave

Intofy 部署

内核参数优化

  • 修改sysctl配置文件:
    echo "fs.inotify.max_queued_events = 32768                   fs.inotify.max_user_instances = 1024                   fs.inotify.max_user_watches = 1048576" > /etc/sysctl.confsysctl -p

安装Intofy-tools

  • 下载并编译:
    wget -P /opt https://nchc.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gzcd /opttar -zxvf inotify-tools-3.13.tar.gzcd /opt/inotify-tools-3.13./configuremake -j 4make install

编写自动监控同步脚本

  • 创建脚本并赋予权限:
    vim /opt/inotify.sh#!/bin/bashINOTIFY_CMD="inotifywait -mrq -e create,delete,move,modify,attrib /slave"RSYNC_CMD="rsync -azH --delete --password-file=/etc/server.pass /slave fox@192.168.0.10::wwwroot"# ...
  • 后台运行脚本:
    chmod +x inotify.sh./inotify.sh &

测试

  • 创建文件:

    cd /slavetouch fox.htmlrm -rf dog.htmls
  • 查看同步日志:

    tail -f /var/log/rsyncd.log

报错排查

  • 如果遇到错误:
    @ERROR: auth failed on module wwwroot

    检查用户名和密码是否一致。

转载地址:http://jpwaz.baihongyu.com/

你可能感兴趣的文章
解决:angularjs radio默认选中失效问题
查看>>
windows环境下安装zookeeper(仅本地使用)
查看>>
缓冲区溢出实例(一)--Windows
查看>>
Python中字符串前添加r ,b, u, f前缀的含义
查看>>
Hadoop学习笔记—Yarn
查看>>
JSONPath小试牛刀之Snack3
查看>>
Jenkins - 部署在Tomcat容器里的Jenkins,提示“反向代理设置有误”
查看>>
wxWidgets源码分析(3) - 消息映射表
查看>>
wxWidgets源码分析(5) - 窗口管理
查看>>
wxWidgets源码分析(7) - 窗口尺寸
查看>>
wxWidgets源码分析(8) - MVC架构
查看>>
wxWidgets源码分析(9) - wxString
查看>>
[白话解析] 深入浅出熵的概念 & 决策树之ID3算法
查看>>
[梁山好汉说IT] 梁山好汉和抢劫银行
查看>>
[源码解析] 消息队列 Kombu 之 基本架构
查看>>
[源码分析] 消息队列 Kombu 之 启动过程
查看>>
抉择之苦
查看>>
wx.NET CLI wrapper for wxWidgets
查看>>
Silverlight for linux 和 DLR(Dynamic Language Runtime)
查看>>
ASP.NET MVC Action Filters
查看>>