Configure the rsync file synchronization service in linux

Source: Internet
Author: User

Server Configuration:
Prerequisites: xinetd and rsync are installed.
1. Modify the/etc/xinetd. d/rsync File
Change disable = yes to no in the following content
Service rsync
{
Disable = yes
Socket_type = stream
Wait = no
User = root
Server =/usr/bin/rsync
Server_args = -- daemon
Log_on_failure + = USERID
}
2. Configure rsync to automatically start
Run the command: chkconfig rsync on
Run the chkconfig rsync -- list command to view the following content:
Rsync on
 
3. Configure rsyncd. conf. This file does not exist in general and needs to be created by yourself. The content example is as follows:
Uid = root
Gid = root
Use chroot = no
Max connections = 4 (maximum number of connections, which can be adjusted as needed .)
Strict modes = yes
Port = 873 (default port, preferably not modified .)
Pid file =/var/run/rsyncd. pid
Lock file =/var/run/rsync. lock
Log file =/var/log/rsyncd. log
 
[Test] (this is the module name. You can configure multiple modules to correspond to different directories on the server .)
Path =/test (this is the server path corresponding to this module)
Comment = This is test
Auth users = rsync .)
Uid = root
Gid = root
Secrets file =/home/rsync. ps (password file, which stores the username and password used for synchronization)
Read only = no
List = no
 
4. Make sure that the rsync port number in etc/services is correct.
It is generally as follows:
Rsync 873/tcp # rsync
Rsync 873/udp # rsync
 
5. Configure the rsync password (the path has been written in the preceding configuration file)/home/rsync. ps (create this file and write the name at will, as long as it is consistent with the above configuration file), in the format of (User name: password), one row of a user.
For example:
Rsync: rsync
 
6. Configure rsync Password File Permissions
Chown root. root rsync. ps
Chmod 400 rsync. ps
 
7 STARTUP configuration
Service xinetd restart
Stopping xinetd: [OK]
Starting xinetd: [OK]
 
8. Check whether rsync is enabled.
Run the following command: lsof-I: 873
Normally, the following content should be displayed:
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Xinetd 4396 root 5u IPv4 633387 TCP *: rsync (LISTEN)
 
Client Configuration:
1. set the password file/home/rsync. ps: This file can be named at will and stored in any directory. It does not matter with the server configuration, but the content has only one password and must be consistent with the server.
According to the above server configuration, the content here should be:
Rsync
Then modify the File Permission:
Chown root. root rsync. ps
Chmod 600 rsync. ps
2. Place the rsync command into the scheduled task (crond). Assume that the server ip address is 192.168.1.100.
First test whether it can be used
Fetch data from the server: rsync-avz -- progress -- delete -- password-file =/opt/rsync. ps rsync@192.168.1.100: test/opt/web/public/
Send data to the server: rsync-avz -- progress -- delete -- password-file =/opt/rsync. ps/opt/web/public/rsync@192.168.1.100: test
Modify the/etc/crontab file and add the following content (execute once every minute to retrieve data from the server ):
* *** Rsync-avz -- progress -- delete -- password-file =/opt/rsync. ps rsync@192.168.1.100: test/opt/web/public/


Author surelei

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.