NFS实时备份
方法一(inotify+rsync):
1.安装inotify-tools(客户端)【监听工具】,实现数据属实备份检查目录是否有如下文档,没有表示操作系统不支持
ls -l /proc/sys/fs/inotify

2、安装inotify-tools软件
yum install inotify-tools -y

如果安装失败,可能是源包的问题,需要安装第三方的源(wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo)
3、新开一个窗口(原网址),进行测试
一个窗口进行监听另外一个创建创建文件:
inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e create,delete /backup

4、确保服务端及客户端的rsync正常的情况下,可以下如下脚本进行实时推送
#!/bin/bash
Path=/data
IP=172.16.1.99
/usr/bin/inotifywait -mrq --format '%w%f' -e close_write,delete $Path \
|while read file
do
cd $Path &&\
rsync -az ./ --delete rsync_backup@$IP::nfsbackup/ --password-file=/etc/rsync.password
done
注:客户端为/data目录,服务端为/nfsbackup目录
5、将其设置成一个服务
在/etc/init.d/syncd目录下写入如下代码执行或开机自启等操作,然后执行chkconfig --add syncd
#!/bin/bash
#chkconfig: 2345 38 46
. /etc/init.d/functions
if [ $# -ne 1 ]
then
echo "usage: $0 {start|stop|status}"
exit 1
fi
case "$1" in
start)
if [ -e "/var/run/inotify.pid" ]
then
action "inotify service start fail" /bin/false
echo "sync server is running......"
sleep 1
exit 1
fi
/bin/bash /server/scripts/inotify.sh &
echo $$ >/var/run/inotify.pid
if [ `ps -ef|grep inotify|wc -l` -gt 2 ]
then
action "inotify service is started" /bin/true
else
action "inotify service is started" /bin/false
fi
;;
stop)
if [ `ps -ef|grep inotify|grep -v grep|wc -l` -a -e "/var/run/inotify.pid" ]
then
rm -f /var/run/inotify.pid >/dev/null 2>&1
pkill inotifywait
else
action "inotify service stop fail" /bin/false
echo "sync server is not running"
sleep 1
exit 1
fi
sleep 1
if [ `ps -ef|grep inotify|grep -v grep|wc -l` -eq 0 -a ! -e "/var/run/inotify.pid" ]
then
action "inotify service is stoped" /bin/true
else
action "inotify service is stoped" /bin/false
fi
;;
status)
if [ `ps -ef|grep inotify|wc -l` -gt 2 ]
then
action "inotify service is running"
else
action "inotify service is stoped"
fi
;;
*)
echo "usage: $0 {start|stop|status}"
exit 1
esac
方法二(sersync+rsync):
1、新建一个/application/目录,网上下载个sersync文件,即解压(客户端配置)

2、查看GNU-Linux-x86/confxml.xml配置文件信息

3、修改GNU-Linux-x86/confxml.xm配置信息

4、查看启动文件的属性
/application/GNU-Linux-x86/sersync2 -h

5、执行测试
/application/GNU-Linux-x86/sersync2 -d -r -n 8 -o /application/GNU-Linux-x86/confxml.xml

6、测试如上述提示表成功写入(/etc/rc.local)开机自启即可
echo '/application/GNU-Linux-x86/sersync2 -d -r -n 8 -o /application/GNU-Linux-x86/confxml.xml' >>/etc/rc.local
小结:
服务器端通过命令也可实现监听(watch),但是延迟两秒。
NFS实时备份的更多相关文章
- 部署web01,web02,nfs,db01,backup,搭建wordpress,WeCenter,实现共享,热备,实时备份
小结 部署web01,web02,nfs,db01,backup,搭建wordpress,WeCenter,实现共享,热备,实时备份 1)在web01和web02上安装nginx和php 2)创建ww ...
- 【集群实战】共享存储实时备份(解决nfs共享存储的单点问题)
1. nfs存储的单点问题 如果nfs服务器宕机了,则所有的nfs客户机都会受到影响.一旦宕机,会丢失部分用户的数据.为了解决单点问题,需要实现共享存储的实时备份,即:将nfs服务端共享目录下的数据实 ...
- ansible-playbook 实战案例 全网备份 实时备份
目录 ansible-playbook 基础介绍 1.YAML三板斧 2. ansible playbook 安装apache 示例 案例 全网备份 实时备份 环境规划 目录规划 base.yaml ...
- 全网数据实时备份方案[inotify,sersync]
环境搭建 0.环境安装 gcc yum install gcc -y 1.安装inotify(源码软件包) 文件下载:https://files.cnblogs.com/files/ftl101 ...
- 实时备份工具之inotify+rsync
1.inotify简介 inotify 是一个从 2.6.13 内核开始,对 Linux 文件系统进行高效率.细粒度.异步地监控机制, 用于通知用户空间程序的文件系统变化.可利用它对用户空间进行安全. ...
- rsync nfs 实时同步,结合实战
目录 rsync nfs 实时同步,实战 一.部署rsync服务端(backup) 二.部署rsync客户端(nfs,web01) 三.部署web代码(web01) 四.NFS服务端部署(nfs) 五 ...
- rsync+inotify-tools实时备份脚本
1.1 实时备份 1.需求分析: 为什么要实时复制 因为nfs是单点非常的不安全 而通过定时任务备份会造成数据丢失 这是就需要需要实时备份 2实时方案 1).搭建好服务端backup与客户端nfs的 ...
- 通过rsync+inotify实现数据的实时备份
我讲到过利用rsync实现数据的镜像和备份,但是要实现数据的实时备份,单独靠rsync还不能实现,本文就讲述下如何实现数据的实时备份. 一.rsync的优点与不足 与传统的cp.tar备份方式相比,r ...
- 工作随笔——使用svnsync实时备份SVN版本库
前段时间把SVN版本库从win迁移到了Linux上,没隔几天那台win的磁盘就严重坏道了....这TMD什么运气! 花费了点时间研究了下svn自己的同步工具.写个日志记录下. 注意:svnsync要求 ...
随机推荐
- 个人常常使用的一些Eclipse技巧
引言 为了加快开发效率,方便地浏览源代码,重构以及重写一些方法等,Eclipse给我们提供了非常多方便的快捷键以及小技巧.以下是我总结一下经常使用的快捷键和技巧. 快捷键 清理控制台(console) ...
- 《CS:APP》 chapter 9 Vitrual Memory 笔记
Vitrual Memory In order to manage memory more efficiently and with fewer errors, modern systems prov ...
- spring与springboot中,如何在static方法里使用自动注入的属性
第一步:写注解@Component 使当前类成为一个bean对象.(@Controller,@service都行) 第二步:写个static的变量 第三步:写个@PostConstruct注解注解注释 ...
- commons-fileupload上传文件(1)
近期,写一个上传图片的功能.于是用到commons-fileupload这个组件.提过form提交表单到后台(这里没实用到structs框架).在后台List pl = dfu.parseReques ...
- Docker容器的使用和连接
在上一篇文章<Docker从安装部署到Hello World>介绍了如何在CentOS7上安装Docker.这篇文章主要介绍一下Docker容器的使用和连接. vDocker 容器使用 1 ...
- JavaScript 获取星期几函数
function getDayofWeek() { var day = ""; var time = new Date(); ...
- npm搭建React项目
转自:http://blog.csdn.net/u012859720/article/details/70597119 要想使用npm,首先安装Node.js 一.安装全局包 $ npm instal ...
- html body中的标签2
一.列表标签 列表标签分为三种. 1.无序列表<ul>,无序列表中的每一项是<li> 英文单词解释如下: ul:unordered list,“无序列表”的意思. li:lis ...
- Jenkins上Git ssh登陆配置
1. 首先登陆linux机器 2. 切换到jenkins用户 3. 生成ssh key ssh-keygen -t rsa -C 'amysu@acxiom.com' 4. 将生成的ssh ke ...
- C#中通过js实现个人用户和非个人用户的登陆
实现用户的登录功能,这里举一个个人和非个人用户的登录的例子 前台代码: <ul class="login_list clearfix"> <li> < ...