Configure the rsync file synchronization service in linux
Source: Internet
Author: User
Server Configuration: premise: xinetd and rsync1. modify the/etc/xinetd. d/rsync file and change disableyes to noservicersync {disableyessocket_typestreamwaitnouserrootserver/u .. 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
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/
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.