Rsycn service configuration experiment record-Linux Enterprise Application-Linux server application information. The following is a detailed description. Objective: To synchronize images of website content easily
Network Environment:
(Company LAN)
Server: 10.10.101.157
Client: 10.10.100.48
1. Software Download installation (we installed rsync-2.6.9.tar.gz)
1. Download: http://rsync.samba.org/ftp/rsync/ from original website
2. #./configure
# Make
# Make install
Note that rsync must be installed on both the client and server. The client runs rsync as a client, and the server runs rsync as a server. It listens to port 873.
3. Run rsync
/Usr/local/bin/rsync -- daemon
Verify that the startup is successful:
Netstat-na | grep 873
2. Server Configuration
10.10.101.157
1. edit/etc/rsyncd. conf.
Uid = nobody
Gid = nobody
Use chroot = no
Log file =/var/log/rsyncd. log
Pid file =/var/run/rsyncd. pid
Lock file =/var/run/rsync. lock
Max connections = 4
[Www]
Path =/home/faga
Comment = BACKUP WWW
Ignore errors
Read only = yes
List = no
Auth users = faga
Hosts allow = 10.10.100.48
Secrets file =/etc/rsyncd. secrets
Iii. Client Testing
10.10.100.48
Mkdir/tmp/faga
Rsync-vzrtopg -- progress -- delete faga@10.10.101.157: www/tmp/faga
After running, you must enter the password and then start to synchronize the image.
Note:
In this command line, the v in vzrtopg is verbose, z is compression, r is recursive, and topg is a parameter that maintains the original file attributes, such as owner and time. -- Progress indicates that the detailed progress is displayed. -- delete indicates that if the server deletes the file, the client also deletes the file to ensure true consistency.
In faga @ ip, faga specifies the user name in the password file, and www indicates the module name, that is, the name customized in/etc/rsyncd. conf. The last/tmp/faga is the name of the local directory that is backed up.
4. Use rsync + ssh for encrypted transmission to implement content mirroring, so as to be used in the script without entering the verification password interactively
1. Generate the SSH private key and public key in 10.10.100.48.
# Cd/root/. ssh/
# Ssh-keygen-d
Press Enter until the end
2. The id_dsa file is displayed in the/root/. ssh/directory? Id_dsa.pub: Copy id_dsa.pub to the 10.10.101.157/root/. ssh/directory and change it to authorized_keys2.
# Scp/root/. ssh/id_dsa.pub 10.101.157:/root/. ssh/authorized_keys2
3. Execute: ssh 10.10.100.157 in 10.10.100.157 to check whether the password is required for login.
4. perform image operations in 10.10.100.48.
Rsync-avlR -- delete-e ssh 10.10.101.157:/home/faga/-- (pull)
Rsync-avlR -- delete-e ssh/www 10.10.101.157:/-- (push)
Parameter description:
If you do not want to include a directory or file, you can set -- exclude.
-A, -- archive
-V, -- verbose
-L, -- links
-R, -- relative
-- Delete
Is that if the Server side? H In addition to a file, does the client also take this file? H Division, keep true consistency
-E ssh
Establish an encrypted connection
Note: script execution can be made. The above method can be used to distribute updated site content, so that site content can be updated synchronously. You only need to use it flexibly.
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