Rsync learning Records

Source: Internet
Author: User
Tags ssh port
Rsync learns to record rsync server troubleshooting ideas 1. check whether the rsync service configuration file path is correct, the correct default path is/etc/rsyncd. conf2, and check hostallow in the configuration file. Hostdeny: whether the ip address segment allowed by the client is the ip address segment allowed by the client. 3. view the configuration... rsync learns to record rsync server troubleshooting ideas 1. check whether the rsync service configuration file path is correct and the correct default path is/etc/rsyncd. conf 2. View host allow in the configuration file. Host deny: whether the ip address CIDR block allowed by the client is the ip address CIDR block allowed by the client. 3. check whether the path of the path parameter exists in the configuration file and whether the permission is correct (normally the owner and group corresponding to the UID parameter in the configuration file). 4. check whether the rsync service is enabled, run the following command to check whether the ps-f | grep rsync Port has netstat-lnt | grep 873 5. check whether the iptables firewall and selinux are enabled to allow the rsync service to pass, or disable it. 6. check whether the password file configured by rsync on the server has 600 permissions and whether the password file format is correct. 7. if you want to push data, check whether the user in the rsyncd. conf file has the read/write permission on the directory under the module. Start the rsync service to start the rsync service in the form of a daemon: rsync -- daemon # ----- daemon indicates to start the rsync service expansion in the form of a daemon: rsync process parameter options: -- daemon # ----- daemon indicates to start the rsync service as a daemon -- addrss # ----- bind a specified IP address to provide services. -- Config = FILE # --- change the configuration FILE path, instead of the default/etc/rsyncd. conf -- prot = PORT # --- change other PORT numbers to provide services, rather than the default PORT 873. Tip: the above options are used to understand the content, but not many production scenarios are used. Operation Procedure # rsync -- daemon lsof-I tcp: 873 rsync client troubleshooting 1. check whether the password file configured by rsync on the client has 600 permissions and whether the password file format is correct. note: you only need a password, which is consistent with the server password. 2. use telnet to connect to Port 873 of The rsync server IP address and check whether the service is started (you can test whether the server firewall is blocked ). Telnet 192.168.1.1 873 3. when the client executes the command rsync-avzP rsync_backup@192.168.1.1: lianglab/test // -- password-file =/etc/rsync. password: in particular, the double colons at 192.168.1.1: lianglab/test/and the following lianglab are the module names. With the rapid development and popularization of the linux system, the data Image Backup tool rsync has been recognized by many users for its stable and efficient features. Implement local and remote data backup to ensure data security. Rsync introduction, the traditional data backup methods include the cp command and the wget command cp command. both the source and target files are local. This command only implements a complete copy of the file. if the data volume to be copied is large, the backup time will become long. The wget command backs up the file over the network, it does not support incremental backup. every time all the data needs to be transmitted over the network again, regardless of which files are updated, this command is more efficient. Today, we will introduce a practical tool, rsync, which allows you to easily implement local and remote data backup. Rsync is a file synchronization and data transmission tool in linux. it uses rsync. To synchronize files between a client and a remote file server, you can use rsync to back up data on the same server from one partition to another, you can also back up the data notification network transmission mode of the local system to any remote host. rsync can resume transmission after interruption. rsync only transfers the inconsistent parts between the source file and the target file; rsync supports full or incremental backup. Rsync features rsync: remote sync. you can see its functions from the software name. rsync has the following features: · images can be used to save the entire directory tree and file system. · Incremental data synchronization is possible, and file transmission efficiency is high, so the synchronization time is very short. · Maintain the permissions, time, and other attributes of the original file. · Encrypted data transmission ensures data security. · You can use rcp, ssh, and other methods to transmit files. of course, you can also directly connect to the file through socket. Supports anonymous transmission. -V tells rsync about what is going on-a Tells rsync to copy all files and directories from the source directory-z tells rsync to compress data to make network transmission faster (our data will encrypted and compressed) -e ssh tells rsync to use our SSH shell for network transmission. you can set the RSYNC_RSH shell environment variable to avoid adding this parameter every time you enter the rsync command, see The rsync man manual for details. -- Delete tells rsync to delete files on the backup server if they do not exist on the master server (this option does not remove any primary or source data ). /Www/This is the source directory on the SSH client, followed by a slash. if you want rsync to copy the entire directory and the content below it, this slash is required 10.1.1.2: /www this is the target IP address and target directory. rsync is used to build the data Image backup system. rsync has four application modes: shell application mode, also called local mode, and remote shell mode, it uses ssh to perform underlying connections and encrypted transmission. The third is the query mode, which is similar to the functions implemented by the ls command. The fourth mode is the server mode. generally, rsync server construction refers to this mode. Rsync with ssh channel technology Case # rsync-avzP/etc/hosts-e "ssh-p30000" lianglab@192.168.1.110:/tmp/meaning: push the local/etc/hosts file to the remote ip address 192.168.110tmp Directory, SSH port number is 30000 # rsync-avzP-e "ssh-p30000" lianglab@192.168.1.110:/tmp/hosts. this file is pulled from the remote ip address to the local device. Let's explain the syntax of the pull case: rsync-avzP-e "ssh-p 22" lianglab@192.168.1.110:/opt/tmp description: 1,-avz equivalent to-vzrtopgD1, the file and directory attributes remain unchanged during synchronization. 2.-P indicates the synchronization process. you can replace it with -- progress. 3.-e "ssh-p 22" indicates data transmission through the ssh channel.-p 22 can be omitted. 4. lianglab@192.168.1.110:/opt remote host system user, address, path 5,/tmp local path. Instance: use the root user from 192. The opt directory (including the directory itself) of 168.1.110 pulls data to the local/tmp directory. Push Case: raync-vzrtopP-e "ssh-p 22"/etc lianglab@192.168.1.110:/tmp instance: put the local/tmp Directory through the root user (excluding the directory itself) push to the/opt directory of 192.168.1.100. # Rsync-vzrtopP-e 'Ssh-p 22 '/tmp root@192.168.1.100:/opt # The pull example is almost the same, just change the source and target. Password: Enter the connection host password. Note: 1. data synchronization is encrypted because it is transmitted through the ssh channel. 2. Password verification is required before transmission, you need to manually enter the password. here we use the ssh key in the previous chapter to achieve login-free authentication, without interactive verification data transmission. 3. The rsync software must be installed on both local and remote machines. Use the ssh key to implement data login-free verification encrypted transmission instructions. if you have set an ssh key for login-free verification in advance, you can use rsync to verify synchronous transmission of data through ssh without logon, this is one of the common methods in production scenarios. Configure an ssh key for data login-free verification. Use the ssh channel for batch data transmission script vi lianglab. sh #! /Bin/sh. /etc/init. d/functions if [$ #-ne 1]; then echo "Usage: $0 argv" exit fi for ip in 17 18 do # scp-P30000 $1 lianglab@192.168.1. $ ip :~> &/Dev/null & \ # ssh-p30000-t lianglab@192.168.1. $ ip sudo rsync ~ /$1/etc> &/dev/null rsync-avzP $1-e "ssh-p 30000" lianglab@192.168.1. $ ip :~> &/Dev/null ssh-p30000-t lianglab@192.168.1. $ ip sudo rsync ~ /$1/etc> &/dev/null if [$? -Eq 0]; then action "liang $1 successful. "/bin/true else action" liang $1 failure. "/bin/false fi done problem error 1: no route to host problem the other party has not started, firewall blocking, firewall blocking on the network, all possible. Solution: disable the firewall, or open tcp udp port 873 of the firewall to allow rsync to pass through. they can use telnet IP 873 for inspection. Practice: A company has a web server. The data in it is very important, but if the hard disk breaks down, the data will be lost, now the leaders ask you to make a periodic and scheduled backup of data on other machines. The requirements are as follows: back up the website program directory on web server A at every night and push it to server B through the rsync command for backup and retention (the backup idea can be to package locally by date, and then push it to the backup server.) the specific operations are as follows: 1. the backup directories of web server A and backup server B must be/backup 2. the web server site directory is assumed to be (/var/www/html) regular backup script cd/var/www & \ tar zcf/backup/192.168.1.110/html _ $ (date has reached f0000.tar.gz. /html & \ cd/backup/& \ rsync-az. rsync_backup@192.168.1.100: backup -- password-file =/etc/rsync. password> &/dev/null find/backup -- type f-name "*. gz "-mtime + 7 | Xargs rm-f [root @ ctor rsync-3.0.4] # tar zxvf rsync-3.0.4.tar.gz [root @ director rsync-3.0.4] # cd rsync-3.0.4 [root @ director rsync-3.0.4] #. /configure config. status: creating popt/dummy config. status: creating shconfig config. status: creating config. h rsync 3.0.4 configuration successful [root @ director rsync-3.0.4] # [root @ director rsync-3.0.4] # make [root @ director rsync-3.0.4] # make inst All 1. local shell mode the local shell is mainly used to copy the specified directory to another directory, for example: [root @ diresrc src] # rsync-av rsync-3.0.4/tmp ------------ omitted -------------- rsync-3.0.4/zlib. h rsync-3.0.4/zlib/zutil. c rsync-3.0.4/zlib/zutil. h rsync-3.0.4/zlib/zutil. o sent 5472930 bytes encoded Ed 5190 bytes 10956240.00 bytes/sec [root @ director src] # rsync-av rsync-3.0.4 // tmp sent 5472780 bytes encoded Ed 5189 bytes 10955938.00 bytes/sec total s Ize is 5454825 speedup is 1.00 [root @ director src] # rsync-av rsync-3.0.4/tmp and rsync-av rsync-3.0.4/tmp commands are a bit different. The obvious difference is the slash at the end of the source parameter. if there is no slash at the end of the source parameter, copy the specified source directory to the specified directory. if there is a slash at the end of the source parameter, the contents in the source directory are copied to the directory. In the command: "-a" is "-- archive" (archive mode), indicating that the file is transmitted recursively and all file attributes are kept; "-v" is "-- verbose", indicating that the detailed mode information is output.
 
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.