• rsync同步完整配置


    一、需求:

    1、对于分公司访问一些服务器(如工程图纸服务器),如果通过Internet上的VPN访问总是觉得速度慢,毕竟带宽有限,为了解决此问题,可以两地建立同步镜像服务器,分公司可以访问本地的镜像服务器而不用访问总公司的服务器,这样速度问题就解决了。

    2、对于很多服务器,特别是文件服务器,设定一个同步镜像服务器,即可以做到每天备份,同时也可同步一台备份服务器便于集中备份。

    3、不论服务器是windows(新的rsync版本解决了中文字体问题)系统还是Linux系统,都可以使用rsync进行同步

    二、Rsync简介

    rsync是Linux、UNIX系统下的数据镜像备份工具,它的特性如下:

    (1)可以镜像保存整个目录树和文件系统。
    (2)可以很容易做到保持原来文件的权限、时间、软硬链接等等。
    (3)无须特殊权限即可安装。
    (4)优化的流程,文件传输效率高。
    (5)可以使用rcp、ssh等方式来传输文件,当然也可以通过直接的socket连接。
    (6)支持匿名传输。

    三、Rsync服务器端配置(172.16.10.201中case文件夹备份到172.16.10.35)

    1、软件下载:

    rysnc的主页地址为:http://rsync.samba.org/,可以从这里下载rsync的安装软件(对于Linux系统,最好使用源码编译安装)
    安装步骤:
      1)# tar zxvf rsync-3.0.6.tar.gz
      2)# cd rsync-3.0.6
      3)# ./configure --prefix=/opt/app/rsync/
      4)# make 
      5)# make install


    2、配置 172.16.10.201服务器

    rsync服务器的配置文件为/opt/app/rsync/etc/rsyncd.conf,其控制认证、访问、日志记录等等。该文件是由一个或多个模块结构组成。一个模块定义以方括弧中的模块名开始,直到下一个模块定义开始或者文件结束,模块中包含格式为name = value的参数定义。每个模块其实就对应需要备份的一个目录树.

    更改服务器端的配置文件

    添加用户,设定密码,所以同步都设置此密码为了方便维护。
    #/usr/sbin/useradd images
    #passwd ucweb@file

    手动添加目录和配置文件
    #mkdir /opt/app/rsync/etc
    #vim /opt/app/rsync/etc/rsync.conf

    pid file = /var/run/rsync.pid
    lock file=/var/run/rsync.lock
    address = 172.16.10.201 
    port = 873
    uid = root
    gid = root
    use chroot = yes
    read onle = yes

    max connections = 10
    motd file = /opt/app/rsync/etc/rsyncd.motd
    #log file = /var/log/rsync.log
    transfer logging = yes
    log format = %t %a %m %f %b
    syslog facility = local3
    timeout = 300

    [case] 
    path = /opt/case/
    list = yes
    ignore errors
    comment = ucweb-file system
    secrets file = /opt/app/rsync/etc/rsyncucweb.password
    exclude = blank.png ; spinner.gif ; downsimple.png ; rails.png ; WEB-INF/

    [huawb]  (可以添加多个同步文件夹)
    path = /opt/case/huawb/poster
    list = yes
    ignore errors
    comment = ucweb-file system
    secrets file = /opt/app/rsync/etc/rsyncucweb.password
    exclude = blank.png ; spinner.gif ; downsimple.png ; rails.png ; WEB-INF/

    [pic]
    path = /usr/local/pic
    list = yes
    ignore errors
    comment = ucweb-file system
    secrets file = /opt/app/rsync/etc/rsyncucweb.password


    3、更改密码文件
    #touch /opt/app/rsync/etc/rsyncucweb.password
    #echo "images:ucweb@file" > /opt/app/rsync/etc/rsyncucweb.password

    4、更改密码文件的权限
    #chmod 600 /opt/app/rsync/ect/rsyncucweb.password

    5、创建rsyncd.motd文件,框内可以输入任何内容,就是为了同步完成可以看到此显示
    #vim /opt/app/rsync/ect/rsyncd.motd

    ###############################
    #                            #
    #  ucweb file Transmission  #
    #        2013-4-28            #
    ###############################

      _____                &&&&_) )
      /,---<                &&&&&&
      ( )c~c~~@~@            )- - &&
        C  >/                <  |&/
        \_O/ -            _`*-'_/ /
      ,- >o<-.              / ____ _/
      /  /              / /  _)_)
    / /|  | |           / /  )  |
    |  | |/ /          /    |
      \_  | |_/            \_    |
      /_/`___|_            /_/\____|
        |  | |                    |
        |  | |                  `. )
        |  | |                  / /
        |__|_|_                /_/|
    (____)_)                |\_\_

    6、创建rsyncd.secrets
    #vim /opt/app/rsync/ect/rsyncd.secrets
    images:ucweb@file

    7、启动rsync服务

    /opt/app/rsync/bin/rsync --daemon --config=/opt/app/rsync/etc/rsync.conf

    编辑/etc/rc.d/rc.local,在最后添加,设置开机启动

    /opt/app/rsync/bin/rsync --daemon --config=/opt/app/rsync/etc/rsync.conf

    转自 http://www.linuxidc.com/Linux/2013-06/85781.htm

  • 相关阅读:
    Web后台框架 目录
    C++ 目录
    【花书笔记】线性代数
    【Python数据挖掘概念、方法与实践】
    【统计学习基础】2. Overview of Supervised Learning
    字节与16进制
    【西瓜书】线性模型
    MySQL入门经典
    【机器学习基石】感知机模型
    python:web应用程序
  • 原文地址:https://www.cnblogs.com/perfei/p/5526468.html
Copyright © 2020-2023  润新知