• centos rsync安装配置


    安装

    1
    yum -y install rsync

    ---------------------服务器安装-------------------------------

    创建基础配置文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #vim /etc/rsyncd.conf
      
    uid = root 
    gid = root   
    use chroot = no 
    max connections = 5 
    pid file = /var/run/rsyncd.pid
    lock file = /var/run/rsync.lock 
    log file = /var/log/rsyncd.log  
      
    [www]  
    path = /usr/local/nginx/html/down/ 
    ignore errors    
    read only = true
    list = false        
    auth users = rsync
    secrets file = /etc/rsync.pas

    创建密码配置文件

    1
    2
    #vi /etc/rsync.pas
    rsync:yourpassword

    将rsync.pas设置为root所有, 权限为600

    1
    2
    chown root.root /etc/rsync.pas
    chmod 600 /etc/rsync.pas

    启动:

    1
    /usr/bin/rsync --daemon

    打开防火墙设置873端口:编辑/etc/sysconfig/iptables文件,添加873端口

    关闭selinux:打开/etc/selinux/config文件,修改SELINUX=disabled

    ------------------------------客户端安装-----------------------------------------

    创建基础配置文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    #vim /etc/rsyncd.conf
     
    uid = root  
    gid = root    
    use chroot = no  
    max connections = 5  
    pid file = /var/run/rsyncd.pid 
    lock file = /var/run/rsync.lock  
    log file = /var/log/rsyncd.log   
     
    [www]   
    path = /usr/local/test/
    ignore errors     
    read only = true
    list = false         
    auth users = rsync 
    secrets file = /etc/rsync.pas

    创建密码配置文件

    1
    2
    #vi /etc/rsync.pas
    yourpassword

    将rsync.pas设置为root所有, 权限为600

    1
    2
    chown root.root /etc/rsync.pas
    chmod 600 /etc/rsync.pas

    执行同步命令:

    1
    rsync -vrtup -R --delete rsync@10.10.10.10::www --password-file=/etc/rsync.pas /usr/local/test/

    命令解析:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    -v, --verbose 详细模式输出
    -r, --recursive 对子目录以递归模式处理
    -t, --times 保持文件时间信息
    -u, --update 仅仅进行更新,也就是跳过所有已经存在于DST,并且文件时间晚于要备份的文件。(不覆盖更新的文件)
    -p, --perms 保持文件权限
     
    rsync@10.10.10.10::www
    rsync - 登陆用户名
    10.10.10.10 - 服务器IP
    www - 主配置文件中的段名
    --password-file=/etc/rsync.pas  - 指定密码文件
    /usr/local/test/ - 要同步到的本地目标文件夹

    设置自动运行脚本,每5秒执行一次同步

    1
    2
    3
    4
    5
    6
    7
    #!/bin/bash
     
    while [ 1 ]
    do
    rsync -vrtup -R rsync@10.10.10.10::www --delete --password-file=/etc/rsync.pas /usr/local/nginx/html/down
    sleep 5
    done

    设置脚本自启动:

    在centos5 和 centos6中,方法不太一样。centos6可以参见另一篇文章:

    http://hi.baidu.com/solohac/item/9a89bf4257a97eeaa5c066cd

  • 相关阅读:
    物理分页和逻辑分页扫盲
    JAVA集合操作的利器:CollectionUtils
    关于MYSQL表记录字段换行符回车符处理
    JSONObject依赖包
    Spring Mvc中@ResponseBody中文乱码解决,以及修改返回的Content-Type
    Python运行出错情况
    Python编码相关理解
    Python访问Access数据库
    Python
    android开发(1)
  • 原文地址:https://www.cnblogs.com/solohac/p/4154155.html
Copyright © 2020-2023  润新知