Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure Linux rsync to transfer large amounts of data between servers

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to configure Linux rsync to transfer a large amount of data between servers". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure Linux rsync to transfer large amounts of data between servers.

Rsync configuration of Linux for remote transmission of large amounts of data between servers

[1] introduction to rsync

Rsync (Remote Synchronize) is a remote data synchronization tool, which can quickly synchronize multiple hosts through LAN/WAN. Rsync uses the "Rsync algorithm" to achieve synchronization between the local host and the remote host. This algorithm is not transmitted in whole every time, it only transmits different parts of the data backed up between the two computers, so the speed is quite fast.

The advantages of Rsync are as follows:

1. You can mirror and save the entire directory tree and file system.

2. It is easy to maintain the permission, time, soft link and so on of the original document.

3. It can be installed without the permission of special envoy.

4. It has optimized process and high efficiency of file transfer.

5, you can use Rsh, SSH and other methods to transfer files, of course, you can also connect directly through Socket.

6. Anonymous transmission is supported.

In addition, compared with SCP, the transmission speed is not a hierarchical level. When we are in the local area network, we often use Rsync and SCP to transmit a large amount of Mysql data, and we find that Rsync is at least 20 times faster than Scp, so if you need to transmit huge amounts of data between Linux/Unix servers, Rsync is a very good choice.

[2] rsync server mode

First check to see if rsync is installed:

Rpm-Q rsync

Rsync-2.6.8-3.1

Rsync is installed. If package rsync is not installed is prompted, it means that the software is not installed. You can use yum to install it.

In addition, turn off the firewall and SElinux, which are not necessary because they are transmitted on the intranet.

Service iptables stop & & chkconfig iptables off

Setenforce 0

Configuration file / etc/rsyncd.conf. This file is self-defined, not created by the system, of course, you can also call a different name, followed by a detailed comment.

Uid = nobody

Gid = nobody

User chroot = no

Max connections = 200

Timeout = 600,

Pid file = / var/run/rsyncd.pid

Lock file = / var/run/rsyncd.lock

Log file = / var/log/rsyncd.log

[backup]

Path=/backup/

Ignore errors

Read only = no

List = no

Hosts allow = 192.168.0.0amp 255.255.255.0

Auth users = test

Secrets file = / etc/rsyncd.password

Note:

Uid = nobody

The user who made the backup, and nobody is any user

Gid = nobody

The group for backup. Nobody is any group.

Use chroot = no

If "use chroot" is specified as true, rsync first chroot to the directory specified by the path parameter before transferring the file. The reason for this is to implement additional security, but the disadvantage is that root permissions are required and the directory files pointed to by external symbolic links cannot be backed up. By default, the color value is true. But this is not generally required. I choose no or false.

List = no

Listing is not allowed

Max connections = 200

Maximum number of connections

Timeout = 600,

Overrides the customer-specified IP timeout, which means that the rsync server does not wait forever for a crashed client.

Pidfile = / var/run/rsyncd.pid

The location of the pid file

Lock file = / var/run/rsync.lock

Lock the location of the file

Log file = / var/log/rsyncd.log

The location of the log file

[backup]

Here is the name of the authentication module, that is, like the samba syntax, it is the published name.

Path = / backup/

Here is the directory that participated in the synchronization

Ignore errors

You can ignore some extraneous IO errors

Read only = no

Allow readable and writeable

List = no

Listing is not allowed

Hosts allow = 192.168.1.0 amp 255.255.255.0

The syntax here is the same as that of samba. Only the network segments of 192.168.21.0 and 24 are allowed to be synchronized, and everything else is rejected.

Auth users = test

Authenticated user name

Secrets file = / etc/rsyncd.password

Password file storage address

Note:

1. [backup] Authentication module name and directory where path = / backup/ participates in synchronization

Remember the path here, don't finish it directly with a random setting, you should know that this is the authentication module, and the data backed up from the client will be stored here.

2. Auth users = redhat authenticated user name

The name is that there are real users on the server side, so don't just follow the steps and ignore this. If the server side without this, then I think your data synchronization will not be achieved, we should keep in mind.

3. Path = / backup/ directories participating in synchronization

You need to build this later in the root directory.

Cd /

Mkdir backup

Chmod-R 777 / backup

Echo "test:test" > / etc/rsync.password

(what I set here is the same user name and password.)

To be on the safe side, I set his permission to 600

Chmod 600 / etc/rsync.password

Startup configuration

[root@test rsync-3.0.4] # vim / etc/xinetd.d/rsync

Configure rsync servervi / etc/xinetd.d/rsync

Change disable=yes to no

Service rsync

{

Disable = no

Socket_type = stream

Wait = no

User = root

Server = / usr/bin/rsync

Server_args =-- daemon

Log_on_failure + = USERID

}

[root@test home] # / etc/init.d/xinetd restart

Stopping xinetd: [OK]

Starting xinetd: [OK]

If xinetd does not have it, it needs to be installed.

[root@test home] # yum-y install xinetd

There are two ways to start the RSYNC server:

Start the rsync server (start independently)

[root@test home] # / usr/bin/rsync-- daemon on

Start the rsync server (with xinetd super process started)

[root@test home] # / etc/init.d/xinetd reload

Configure rsync to start automatically

[root@test etc] # chkconfig rsync on

[root@test etc] # chkconfig rsync-- list

Rsync

Join rc.local

In a variety of operating systems, rc files are stored in different locations, which can be modified to load rsync-daemon when the system is started.

[root@test home] # vi / etc/rc.local

/ usr/local/rsync-daemon # add a line

Client configuration:

Echo "test" > / etc/rsyncd.password

All you need here is the password, not the user, so you don't have to interact manually when you synchronize.

Chmod 600 / etc/rsync.password

Test: the following delete indicates the command to delete files that exist in the destination but not in the source directory

Rsync-vzrtop-delete / home/ce test@192.168.0.206::backup-password-file=/etc/rsyncd.password

Download files from the server a: packaging, v: details, z compression

Rsync-avz-- password-file=/etc/rsyncd.password test@192.168.0.206::backup / home/

Upload it locally to the server

Rsync-avz-- password-file=/etc/rsyncd.password / home test@192.168.0.206::backup

[3] rsync client mode

Commonly used: rsync-av

Download: rsync [parameters] remote files (remote path) local directory

Upload: rsync [parameters] local file remote directory

Common parameters of rsync

If interactive operations are not required, rsync can usually work like scp. Here are some common rsync parameters.

Example: rsync-av test@192.168.1.122:/home/test/3.txt.

Means to copy the / home/test/3.txt file of service 192.168.1.122 to the current directory of this client. Represents the current directory

-a,-- archive archiving mode, which means that files are transferred recursively and all file attributes are maintained, which is equal to-rlptgoD

-v-- verbose: verbose mode output

-r-- recursive: handles subdirectories in return mode.

-p-- perms: maintain file permissions

-o-- owner: keep the file owner information

-g-- group: keep filegroup information

-t-- times: keep file time information

-- delete: delete files or directories that exist in DST but not in SRC

-- delete-excluded: also delete the files that are discharged by this option on the receiver.

-z-- compress: compress the backed-up files during transfer

-- exclude=PATTERN: make rules to exclude files that do not need to be transferred

-- include=PATTERN: do not exclude files that need to be transferred

-- exclude-from=FILE: excludes files that develop schemas in FILE

-- include-from=FILE: files that make pattern matches in FILE are not excluded

At this point, I believe you have a deeper understanding of "how to configure Linux rsync to transfer a large amount of data between servers". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 279

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report