• rsync实现同步


    一、备份客户端:

    1.创建/etc/rsyncd.secrets 权限配置600 (写服务器端的账户密码)

    2.客户端配置文件:

    port=873
    log file=/var/log/rsync.log
    pid file=/var/run/rsync.pid
    hosts allow =172.16.16.231
    hosts deny=*

    [backup]           
    path=/databackup                (本机的备份用的文件夹)
    use chroot=yes 
    max nonections=4
    read only=no
    list=yes
    uid=root
    gid=root
    #auth users=root
    secrets file=/etc/rsyncd.secrets

    启动rsync :  rsync --daemon --config=/etc/rsyncd.conf

    备份服务端

    创建/etc/rsyncd.secrets 权限配置600 (写服务器端的账户密码)

    服务端配置文件:

    port=873
    log file=/var/log/rsync.log
    pid file=/var/run/rsync.pid
    hosts allow=172.16.16.160
    hosts deny=*
    [abc]
    path=/databakup                  (本机的要备份用的文件夹)
    use chroot=yes
    max nonections=4
    read only=no
    list=yes
    uid=root
    gid=root
    auth users=root
    secrets file=/etc/rsyncd.secrets

    安装inotify

    1)、1234 tar-zxvf inotify-tools-3.14.tar.gz
    2)、cdinotify-tools-3.14
    3)、./configure--prefix=/usr/local/inotify
    4)、make;makeinstall

    同步脚本:

    #!/bin/bash
    SRC=/databakup/exam
    SRC2=/databkup/dspbak
    #SRC=/test/test1
    #SRC2=/test/test2
    HOST=172.16.16.160
    /usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $SRC | while read files
    do
    /usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd.secrets $SRC root@$HOST::backup
    done
    ~

    备份一个文件只能写一条语句

    [root@web ~]# chmod u+x /root/shell/rsync.sh

    [root@web ~]# setsid /root/shell/rsync.sh &

    #后台运行脚本,关闭shell终端继续后台运行

    rsync.sh脚本加入开机启动项

    # echo "/root/shell/rsync.sh" >> /etc/rc.local

    防火墙开启rsync端口:873

    添加:

    iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -jACCEPT

    防火墙这关要慎重,有些服务器是不允许打开的

    重启:

    # /etc/init.d/iptables restart

  • 相关阅读:
    Exception: Failed to execute 'setItem' on 'Storage'
    element ui中动态添加的表单进行验证
    10. 自定义assertThat中的Matcher函数lt、gt
    8. anyInt()、anyString()、eq()、anyCollection()、verify验证void方法
    7. 参数匹配:eq、isA、any
    6. spy
    4-5. when-thenXX、doXX-when、Answer、thenCallRealMethod
    2. 开启Mock的三种方式、深度Mook
    1. quickstart
    Sentinel
  • 原文地址:https://www.cnblogs.com/jtlin/p/6023700.html
Copyright © 2020-2023  润新知