Rsync Synchronization Service installation configuration and script usage

Source: Internet
Author: User

Rsync It is an application software under Unix/linux, it can keep multiple server data synchronization consistency, rsync will copy the whole content on the first synchronization, but only the modified files are transmitted the next time.

Rsync in the process of transmitting data, it is possible to compress and Unzip operation, so you can use less bandwidth. can easily do to keep the original file permissions, time, soft and hard links. Rsync has two synchronization methods, one based on SSH synchronization does not need to configure, a need for their own key synchronization needs to file configuration. The following is the way I use my own secret key: The majority of enterprises

  1. Rsync installation

    Experiment two virtual machines: Server 192.168.2.222, client 192.168.2.183

    Easy to experiment, I use Yum installation method here: Yum Install rsync-y

  2. I am here to customize the rsync configuration directory mkdir/home/lijq/.rsync/-p; Create configuration file Add the following VI rsyncd.conf;

    UID = nobody
    GID = Nobody
    Use chroot = no
    Max connections = 30
    PID file =/home/lijq/.rsync/rsyncd.pid
    Lock file =/home/lijq/.rsync/rsyncd.lock
    Log file =/home/lijq/.rsync/rsyncd.log
    Transfer logging = yes
    Log format =%t%a%m%f%b
    Syslog facility = Local3
    Timeout = 300
    [Test1]
    Read Only = no
    Path =/data/www
    Comment = www
    Auth users = Test
    Secrets file =/home/lijq/.rsync/rsync.pas
    Hosts allow = 192.168.2.183

  3. Cd/home/lijq/.rsync; Create Rsync.pas key file test:123456 and give permissions chmod 666 Rsync.pas

  4. Then start the service, I am here to customize the configuration path and port all start commands for the following:

    /usr/bin/rsync--daemon--config=/home/lijq/.rsync/rsyncd.conf--port 7001

    Using Ps-ef | grep rsync to view service startup conditions

  5. Client configuration, only need to create Rsync.pas password file content 123456 under cd/home/lijq/.rsync/and give 600 permissions

  6. Then create the server-side synchronization directory, the above configuration file is defined by the/data/www

  7. Client execution Rsync-ap--delete [email protected]:: TEST1/ROOT/LIJQ--port=7001--password-file=/home/lijq/.rsy Nc/rsync.pas

  8. The above command is the contents of the client Synchronization server file,/ROOT/LIJQ for the client directory can be defined by itself, the port is my own definition, test1 is my service-side definition of the synchronization module name

  9. If error @error:auth failed on module test1 Please check the key profile, if error: rsync:failed to connect to 192.168.2.222:no the route to host (113) Please check Firewalls and selinux, bloggers suffer

  10. After the synchronization command executes, it is found that the/data/www/files on the server are synchronized to the client/ROOT/LIJQ below, and the done

Two. The above client performs the command synchronization is the server directory file synchronization to the client to the equivalent of backup, and many enterprises are from the client to update the data to the service side therefore: You can execute the following command on the client.

/usr/bin/rsync-avzp--progress--delete--password-file=rsyncd1.pas--port=7001/root/lijq/ [email protected] :: Test1 Rsyncd1.pas is a key file that I created in the current directory, or it can be written as the previous path.

If the error is rsync Error:some files/attrs were not transferred (see previous errors) (code) at MAIN.C (1039) [sender=3.0.6] Check the service End Directory Permissions other users should have write permission Oh, done

Script Implementation synchronization: Here the script is the client data synchronization to the server side, the other can be defined by themselves:

#!/bin/bash#use for:sh 33.sh test serversysuser=testexport mokuai=test1export port=7001src_dir=/root/lijq/serverip= 192.168.2.222serverno=$1case "$" intest) echo ${rsyncsource%/*};; Server)/usr/bin/rsync-avzp--progress--delete--password-file=rsyncd1.pas--port=${port $SRC _dir [email protected]$ ServerIP:: $MOKUAI;; Esac

Done

Follow-up research continues to update

This article is from the "Fluffy Duck" blog, please be sure to keep this source http://woshitieren.blog.51cto.com/2466034/1679226

Rsync Synchronization Service installation configuration and script usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.