Linux, rsync configuration for remote transfer large amounts of data between servers
[Tutorial] theme: rsync
[Course record]: E record
【main content】
[1] describes the rsync
Rsync (Remote Synchronize) is a remote data synchronization tool through LAN / WAN quickly synchronize multiple hosts, Rsync is the use of "Rsync algorithm" to achieve synchronization between the local host and the remote host, this algorithm is not every time the whole transmission, only transmit different data between two computers of the backup portion, and therefore very fast.
Rsync the following advantages:
1, the mirror can save the entire directory tree and the file system.
2, it can easily be done to keep the original file permission, time, soft links.
3, without permission to install special envoy.
4, with optimized processes, high file transfer efficiency.
5, may be used Rsh, SSH, etc. to transfer files, of course, also be connected directly via Socket.
6, support for anonymous transfers.
In addition, compared to the SCP, the transmission speed is not a hierarchical level. We often when a large number of local area network using Mysql data transfer Rsync and SCP, found Rsync at least 20 times faster or more than Scp, so if you need to pass each other in massive data between Linux / Unix servers, Rsync is a very good choice.
[2] rsync server mode
First check whether rsync installed:
rpm –q rsync
rsync-2.6.8-3.1
DESCRIPTION rsync is installed, if the package rsync is not installed prompted the description of the software is not installed you can use the newspaper to install yum
In addition, turn off the firewall and SElinux, because it is transmitted within the network, so they do not need to
service iptables stop && chkconfig iptables off
setenforce 0
Profile /etc/rsyncd.conf. This file is your own definition, is not created by the system, of course, you can call different names, on the back of write detailed notes.
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.0/255.255.255.0
auth users = test
secrets file = /etc/rsyncd.password
Comment:
uid = nobody
Users to back up, nobody is any user
gid = nobody
Backup group, nobody is any group
use chroot = no
If "use chroot" is specified as true, then rsync to transfer files first before chroot path to the next parameter specified directory. The reason for this is to achieve additional security, but the drawback is the need to root privileges, and can not back up files to a directory outside of the symbolic link points to. chroot is true by default, but generally do not need this, I chose no or false
list = no
Do not allow a list of columns
max connections = 200
Maximum number of connections
timeout = 600
Covering customer-specific IP timeout, that is to say rsync server will not wait forever for a client crash.
pidfile = /var/run/rsyncd.pid
Pid file storage location
lock file = /var/run/rsync.lock
Lock file storage location
log file = /var/log/rsyncd.log
Location for the log file
[backup]
Here is an authentication module name, that is, with samba grammar, is the name announced
path = /backup/
Here is involved in directory synchronization
ignore errors
You can ignore IO errors unrelated
read only = no
It allows read and write
list = no
Do not allow a list of columns
hosts allow = 192.168.1.0/255.255.255.0
Here with samba syntax is the same, only allows a network segment 192.168.21.0/24 synchronize, rejected all other
auth users = test
Authentication username
secrets file = /etc/rsyncd.password
Password file storage address
note:
1, [backup] Authentication module name and path = / backup / directory synchronization participation
path we have to remember here is good, not just a set of directly bin here, you know there is an authentication module, and later from the client backup data is stored here.
2, auth users = redhat authenticated user name
The name is a server-side real presence of the user, but we should not go overlooked this point directly with the steps. If the server less of this, then I guess you will not achieve data synchronization, we have to keep in mind.
3, path = / backup / synchronize directories participation
Later this need they have to build their own under the root directory
cd /
mkdir backup
chmod –R 777 /backup
echo “test:test” > /etc/rsync.password
(Here I set the same user name and password)
To be safe, I set him permission to 600
chmod 600 /etc/rsync.password
Boot configuration
[root@test rsync-3.0.4]# vim /etc/xinetd.d/rsync
配置rsync servervi /etc/xinetd.d/rsync
将disable=yes改为no
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root @ the Test Home] # /etc/init.d/xinetd restart
Stopping xinetd: [the OK]
Starting xinetd: [the OK]
if xinetd not, you need to install it
[root @ the Test Home] # yum -y install xinetd
RSYNC Service Both methods start the end:
start rsync server (independent start)
[root @ the Test Home] # / usr / bin / rsync --daemon ON
Start rsync server (xinetd super process has started)
[root @ the Test Home] # /etc/init.d/xinetd reload
Rsync configured to start automatically
[root @ the Test etc] # chkconfig rsync ON
[root @ the Test etc] # chkconfig --list rsync
rsync
Rc.local added
in a variety of operating systems, different file location RC can be modified so that when the system starts loading into the rsync --daemon.
[root @ the Test Home] # vi /etc/rc.local
/ usr / local / rsync -daemon add a line #
Client Configuration:
echo “test” > /etc/rsyncd.password
Here only need a password, the user is not required, so even when you want to sync manually Interactive
chmod 600 /etc/rsync.password
Testing: The following represents the delete command to delete the target directory exists and does not exist in the source file
rsync -vzrtop --delete /home/ce [email protected]::backup --password-file=/etc/rsyncd.password
Download a file from the server a: Packing, v: details, z compressed
rsync -avz --password-file=/etc/rsyncd.password [email protected]::backup /home/
Upload up from the local to the server
rsync -avz --password-file=/etc/rsyncd.password /home [email protected]::backup
[3] rsync client mode
Common: rsync -av
Download: rsync [parameters] remote file (remote path) local directory
Upload: rsync [parameters] remote directory local file
rsync common parameters
If no interactive operation, rsync can usually work as scp, rsync following parameters commonly used.
Examples: rsync -av [email protected]: /home/test/3.txt.
It said it would file replication service /home/test/3.txt 192.168.1.122 to the current directory of which this client. "" Indicates the current directory
-a, --archive filing mode, transfer files recursively expressed, and maintaining all file attributes, equal -rlptgoD
-v --verbose: Detail mode output
-r --recursive: subdirectories process to return mode.
-p --perms: keep the file permissions
-o --owner: keep the file owner information
-g --group: keep the file group information
-t --times: keep the file time information
--delete: delete what exists in DST SRC does not exist in the file or directory
--delete-excluded: also deletes the files which receives the discharge end of the development option
-z --compress: backup file compression processing in the transmission
--exclude = PATTERN: developing negative file transfer does not require
--include = pATTERN: formulation does not exclude the need to transfer files
--exclude-from = fILE: fILE file developed negative pattern
--include-from = fILE: the formulation does not exclude fILE file pattern matching
----------------------------------------------------------------------
Description: This is the theory will do the same, because any server can connect remotely, then just know the ip, user name, password, you can enter the server, you can view the file server
Of course, you can copy this down, another server can then log in, so you can be the most original source server to copy files locally, and then upload it to another server, rsync, the equivalent of eliminating the need for an intermediate step
The file server is the direct source of spread to another server, you need to configure the next course, there are two ways
The first: server mode, you need to configure a server as a server (server pretending to be seen as, in fact, are two servers), and then configure a bakup file, configure a user name and password, designed to be remotely connected
If the professional point, backup is called authentication module, the user name and password file is called certification documents, then the client also need to configure a user's password is the key corresponding to the source server, and then in the process of transmission
The user is set, ip parameter, the equivalent source server the user name, password, ip have, so it can be transmitted
Transfer: https: //www.cnblogs.com/sengling/p/5281481.html
[Tutorial] theme: rsync
[Course record]: E record
【main content】
[1] describes the rsync
Rsync (Remote Synchronize) is a remote data synchronization tool through LAN / WAN quickly synchronize multiple hosts, Rsync is the use of "Rsync algorithm" to achieve synchronization between the local host and the remote host, this algorithm is not every time the whole transmission, only transmit different data between two computers of the backup portion, and therefore very fast.
Rsync the following advantages:
1, the mirror can save the entire directory tree and the file system.
2, it can easily be done to keep the original file permission, time, soft links.
3, without permission to install special envoy.
4, with optimized processes, high file transfer efficiency.
5, may be used Rsh, SSH, etc. to transfer files, of course, also be connected directly via Socket.
6, support for anonymous transfers.
In addition, compared to the SCP, the transmission speed is not a hierarchical level. We often when a large number of local area network using Mysql data transfer Rsync and SCP, found Rsync at least 20 times faster or more than Scp, so if you need to pass each other in massive data between Linux / Unix servers, Rsync is a very good choice.
[2] rsync server mode
First check whether rsync installed:
rpm –q rsync
rsync-2.6.8-3.1
DESCRIPTION rsync is installed, if the package rsync is not installed prompted the description of the software is not installed you can use the newspaper to install yum
In addition, turn off the firewall and SElinux, because it is transmitted within the network, so they do not need to
service iptables stop && chkconfig iptables off
setenforce 0
Profile /etc/rsyncd.conf. This file is your own definition, is not created by the system, of course, you can call different names, on the back of write detailed notes.
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.0/255.255.255.0
auth users = test
secrets file = /etc/rsyncd.password
Comment:
uid = nobody
Users to back up, nobody is any user
gid = nobody
Backup group, nobody is any group
use chroot = no
If "use chroot" is specified as true, then rsync to transfer files first before chroot path to the next parameter specified directory. The reason for this is to achieve additional security, but the drawback is the need to root privileges, and can not back up files to a directory outside of the symbolic link points to. chroot is true by default, but generally do not need this, I chose no or false
list = no
Do not allow a list of columns
max connections = 200
Maximum number of connections
timeout = 600
Covering customer-specific IP timeout, that is to say rsync server will not wait forever for a client crash.
pidfile = /var/run/rsyncd.pid
Pid file storage location
lock file = /var/run/rsync.lock
Lock file storage location
log file = /var/log/rsyncd.log
Location for the log file
[backup]
Here is an authentication module name, that is, with samba grammar, is the name announced
path = /backup/
Here is involved in directory synchronization
ignore errors
You can ignore IO errors unrelated
read only = no
It allows read and write
list = no
Do not allow a list of columns
hosts allow = 192.168.1.0/255.255.255.0
Here with samba syntax is the same, only allows a network segment 192.168.21.0/24 synchronize, rejected all other
auth users = test
Authentication username
secrets file = /etc/rsyncd.password
Password file storage address
note:
1, [backup] Authentication module name and path = / backup / directory synchronization participation
path we have to remember here is good, not just a set of directly bin here, you know there is an authentication module, and later from the client backup data is stored here.
2, auth users = redhat authenticated user name
The name is a server-side real presence of the user, but we should not go overlooked this point directly with the steps. If the server less of this, then I guess you will not achieve data synchronization, we have to keep in mind.
3, path = / backup / synchronize directories participation
Later this need they have to build their own under the root directory
cd /
mkdir backup
chmod –R 777 /backup
echo “test:test” > /etc/rsync.password
(Here I set the same user name and password)
To be safe, I set him permission to 600
chmod 600 /etc/rsync.password
Boot configuration
[root@test rsync-3.0.4]# vim /etc/xinetd.d/rsync
配置rsync servervi /etc/xinetd.d/rsync
将disable=yes改为no
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
[root @ the Test Home] # /etc/init.d/xinetd restart
Stopping xinetd: [the OK]
Starting xinetd: [the OK]
if xinetd not, you need to install it
[root @ the Test Home] # yum -y install xinetd
RSYNC Service Both methods start the end:
start rsync server (independent start)
[root @ the Test Home] # / usr / bin / rsync --daemon ON
Start rsync server (xinetd super process has started)
[root @ the Test Home] # /etc/init.d/xinetd reload
Rsync configured to start automatically
[root @ the Test etc] # chkconfig rsync ON
[root @ the Test etc] # chkconfig --list rsync
rsync
Rc.local added
in a variety of operating systems, different file location RC can be modified so that when the system starts loading into the rsync --daemon.
[root @ the Test Home] # vi /etc/rc.local
/ usr / local / rsync -daemon add a line #
Client Configuration:
echo “test” > /etc/rsyncd.password
Here only need a password, the user is not required, so even when you want to sync manually Interactive
chmod 600 /etc/rsync.password
Testing: The following represents the delete command to delete the target directory exists and does not exist in the source file
rsync -vzrtop --delete /home/ce [email protected]::backup --password-file=/etc/rsyncd.password
Download a file from the server a: Packing, v: details, z compressed
rsync -avz --password-file=/etc/rsyncd.password [email protected]::backup /home/
Upload up from the local to the server
rsync -avz --password-file=/etc/rsyncd.password /home [email protected]::backup
[3] rsync client mode
Common: rsync -av
Download: rsync [parameters] remote file (remote path) local directory
Upload: rsync [parameters] remote directory local file
rsync common parameters
If no interactive operation, rsync can usually work as scp, rsync following parameters commonly used.
Examples: rsync -av [email protected]: /home/test/3.txt.
It said it would file replication service /home/test/3.txt 192.168.1.122 to the current directory of which this client. "" Indicates the current directory
-a, --archive filing mode, transfer files recursively expressed, and maintaining all file attributes, equal -rlptgoD
-v --verbose: Detail mode output
-r --recursive: subdirectories process to return mode.
-p --perms: keep the file permissions
-o --owner: keep the file owner information
-g --group: keep the file group information
-t --times: keep the file time information
--delete: delete what exists in DST SRC does not exist in the file or directory
--delete-excluded: also deletes the files which receives the discharge end of the development option
-z --compress: backup file compression processing in the transmission
--exclude = PATTERN: developing negative file transfer does not require
--include = pATTERN: formulation does not exclude the need to transfer files
--exclude-from = fILE: fILE file developed negative pattern
--include-from = fILE: the formulation does not exclude fILE file pattern matching
----------------------------------------------------------------------
Description: This is the theory will do the same, because any server can connect remotely, then just know the ip, user name, password, you can enter the server, you can view the file server
Of course, you can copy this down, another server can then log in, so you can be the most original source server to copy files locally, and then upload it to another server, rsync, the equivalent of eliminating the need for an intermediate step
The file server is the direct source of spread to another server, you need to configure the next course, there are two ways
The first: server mode, you need to configure a server as a server (server pretending to be seen as, in fact, are two servers), and then configure a bakup file, configure a user name and password, designed to be remotely connected
If the professional point, backup is called authentication module, the user name and password file is called certification documents, then the client also need to configure a user's password is the key corresponding to the source server, and then in the process of transmission
The user is set, ip parameter, the equivalent source server the user name, password, ip have, so it can be transmitted