Linux O & M and architecture-rsync and linux-rsync

Source: Internet
Author: User
Tags rsync scp command

Linux O & M and architecture-rsync and linux-rsync

1. rsync Introduction

Rsync is a tool for Synchronous backup of full and incremental local or remote data images

 

Common rsync Command Parameters
Command parameter description-a (-- archive) archive mode indicates that the file is transmitted recursively, and all file attributes are maintained, which is equal to rtopgDl-v (-- verbose) to display the output process, transfer Progress and other information-z (-- compress) compression during transmission to improve transmission efficiency -- exclude =/etc/hosts specifies to exclude unnecessary File Information (same as the tar parameter) -- exclude-from = directory file where the file name is located, multiple files can be excluded (same as the tar parameter) -- bwlimit = PATE limit I/O bandwidth; KBytes per second limit socket I/O bandwidth Speed limit Function -- delete keeps the target directory consistent with the source directory, and synchronizes data without any difference

 

2. rsync features

① Special files such as soft links and devices can be copied.

② Excluding the synchronization of specified files or directories is equivalent to the tar exclusion function of the packaging command.

③ Keep the permissions, time, hard links, owner, group, and other attributes of the original file or directory unchanged

④ Implement incremental synchronization and only synchronize the changed data, resulting in high transmission efficiency

⑤ You can use rcp, rsh, ssh, and other methods to transfer files.

⑥ File and data can be transmitted through socket (process mode)

7. Support anonymous authentication process transmission to facilitate secure data backup

3. rsync application scenarios

① Use scheduled tasks + rsync to synchronize data at regular intervals. The main synchronized data information is used by internal staff of the website.

② Use real-time synchronization software + rsync to synchronize data in real time. The main synchronized data information is the data uploaded by website users.

4. rsync Data Transmission Mode

① Data transmission between hosts (similar to the cp command function)

② Use rcp, ssh, and other channels to transmit data (similar to the scp command function)

③ Transmit data through a daemon (socket) (this is an important function of rsync itself ).

5. rsync daemon-Server Configuration

1. Check whether rsync software is installed in the system.

rpm -qa rsyncrsync-3.0.6-12.el6.x86_64

2. rsync multi-module master configuration file

cat >/etc/rsyncd.conf<<EOF#rsync server##created by yanxinjiang 2017-8-1##rsyncd.conf start##uid = rsyncgid = rsyncuse chroot = nomax connections = 200timeout = 300pid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog file = /var/log/rsyncd.logignore errorsread only = falselist = falsehosts allow = 172.16.1.0/24hosts deny = 0.0.0.0/32auth users = rsync_backupsecrets file = /etc/rsync.password[backup]path = /backup[nfsbackup]path = /nfsbackupEOF

3. Create backup directories and authorize management users

mkdir /backup -pchown -R rsync.rsync /backup/useradd rsync -s /sbin/nologin -M

4. Create an rsync server and client identity authentication File

echo "rsync_backup:123456" >/etc/rsync.passwordchmod 600 /etc/rsync.password

5. Start the rsync service.

[root@backup ~]# rsync --daemon[root@backup ~]# lsof -i:873COMMAND   PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAMErsync   31209 root    3u  IPv4 7505812      0t0  TCP *:rsync (LISTEN)rsync   31209 root    5u  IPv6 7505813      0t0  TCP *:rsync (LISTEN)
6. rsync Daemon-client Configuration

1. Create and authorize the client identity authentication File

[root@nfs01 ~]# echo "123456" >/etc/rsync.password[root@nfs01 ~]# chmod 600 /etc/rsync.password

2. Test the rsync service on the client.

[root@nfs01 ~]# rsync -avz /etc/hosts rsync_backup@172.16.1.41::backup --password-file=/etc/rsync.passwordsending incremental file listsent 26 bytes  received 8 bytes  3.24 bytes/sectotal size is 314  speedup is 9.24

3. No difference in rsync Data Synchronization

Client push
[Root @ nfs01 data] # ls/data/a B c d e f g pull.txt [root @ nfs01 data] # rsync-avz/data -- delete rsync_backup@172.16.1.41 :: backup -- password-file =/etc/rsync. passwordsending incremental file listdata/data/adata/bdata/c

Server check

[Root @ backup] # ls/backup/data/

A B c d e f g pull.txt

3. Client push Problems

Error 1[Root @ nfs01 ~] # Rsync-avz/etc/hosts rsync_backup@172.16.1.41: backupPassword: @ ERROR: auth failed on module backuprsync error: error starting client-server protocol (code 5) at main. c (1503) [sender = 3.0.6]Error 2[Root @ nfs01 tmp] # rsync-avz/etc/hosts rsync_backup@172.16.1.41:/backupERROR: The remote path must start with a module name not a/rsync error: error starting client-server protocol (code 5) at main. c (1503) [sender = 3.0.6]Error 3[Root @ nfs01 tmp] # rsync-avz/etc/hosts rsync_backup@172.16.1.41: backup @ ERROR: Unknown module 'backup 'rsync error: error starting client-server protocol (code 5) at main. c (1503) [sender = 3.0.6]Error 4[Root @ nfs01 tmp] # rsync-avz/etc/hosts rsync_backup@172.16.1.41: backupPassword: sending incremental file listhostsrsync: mkstemp ". hosts.5z3AOA" (in backup) failed: Permission denied (13)

4. Summary of errors

① Incorrect password and incorrect virtual user name

② Secrets file =/etc/rsync. The password file specified by password is different from the actual password file name

③ The/etc/rsync. password File Permission is not 600

④ Rsync_backup: 123456 the password configuration file should be followed by no space

⑤ Enter only the password information in the rsync client password file. Do not enter the virtual authentication user name.

6. During push, the module name backup is followed by a double colon instead of the path/backup

7. telnet to connect to port 873 of the rsync service IP address and check whether the service starts telnet 172.16.1.41 873.

The owner and group of the shared directory are incorrect, not rsync. the permission of the shared directory is incorrect, not 755

7. How the rsync client accesses the server

 

 

Related Article

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.