• Rsync文件同步服务器配置


    rsync 是一个Unix/Linux系统下的文件同步和传输工具。rsync是用 “rsync 算法”提供了一个客户机和远程文件服务器的文件同步的快速方法。可以用来做备份或镜像。
    一、配置文件rsyncd.conf
    1. 创建配置目录和文件
    # 在/etc目录下创建一个rsyncd的目录,我们用来存放rsyncd.conf 和rsyncd.secrets文件
    shell> mkdir /etc/rsyncd
    # 创建rsyncd.conf ,这是rsync服务器的配置文件
    shell> touch /etc/rsyncd/rsyncd.conf
    # 创建rsyncd.secrets ,这是用户密码文件
    shell> touch /etc/rsyncd/rsyncd.secrets
    # 为了密码的安全性,我们把权限设为600
    shell> chmod 600 /etc/rsyncd/rsyncd.secrets
    # 服务器欢迎信息
    shell> touch /etc/rsyncd/rsyncd.motd 
    2. 编辑rsyncd.conf
    # This line is required by the /etc/init.d/rsyncd script
    pid file = /var/run/rsyncd.pid   
    port = 873
    address = 192.168.1.201 
    uid = root   
    gid = root   
    use chroot = yes  
    read only = yes  
    #limit access to private LANs
    hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0  
    hosts deny=*
    max connections = 5 
    motd file = /etc/rsyncd/rsyncd.motd
    #This will give you a separate log file
    #log file = /var/log/rsync.log
    #This will log every file transferred - up to 85,000+ per user, per sync
    #transfer logging = yes
    log format = %t %a %m %f %b
    syslog facility = local3
    timeout = 300
    [linuxroot]   
    path = /
    list=yes 
    ignore errors 
    auth users = root
    secrets file = /etc/rsyncd/rsyncd.secrets
    comment = linuxroot
    exclude =   home/
    注:
    (1) address 是服务器IP地址,uid,gid是服务器传输文件发起执行的用户和组
    (2) auth users 认证用户。是必须在服务器上存在的真实的系统用户,以,号隔开多个用户
    (3) path 指定文件目录所在位置
    (4) excude 排除的目录列表
    2. 编辑rsyncd.secrets(用户名:密码)
    root:123123
    3.启动rsync服务器
    shell> /usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf 
    # Linux防火墙是用iptables,所以查看防火墙设置
    shell> iptables -A INPUT -p tcp -m state --state NEW  -m tcp --dport 873 -j ACCEPT
    # 查看一下防火墙是不是打开了 873端口;
    shell> iptables -L 
    二、同步数据
    1. 查看同步数据情况
    #rsync rsync://[认证用户]@[主机]/[模块名]
    shell> rsync rsync://feng2@192.168.1.201/linuxroot
    2. 客户端同步数据:
    客户端创建认证用户密码文件。可以在同步时不用输入密码,也方便crond计划任务。
    # rsync -avzP  --progress --delete [认证用户]@[主机名]::[模块名] [目标路径]
    shell> su
    shell> cd ~
    shell> touch rsync.password 
    shell> chmod 600 rsync.password 
    shell> echo "123123" > rsync.password
    shell> rsync -avzP --progress --delete --password-file=rsync.password root@192.168.1.201::linuxroot /(责任编辑:admin)

    http://www.net527.cn/a/caozuoxitong/Linux/15822.html

  • 相关阅读:
    python 冒泡排序
    数组
    git用法
    Leetcode 344. 反转字符串
    Leetcode 83. 删除排序链表中的重复元素
    【第一部分】01Leetcode刷题
    【C++ Primer | 07】常用算法
    【第一部分】10Leetcode刷题
    【第一部分】09Leetcode刷题
    【第一部分】07Leetcode刷题
  • 原文地址:https://www.cnblogs.com/seasonzone/p/3147687.html
Copyright © 2020-2023  润新知