环境 系统 IP地址
主服务器 CentOS7.4 192.168.1.1
备份服务器 CentOS7.4 192.168.1.2

一、备份服务器

安装rsync(备)

wget https://rsync.samba.org/ftp/rsync/src/rsync-3.1.3.tar.gz
tar -xf rsync-3.1.3.tar.gz
./configure --prefix=/usr/local/rsync
make && make install

配置rsyncd.conf

cat <<EOF> /etc/rsyncd.conf
pid file = /var/run/rsync.pid
log file = /var/log/rsync.log
lock file=/var/run/rsync.lock
secrets file = /etc/rsync.pw
motd file = /etc/rsyncd.motd
transfer logging = yes
log format = %t %a %m %f %b
syslog facility = local3
[data]
path = /data/test/
comment = data
exclude =
port = 873
uid = root
gid = root
timeout = 600
max connections = 200
use chroot = no
read only = no
list = no
hosts allow = 192.168.1.1
EOF

可以设置多个目录

#增加test1目录
[test1]
path = /data/test1
list = yes
ignore errors
comment = ucweb-file system
secrets file = /etc/rsync.pw
exclude = blank.png ; spinner.gif ; downsimple.png ; rails.png ; WEB-INF/

建立密码认证文件

cat <<EOF> /etc/rsync.pw
root:123456
EOF

配置rsyncd.motd文件,开始传送的时候会显示

cat <<EOF> /etc/rsyncd.motd
###############################
# #
# start rsync #
# #
###############################
EOF

启动rsync

/usr/local/rsync/bin/rsync --daemon --config=/etc/rsyncd.conf

开机启动rsync

echo '/usr/local/rsync/bin/rsync --daemon --config=/etc/rsyncd.conf'>>/etc/rc.d/rc.localer 

二、主服务器

建立密码认证文件

cat <<EOF> /etc/rsync.pw
123456
EOF

测试开始

/usr/local/rsync/bin/rsync -avH --port=873 --progress --delete /data/test/ root@192.168.1.3::data --password-file=/etc/rsync.pw

查看192.168.1.2上是否有同步

安装inotify-tools

yum install inotify-tools -y

新建inotify.sh文件同步

#!/bin/sh
# get the current path
CURPATH=`pwd`
/usr/bin/inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e modify /data | while read date time dir file; do
FILECHANGE=${dir}${file}
# convert absolute path to relative
FILECHANGEREL=`echo "$FILECHANGE" | sed 's_'$CURPATH'/__'` /usr/bin/rsync -avH --port=873 --progress --delete /data/test/ root@192.168.1.2::data --password-file=/etc/rsync.pw
echo "At ${time} on ${date}, file $FILECHANGE was backed up via rsync"
done

注意:

如果仅仅是备份的话,不要带delete参数

参考链接

https://blog.csdn.net/liuzheng0915/article/details/52003942

三、研究

lrsync

https://www.cnblogs.com/zxci/p/6243574.html

inotify+rsync安装配置的更多相关文章

  1. rsync安装配置及故障解决完全教程[window, 文件同步]

    Rsync是的全称是: remote synchronize, 也就是远程同步数据, 它是一款不错的文件同步软件,而且是免费的, 它在镜像保存整个目录树和文件系统的同时保持原来文件的权限.时间.软硬链 ...

  2. rsync安装配置实时同步

    一.简介 1.认识 Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.Rsync使用所谓的“Rsync算法”来使本地和远 程两个主 ...

  3. centos rsync安装配置

    安装 1 yum -y install rsync ---------------------服务器安装------------------------------- 创建基础配置文件 1 2 3 4 ...

  4. inotify工具安装配置

    一.安装 1)  从内核和目录里面查看是否支持inotify [root@nfs01 ~]# uname -r 2.6.32-573.el6.x86_64 [root@nfs01 ~]# ls -l ...

  5. Linux系统inotify工具安装配置

    inotify主要功能 Inotify 是一个 Linux特性,它监控文件系统操作,比如读取.写入和创建.Inotify 反应灵敏,用法非常简单,并且比 cron 任务的繁忙轮询高效得多.学习如何将 ...

  6. Rsync安装配置

    一.先准备两台CentOS服务器,假定是 1.172.18.2.225(服务端) 需要配置rsyncd.conf文件 2.172.18.2.227(客户端) 不需要配置rsyncd.conf文件 二. ...

  7. CentOS7 安装配置rsync

    centos7自带rsync,今天简单记录下. rsync安装配置步骤 服务器端: 1.修改默认配置文件/etc/rsyncd.conf,该成如下: # /etc/rsyncd: configurat ...

  8. Inotify+rsync实现实时数据同步

    使用rsync可以实现数据同步,但是即使使用crontab定时任务最小执行间隔为1分钟,在数据实时性要求比较高场合需使用inotify+rsync实现实时同步 下载inotify wget https ...

  9. lsyncd替代inotify+rsync实现实时同步

    因公司业务需要需要实时同步日志文件,刚一开始使用的是inotify+rsync来实现实时同步,但时间久而久之发现同步的速度越来越慢,往往延迟好几个小时.查了一下网上的inotify+rsync方案基本 ...

随机推荐

  1. ASP.NET自带对象JSON字符串与实体类的转换

    关于JSON的更多介绍,请各位自行google了解!如果要我写的话,我也是去Google后copy!嘿嘿,一直以来很想学习json,大量的找资料和写demo,总算有点了解! 切入正题! 还是先封装一个 ...

  2. 对于MathType中公式与文字错位的问题怎么解决

    MathType是强大的数学公式编辑器,与常见的文字处理软件和演示程序配合使用,能够在各种文档中加入复杂的数学公式和符号,可用在编辑数学试卷.书籍.报刊.论文.幻灯演示等方面,是编辑数学资料的得力工具 ...

  3. linux常用命令-tar,scp,du

    tar 打包排除指定目录 tar -zcvf afish.tar.gz * --exclude=file1 --exclude=dir1 排除目录注意: 1.--exclude=file1 而不是 - ...

  4. linux用户及用户组操作

    Linux用户.用户组权限管理详解 Linux用户管理三个重要文件详解: Linux登陆需要用户名.密码./etc/passwd 文件保存用户名.登录Linux时,Linux 先查找 /etc/pas ...

  5. shell脚本中,将所有的参数值否赋给一个变量或者说将所有的参数合成一个字符串,获取所有参数

    需求描述: 在写脚本的过程中,遇到这样的一个需求,将脚本执行过程中,传递给 脚本的所有的参数,都赋值给一个变量然后在对这个变量进行处理. 测试过程: 通过以下的脚本将所有传递给脚本的变量都赋值一个变量 ...

  6. [hibernate]org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter

    org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type sette ...

  7. Collabration Web Application Screenshot(English Language) Free download now!

    The screenshots of english language version collabration web application which is as following: Incl ...

  8. Redis(四)-- 集群

    一.Redis适合做企业级分布式缓存集群的条件 1.Redis内置哈希槽,有16384个哈希槽(0~16383),根据CRC16算法来确定这个集群中属于哪一个服务器来处理这个请求. 2.Redis提供 ...

  9. STM32的操作过程,寄存器配置与调试过程(转载)

    很多学习stm32的,为什么学习stm32他也不知道,我们所知道的就是各个论坛讨论stm32的很多,而我们很多人之所以学习stm32是很多的淘宝卖家做了大量的图片文字宣传,于是我们经不住诱惑就买了板子 ...

  10. js 判断数据类型的几种方法

    判断js中的数据类型有一下几种方法:typeof.instanceof. constructor. prototype. $.type()/jquery.type(),接下来主要比较一下这几种方法的异 ...