Ubuntu next multi-server rsync synchronous Mirror service configuration

Source: Internet
Author: User
Tags custom name rsync

Primary server: 192.168.5.13_ubuntu

From server: 192.168.5.11_centos

================== 1> is installed on both hosts separately rsync===================

Ubuntu installation is as follows:

    1. # Apt-get Install rsync

Compile and install: Download this free software

rsync.samba.org/or Samba.anu.edu.au/rsync

Go to the official website to download the latest version

Perform #./configure && make && make install after extracting into directory

The normal situation is soon installed, rsync Server installation is relatively simple, but we installed the rsync, and did not find the configuration file and Rsync Server launcher, because each administrator may be different for rsync, so the general release is just install the software is finished, Let the administrator set up the rsync server on their own use and direction.

=====================2> rsync Server Configuration =====================

In the/etc directory to create a RSYNCD directory, we used to store rsyncd.conf,rsyncd.secrets and RSYNCD.MOTD files;

Rsyncd.conf is the main configuration file of Rsync server;

Rsyncd.secrets is the user password file;

RSYNCD.MOTD Configure some service welcome and description information;

A> Creating Modifications rsyncd.conf

Rsyncd.conf is the main configuration file of Rsync server, we have a simple example, for example, we want to back up the/tmp/directory on the server, in/tmp/, I want to exclude the test directory and test.php file;

zhouda# cd/etc
zhouda# mkdir RSYNCD
zhouda# CD RSYNCD
zhouda# VI rsyncd.conf

Write (Ensure that there are no spaces in each line of the file):

PID file =/var/run/rsyncd.pidport = 873address = 192.168.5.13#uid = Nobody#gid = Nobodyuid = Rootgid = RootUse chroot = y Esread only = Yes#limit access to private lans# sets accessible hosts: If multiple IPs are separated by spaces: 192.168.5.3 192.168.5.4 192.168.5.5 or set interval 192.168.5.3/5hosts allow=192.168.5.11 192.168.5.14hosts Deny=*max connections = 5MOTD file =/etc/rsyncd/rsyncd.motd# This would give you a separate log filelog file =/var/log/rsync.log#this would log every file transferred-up to 85,000+ p Er user, per synctransfer logging = yeslog format =%t%a%m%f%bsyslog facility = Local3timeout = 300# square brackets Set the module name [Linuxsir Home] #要同步服务器的目录路径path =/www/list=yesignore Errors#auth Users is a real system user that must exist on the server, if you want to use more than one user, it is separated by a number, for example auth users = Roger,linuxsirauth users = roger# access required password files from the server secrets file =/etc/rsyncd/rsyncd.secretscomment = Linuxsir tmp# Set the unsynchronized directory or file to be separated by a space exclude = test/test.php

b> Create a Change password file rsyncd.secrets

    1. Zhouda#cd/etc/rsyncd
      Zhouda#vi rsyncd.secrets

Write:

    1. Roger:roger

Exit save.

Permissions to modify permissions for password files:

    1. Zhouda#chmod rsyncd.secrets

C> Creating a modified RSYNC.MOTD file

RSYNCD.MOTD is the user login information that defines the RYSNC server information. For example, let the user know who this server is to provide, and so on, like FTP server login, we see the linuxsir.org FTP
......。 Of course, this is not required when defining variables globally, you can use the # number to drop it, or delete it, for example:

    1. Zhouda#vi RSYNCD.MOTD

Write:

    1. welcome!

===================== 3> start rsync service =======================

    1. Zhouda#/usr/bin/rsync--daemon--config=/etc/rsyncd/rsyncd.conf

============ 4> master server is already configured rsync! Below we set the ============ from the server

Just install rsync from the server, and if not installed, yum install rsync and then run:

    1. zhouda#/USR/BIN/RSYNC-VZRTOPG--progress [email protected]::linuxsirhome/tmp

#因为没有指定密码文件, so you need to manually enter the password set on the master server

Enter Password: Roger

Roger is the user name in the specified password file.

:: Linuxsirhome represents the module name set in rsyncd.conf

/TMP is from the server directory (192.168.5.11/TMP)

To this end, rsync synchronization between the two hosts of Rsync (192.168.5.11/tmp and 192.168.5.14/TMP) has been configured, as long as you enter the password from the server to perform the above command to synchronize.

Note: The V in-VZRTOPG in the command line below is verbose,

Z is a compressed transmission,

R is recursive,

TOPG are the parameters that preserve the original attributes of the file, such as owner and time.

U is to synchronize only the files that have been updated, to prevent the files that are not updated from being updated again, but note the synchronization of the clocks of the two machines.

--progress means to show detailed progress,

--delete means that if the server side deletes the file, then the client also deletes the file accordingly, maintaining true consistency. After the [email protected]::linuxsirhome, the linuxsirhome is the module name, which is the/ETC/RSYNCD/ A custom name in rsyncd.conf, Roger is the user name specified in the specified module that can be synchronized. The last/root/www is the directory name that is backed up to local. In this case, you can also use the parameters of-e ssh to establish an encrypted connection.

You can use the –password-file=/root/rsync.pass to specify the password file, so that it can be used in the script without the need to interactively enter the authentication password, it is important to note that this password file permission property to be set to only the main readable.

ZHOUDA#/USR/BIN/RSYNC-VZRTOPG--progress--delete--password-file=/root/rsync.pass [email protected]::linuxsirhome/ Root/www

==================5> set the master-slave server scheduled automatic synchronization ==================

Automatic synchronization to use the Crond service from the server, for the introduction of Crond, please refer to: Linux timed execution system

We create two rsync.sh files and Rsync.pass files from the/root/www directory, which is 192.168.5.11 from the server.

The rsync.sh file is a script file that Crond to execute.

Rsync.pass is the file that holds the master server password.

a> Create rsync.sh file

    1. Zhouda#cd/tmp
    2. Zhouda#vi rsync.sh

Write:

    1. /USR/BIN/RSYNC-VZRTOPG--progress [Email protected]::linuxsirhome/root/www--password-file=/root/www/rsync.pass

Exit save.

b> Creating a rsync.pass password file

    1. Zhouda#vi Rsync.pass

Write:

    1. Roger

Exit Save and Modify permissions:

    1. Zhouda#chmod Rsync.pass
    2. zhouda# chmod 777 rsync.sh

c> Configuring Crond Services

    1. Zhouda#crontab-e

Add a line:

*/1 * * * */root/www/rsync.sh//-sync once per minute

Exit save.

Set up, the first self also executes the next./rsync.sh, to see if it works.

The master server/www directory is updated to/root/www from the server every other minute.

Specific parameters:

  1. -V,--verbose verbose mode output
    -Q,--quiet thin output mode
    -C,--checksum turn on the check switch to force verification of file transfers
    -A,--archive archive mode, which means to transfer files recursively and keep all file attributes equal to-rlptgod
    -R,--recursive subdirectories in recursive mode
    -R,--relative using relative path information
    -B,--backup creates a backup, that is, the old file is renamed to ~filename when the same file name exists for the purpose. You can use the--suffix option to specify a different backup file prefix.
    --backup-dir store backup files (such as ~filename) in the directory.
    -suffix=suffix Defining backup File prefixes
    -U,--update only updates, which is to skip all the files that already exist in DST, and the file time is later than the file to be backed up. (Does not overwrite the updated file)
    -L,--links reserved Soft link
    -L,--copy-links to handle soft links like regular files
    --copy-unsafe-links only copies links to links outside the SRC Path directory tree
    --safe-links ignoring links to the SRC Path directory tree
    -H,--hard-links reserved Hard link
    -P,--perms maintain file permissions
    -O,--owner keep file owner information
    -G,--group keep file group information
    -D,--devices keep device file information
    -T,--times keep file time information
    -S,--sparse special processing of sparse files to save DST space
    -N,--dry-run reality which files will be transmitted
    -W,--whole-file copy files without incremental detection
    -X,--one-file-system do not cross file system boundaries
    -B, the block size used by the--block-size=size test algorithm, is 700 bytes by default
    -E,--rsh=command specifies data synchronization using RSH and SSH
    --rsync-path=path Specify the path information for the rsync command on the remote server
    -C,--cvs-exclude uses the same method as CVs to automatically ignore files to exclude files that you do not want to transfer
    --existing only updates those files that already exist in DST without backing up those newly created files
    --delete Delete those files that are not in the DST SRC
    --delete-excluded also deletes those files that are excluded by the option specified by the Receive side
    --delete-after transfer ends after removal
    --ignore-errors Timely IO errors are also deleted
    --max-delete=num deleting NUM files up to a maximum
    --partial retains files that are not fully transmitted for any reason, to expedite subsequent transmissions
    --force forcibly delete a directory, even if it is not empty
    --numeric-ids does not match the user and group ID of a number to a user name and group name
    --timeout=time IP time-out, in seconds
    -I,--ignore-times do not skip files that have the same time and length
    --size-only when deciding whether to back up a file, just look at the file size regardless of file time
    --modify-window=num determines whether the file is time-stamped with the time Stamp window, which defaults to 0
    -t--temp-dir=dir creating temporary files in Dir
    --compare-dest=dir also compares the files in DIR to determine if a backup is required
    -p equivalent to--partial
    --progress Show Backup process
    -Z,--compress compress the backed-up files during transmission
    --exclude=pattern specify to exclude file modes that do not need to be transferred
    --include=pattern specifies file modes that need to be transferred without exclusion
    --exclude-from=file exclude files in the specified schema in file
    --include-from=file does not exclude files that specify pattern matching
    --version Print version Information
    --address binding to a specific address
    --config=file specify a different configuration file, do not use the default rsyncd.conf file
    --port=port Specify a different rsync service port
    --blocking-io using blocking IO for remote shells
    -stats gives the transfer status of some files
    --progress in the transmission of the real-time transmission process
    --log-format=format specifying the log file format
    --password-file=file get the password from file
    --bwlimit=kbps limit I/O bandwidth, Kbytes per second
    -H,--help display Help information
Category: Linux Tags: rsync, sync, Ubuntu, CentOS

Ubuntu next multi-server rsync synchronous Mirror service configuration

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.