zoukankan      html  css  js  c++  java
  • Rsync的环境的搭建及测试

    名称IP
    发起端 192.168.200.114
    同步源 192.168.200.115

    发起端配置

    首先安装Rsync,一般来说系统都已经默认安装

    yum -y install rsync
    rpm -q rsync

    修改配置文件

    vim /etc/rsyncd.conf 
    # /etc/rsyncd: configuration file for rsync daemon mode
    
    # See rsyncd.conf man page for more options.
    
    # configuration example:
    
     uid = nobody        
     gid = nobody
     use chroot = yes
    # max connections = 4
     pid file = /var/run/rsyncd.pid
     log file = /var/log/rsyncd.log
     hosts allow = 192.168.200.0/24
    # exclude = lost+found/
    # transfer logging = yes
    # timeout = 900
    # ignore nonreadable = yes
    # dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
    
     [wwwroot]
            path = /www/html
            comment = ftp export area
            read only = yes
            dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
            auth users = backuper
            secrets file = /etc/rsyncd_users.db
    vim /etc/rsyncd_users.db 
    backuper:pwd123            #用户名:密码
    chmod 600 /etc/rsyncd_users.db 

    开启服务

    rsync -daemon
    netstat -lnpt|grep 873
    tcp        0      0 0.0.0.0:873             0.0.0.0:*               LISTEN      1563/rsync          
    tcp6       0      0 :::873                  :::*                    LISTEN      1563/rsync

    想要停止的话可以根据pid文件

    kill -9 $(cat /var/run/rsync.pid)

    同步源配置

    安装rsync并启动

    yum -y install rsync
    rpm -q rsync
    rsync -daemon

    测试

    发起端:

    mkdir /www/html -p
    touch 1.txt

    同步源:

    rsync -avz rsync://backuper@192.168.200.114/wwwroot/ /root
    Password: 
    receiving incremental file list
    ./
    1.txt
    
    sent 46 bytes  received 103 bytes  2.50 bytes/sec
    total size is 0  speedup is 0.00
    -a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD。
    -v, --verbose 详细模式输出。
    -H, --hard-links 保留硬链结。
    –delete 删除那些DST中SRC没有的文件。
    -z, --compress 对备份的文件在传输时进行压缩处理。
    选项参数

    Rsync免交互

    创建密码文件

    vim /etc/rsync_passwd
    pwd123
    chmod 600 /etc/rsync_passwd
    rsync -avz --password-file=/etc/rsync_passwd rsync://backuper@192.168.200.114/wwwroot /root

    创建密码变量

    export RSYNC_PASSWORD=pwd123
    rsync -avz rsync://backuper@192.168.200.114/wwwroot /root
    unset RSYNC_PASSWORD    ##取消变量

    解决交互问题后就可以写入计划任务了

    完成

  • 相关阅读:
    WPF Path使用Geometry数据
    WPF Uri反射加载XAML
    T4模板生成数据库实体DB First
    Unsatisfied dependency expressed through method 'shirFilter' parameter 0 异常排查
    SpringBoot集成多数据源
    SpringBoot整合Flyway数据库版本管理
    阿里云服务器Docket安装RabbitMQ 3.8.12
    Docker 部署阿里云RocketMQ 4.5.1
    SpringBoot 整合EasyExcel 获取动态Excel列名
    SpringBoot 开发提速神器 Lombok+MybatisPlus+SwaggerUI
  • 原文地址:https://www.cnblogs.com/yuan9910/p/13810406.html
Copyright © 2011-2022 走看看