linux手动安装rsync_Linux编译安装Rsync

本文详细介绍了在RHEL6.10系统上手动编译安装Rsync 3.1.3和inotify-tools 3.20.1的步骤,包括安装依赖、下载源码、配置、编译、安装、配置环境变量以及设置实时数据同步脚本,以实现高效的数据备份和同步。
摘要由CSDN通过智能技术生成

Rsync是一款专业的数据同步工具,轻松实现本地或者远程数据同步、增量备份,目前是中小型企业中使用率最高的数据备份工具。在企业中为实现数据的实时同步,一般会借助inotify-tools对文件或者目录状态进行监控,两者相结合提高同步工作效率。

实验环境

操作系统:RHEL6.10

Rsync:3.1.3

inotify-tools:3.20.1

安装教程

第一步 安装依赖包

[root@wanghualang ~]# yum -y install gcc automake libtool

第二步 下载、解压源码包

[root@wanghualang ~]# cd /usr/local/src/

[root@wanghualang src]# wget --no-check-certificate https://download.samba.org/pub/rsync/src/rsync-3.1.3.tar.gz

[root@wanghualang src]# wget --no-check-certificate https://github.com/rvoicilas/inotify-tools/archive/3.20.1.tar.gz

[root@wanghualang src]# tar xzf rsync-3.1.3.tar.gz

[root@wanghualang src]# tar xzf 3.20.1.tar.gz

第三步 编译安装Rsync、inotify-tools

[root@wanghualang ~]# cd /usr/local/src/rsync-3.1.3

[root@wanghualang rsync-3.1.3]# ./configure--prefix=/usr/local/rsync --disable-ipv6

[root@wanghualang rsync-3.1.3]# make

[root@wanghualang rsync-3.1.3]# make install

[root@wanghualang ~]# cd /usr/local/src/inotify-tools-3.20.1

[root@wanghualang inotify-tools-3.20.1]# sh autogen.sh

[root@wanghualang inotify-tools-3.20.1]# ./configure--prefix=/usr/local/inotify-tools

[root@wanghualang inotify-tools-3.20.1]# make

[root@wanghualang inotify-tools-3.20.1]# make install

第四步 配置环境变量

[root@wanghualang ~]# echo "exportPATH="$PATH:/usr/local/inotify-tools/bin:/usr/local/rsync/bin"">>/etc/profile

[root@wanghualang ~]# source /etc/profile

第五步测试手动同步,并保持数据一致

[root@wanghualang ~]# mkdir /{test1,test2}

[root@wanghualang ~]# touch /test1/1

[root@wanghualang ~]# rsync -av /test1/ /test2/ --delete

第六步 测试实时同步,并保持数据一致

[root@wanghualang ~]# vim auto_rsync.sh

#!/bin/bash

#源目录

SOURCE_DIRECTORY="/test1/"

#备份目录

BACKUP_DIRECTORY="/test2/"

#源目录中的文件发生创建、修改、移动、删除操作时将自动触发同步备份目录,且备份目录与源目录数据保持一致

inotifywait -mrq -e create,modify,move,delete $SOURCE_DIRECTORY | while read file

do

rsync -a $SOURCE_DIRECTORY $BACKUP_DIRECTORY --delete

done

[root@wanghualang ~]# sh auto_rsync.sh &

[root@wanghualang ~]# touch /test1/a

[root@wanghualang ~]# ls /test2/

[root@wanghualang ~]# echo "1">/test1/a

[root@wanghualang ~]# cat /test2/a

[root@wanghualang ~]# mv /test1/a /test1/b

[root@wanghualang ~]# ls /test2/

[root@wanghualang ~]# rm -f /test1/*

[root@wanghualang ~]# ls /test2/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值