inotify+rsync安装配置
环境 | 系统 | 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安装配置的更多相关文章
- rsync安装配置及故障解决完全教程[window, 文件同步]
Rsync是的全称是: remote synchronize, 也就是远程同步数据, 它是一款不错的文件同步软件,而且是免费的, 它在镜像保存整个目录树和文件系统的同时保持原来文件的权限.时间.软硬链 ...
- rsync安装配置实时同步
一.简介 1.认识 Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.Rsync使用所谓的“Rsync算法”来使本地和远 程两个主 ...
- centos rsync安装配置
安装 1 yum -y install rsync ---------------------服务器安装------------------------------- 创建基础配置文件 1 2 3 4 ...
- inotify工具安装配置
一.安装 1) 从内核和目录里面查看是否支持inotify [root@nfs01 ~]# uname -r 2.6.32-573.el6.x86_64 [root@nfs01 ~]# ls -l ...
- Linux系统inotify工具安装配置
inotify主要功能 Inotify 是一个 Linux特性,它监控文件系统操作,比如读取.写入和创建.Inotify 反应灵敏,用法非常简单,并且比 cron 任务的繁忙轮询高效得多.学习如何将 ...
- Rsync安装配置
一.先准备两台CentOS服务器,假定是 1.172.18.2.225(服务端) 需要配置rsyncd.conf文件 2.172.18.2.227(客户端) 不需要配置rsyncd.conf文件 二. ...
- CentOS7 安装配置rsync
centos7自带rsync,今天简单记录下. rsync安装配置步骤 服务器端: 1.修改默认配置文件/etc/rsyncd.conf,该成如下: # /etc/rsyncd: configurat ...
- Inotify+rsync实现实时数据同步
使用rsync可以实现数据同步,但是即使使用crontab定时任务最小执行间隔为1分钟,在数据实时性要求比较高场合需使用inotify+rsync实现实时同步 下载inotify wget https ...
- lsyncd替代inotify+rsync实现实时同步
因公司业务需要需要实时同步日志文件,刚一开始使用的是inotify+rsync来实现实时同步,但时间久而久之发现同步的速度越来越慢,往往延迟好几个小时.查了一下网上的inotify+rsync方案基本 ...
随机推荐
- C Language Study - 函数指针的使用
函数指针的使用 1.函数指针定义 第一次使用函数指针,我是这样声明的,typedef void ( *pSimulatepks )( uint8 *prxBuf, uint8 *prxBufLen ) ...
- mysql驱动(github上的)
https://github.com/Eonblast/Emysql https://github.com/denglf/erlang-db-driver https://github.com/diz ...
- par函数的ann 参数-控制图片的注释信息
ann 参数控制图片的x轴和y轴标签以及标题是否显示 默认值为TRUE, 所以图片有对应的信息时,会显示出来,代码示例 plot(1:5, 1:5, main = "title", ...
- R语言低级绘图函数-grid
grid 函数用来在一张图表上添加网格线, 基本用法:默认在添加刻度线的地方添加网格线 plot(1:5, 1:5, xlim = c(0,6), ylim = c (0,6), type = &qu ...
- Windows下安装Scrapy
安装python 根据你的需求下载python安装包,安装python(本文基于python27)https://www.python.org/downloads/ 在 环境变量---"Pa ...
- u3d调用c++ dll的DllNotFoundExceion 问题
原文地址:http://blog.csdn.net/boren31/article/details/8778504 问题年年有,今年特别多. 开发环境: Windows XP sp3 Visual ...
- Cookie管理工具
Cookie Editor 是管理 Cookie 的工具,能识别并编辑IE.Firfox.Netscope Cookie 文件,控制个人隐私信息,修改 Cookie 使用期限,删除历史文件,编辑和删除 ...
- [redis] redis 对string类型数据操作
package com.xwolf.java.redis; import org.junit.Before; import org.junit.Test; import redis.clients.j ...
- /etc/motd
/etc/motd 用于自定义欢迎界面,用法如下: [root@localhost ~]$ cat /etc/motd .=""=. / _ _ \ | d b | \ /\ / ...
- nano100B的看门狗讲解
看门狗定时器的用途是在软件出问题时执行系统复位功能,这可以防止系统无限期地挂起.除此之外,看门狗定时器还支持将CPU 从掉电模式唤醒的功能.看门狗定时器包含一个18 位的自由运行计数器,定时溢出间隔可 ...