Rsync Data Synchronization Configuration

Source: Internet
Author: User

Environment configuration

Operating system: Centos6.4_64bit

A server ip:192.168.6.128

b Server ip:192.168.6.129

On a server basis, synchronize the a server files to Server B.

The steps are as follows:

Start configuring a server

1. Install rsync on Server A

TAR-XVF rsync-3.1.1.tar.gz

CD rsync-3.1.1

Configure--prefix=/usr/local/rsync

Make && make install

2. Configuration files

Create a new Rsyncd.config under/etc/(the default/etc/does not have this file) the contents are as follows:

Uid=nobody
Gid=nobody
Use Chroot=no
Max connections=10
Strict Modes=yes
PID File=/var/run/rsyncd.pid
Lock File=/var/run/rsync.lock
Log File=/var/run/rsync.log
[Files]
Path=/data/files #要同步数据的目录
Comment=files
Ignore errors
Read Only=no
Write Only=no
Hosts allows=*
#hosts deny=192.168.6.129
List =false
Uid=root
Gid=root
Auth Users=admin #同步时用的账户
Secrets File=/etc/rsyncserver.pass #密码文件

3,/etc/under the new password file rsyncserver.pass, format: Username:password

Admin:admin

4. Give 600 permissions to the password file

chmod 600/etc/rsyncserver.pass

5. Start Rsync Service

/usr/local/rsync/bin/rsync--daemon--config=/etc/rsyncd.conf

A server configuration is complete!

Start Configuring B Server

1, b Server Installation rsync, method with a server

2, B Server only need to configure password file/etc/rsyncserver.pass, password to the same as a server password, format: password

3. Perform synchronous commands

/USR/LOCAL/RSYNC/BIN/RSYNC-VZRTOPG--delete--progress--exclude "*access*" [Email protected]::files/data/files-- Password-file=/etc/rsyncserver.pass

Description

V: Verbose mode output

Z: The transfer is the compressed processing of the backed up files

R: Recursively processing subdirectories

T: Keep file time information

O: Keep file owner information

P: Keep file permissions information

G: Maintain file group information

--delete: Synchronizing with a server as a benchmark

--progress: Show synchronization process

--exclude: Exclude file types that do not need to be transferred

[Email protected]::files files represents the files module configured in the Rsyncd.config configuration file

/data/files: Indicates that files are synchronized to the local/data/files directory

--password-files: Specifying a password file

Summarize:

Rsync is a full or incremental backup. There are 2 drawbacks to this type of file synchronization:

1, if the new file on the B server, the synchronization command can not be synchronized to a server, that is, the file on the B server is always greater than or equal to the file on the server.

(The--delete parameter is added to the synchronization command, and a file that does not exist on the a server is deleted during execution, and if this parameter is not added, it will not be deleted or synced to the B server)

2, the synchronization command must be made into a script to join the scheduled task, at a specific time to perform synchronous operation, can not be synchronized real-time backup.

To solve the first problem, we need to use unison software.

To solve the second problem, we need to use the rsync+inotify combination

Rsync Data Synchronization 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.