• 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    ##取消变量

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

    完成

  • 相关阅读:
    MAC LAMP环境 php执行使用问题
    centos 服务器 安全设置
    Linux系统发现占用CPU达100%的进程并处理
    git 使用国内镜像 ,查看镜像更改情况
    mac安装composer
    MySql反向模糊查询
    Linux启动或重启网卡
    MAMP环境 nginx配置忽略index.php入口文件
    php 验证码生成 不保存的情况下 缩小图片质量
    KMP字符串模式匹配详解
  • 原文地址:https://www.cnblogs.com/yuan9910/p/13810406.html
Copyright © 2020-2023  润新知