Centos下用inotify+rsync实现自动同步功能

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lierwang2017/article/details/78728356

一、安装inotify-tools

   下载地址: https://nchc.dl.sourceforge.net/project/inotify-tools/inotify-tools/3.13/inotify-tools-3.13.tar.gz,下载完成后上传至/usr/local/

    解压

    # tar -xvf  inotify-tools-3.13.tar.gz 

    开始安装

    # cd inotify-tools-3.13

    # ./configure

    # make && make install

二、安装rsync

    查看是否已安装

    # rpm qa|grep rsync*

    如果带有此软件,请先用rpm-e将这些软件干掉,命令如下:

    #rpm -e rsync*此处为你的包名,即上面查询出来的名字)

    如果在删除的过程中提示因为一些依赖关系无法删除,请用如下命令:

    #rpm -e --nodeps rsync*

    

    软件包安装

    # sudo apt-get install rsync 注:在debian、ubuntu等在线安装方法;

    #yum install rsync注:Fedora、Redhat等在线安装方法;

    #rpm -ivh rsync注:Fedora、Redhat等rpm包安装方法;

    其它Linux发行版,请用相应的软件包管理方法来安装。

    

    源码包安装

    # tar xvf rsync-xxx.tar.gz

    # cd rsync-xxx

    # ./configure --prefix=/usr ; make ; make install 

    注:在用源码包编译安装之前,您得安装gcc等编译开具才行;

    本文我使用的是源码包安装,软件包rsync-3.1.2.tar.gz,下载地址: https://download.samba.org/pub/rsync/

    上传安装包至/usr/local,然后解压

    开始安装

    # cd rsync-3.1.2

    # ./configure --prefix=/usr ;

    # make

    # make install

    此时以安装完成,这里对配置文件的详细配置不做描述(有特殊要求可以配置,目前可以满足同步需求)

  

三、同步脚本

     

四、开启监控

   shell脚本命名test.sh,用root账号执行# chmod 777 test.sh

   执行脚本# ./test.sh &

    测试同步功能,成功!

猜你喜欢

转载自blog.csdn.net/lierwang2017/article/details/78728356