Install rsyncd server (system automatic and source code package installation)

Source: Internet
Author: User

 

Install rsyncd Server
Note: The default rsync version of RHEL is 2.6.x, and the list is backed up first. It consumes a lot of or even 1 GB of memory resources when pushing a large number of files.
Install the xinetd service with rsync of the system.

Run chkconfig xinetd on and chkconfig rsync on

Edit/etc/xinetd. d/rsync as follows:

# Default: Off
# Description: the rsync server is a good addition to an FTP server, as it/
# Allows CRC checksumming etc.
Service rsync
{
Disable = No
Socket_type = stream
Wait = No
User = root
Server =/usr/bin/rsync
Server_args = -- daemon -- Config =/usr/local/rsyncd/etc/rsyncd. conf
Log_on_failure + = userid
}

Then create a directory

Mkdir-P/usr/local/rsyncd/{etc, man, VAR}

VI/usr/local/rsyncd/etc/rsyncd. conf

Log File =/usr/local/rsyncd/var/rsyncd. Log
PID file =/usr/local/rsyncd/var/rsyncd. PID
Lock file =/usr/local/rsyncd/var/rsyncd. Lock
Secrets file =/usr/local/rsyncd/etc/rsyncd. Secrets
Motd file =/usr/local/rsyncd/etc/rsyncd. motd
Read Only = Yes
Address = 192.168.51.205
# Hosts allow = 192.168.0.159
# Hosts deny = 192.168.100.0/24
List = Yes
Uid = root
Gid = root
Use chroot = No
Max connections = 4
# Syslog facility = local5
[Test]
Path =/root/test
Comment = test
Auth users = tonyty163
Secrets file =/usr/local/rsyncd/etc/Linux. Pas

/Usr/bin/rsync -- daemon -- config-file =/usr/local/rsync/etc/rsyncd. conf -- Port = 873

In the latest rsync 3.0.x version, the incremental file list is used, and the list is backed up while the memory is occupied by only 4 ~ 5 m
# Cd/opt/src
# Tar xzvf rsync-3.0.4.tar.gz
# Cd rsync-3.0.4
# Compilation is detailed parameter see./configure -- Help
#./Configure -- prefix =/opt/APP/rsync -- disable-ipv6
# Make & make install
# Ln-S/opt/APP/rsync/bin/rsync/usr/bin/rsync
# Add the rsync running process number directory
# Mkdir/opt/APP/run
# Add the rsync log directory
# Mkdir/opt/APP/logs
# Create an rsync server configuration file
# Touch/opt/APP/rsync/rsyncd. conf
# Create an rsync User Password File
# Touch/opt/APP/rsync/Linux. Pas
# You must change the password file permission to 600. Otherwise, authentication problems may occur.
# Chmod 600/opt/APP/rsync/Linux. Pas

Iii. rsync server configuration:
3.1 rsync server configuration file rsyncd. conf
Rsyncd. conf is the main configuration file of the rsync server.

Global definition:
# Vi/opt/APP/rsync/rsyncd. conf
PID file =/opt/APP/rsync/run/rsync. PID
Port = 3334
Address = 192.168.2.100
Uid = root
Gid = root
Use chroot = Yes
Read Only = Yes
# Limit access to private LANs
Hosts allow = 192.168.2.0/255.255.255.0
Hosts deny = *
Max connections = 10
Motd file =/opt/APP/rsync/rsyncd. motd
Log File =/opt/APP/rsync/logs/rsyncd. Log
Timeout = 300

Module definition:
[Linux_file]
Path =/opt/case/www.linux.com/
List = Yes
Ignore errors
Auth users = root
Uid = root
Gid = root
Secrets file =/opt/APP/rsync/Linux. Pas
Read Only = No
Note: Auth users is a real system user that must exist on the server. If you want to use multiple users, separate them with commas (,). For example, auth users = root, Linux
Password File:/opt/APP/rsync/Linux. Pas content format:
User name: Password
Note: The Linux. Pas permission for the password file must be 600. Otherwise, the rsync server cannot work normally.
Root: 1linux6
For Linux: 88888
Note: The password here is worth noting. For security, you cannot write the password of the System user here. For example, if the root password of your system user is linux.com, you can set the root password in rsync to 1linux6 for security purposes.

Rsyncd. motd file:
It defines the information of the rysnc server, that is, the user logon information. For example, let the user know who provided the server. For example, when logging on to an FTP server, we can see linux.com FTP ....... Of course, this is not necessary for global definition of variables. You can use # To note or delete the variables. Here I wrote the content of rsyncd. motd:
++
+ Linux.com rsync 2008-11-11 +
++

3.2 rsync server configuration example:
Global definition:
On the rsync server, there are several key global definitions, according to the previous configuration file rsyncd. conf;
PID file =/opt/APP/rsync/run/rsyncd. PID Note: Tell the process to write to the/opt/APP/rsync/run/rsyncd. PID file;
Port = 873 Note: Specify the running port. The default value is 873. You can specify the port by yourself;
Address = 192.168.2.100 Note: Specify the Server IP address;
Uid = nobody
Gid = nobdoy
Note: When the Server transfers files, the user and user group to be sent for execution is nobody by default. If you use nobody users and user groups, you may encounter permission issues. Some files cannot be pulled from the server. So I was lazy and used root for convenience. However, you can specify a user in the module defined when defining the directory to be synchronized to solve the permission problem.
Use chroot = Yes
NOTE: With chroot, before transferring files, the server daemon sends chroot to the directory in the file system. This may protect the system from installation vulnerabilities. The disadvantage is that Super User Permissions are required. In addition, the symbolic link files will be excluded. That is to say, if you have signed a link on the rsync server, when you run the synchronization data of the client on the backup server, only the Symbolic Link name will be synchronized, the content of the symbolic link is not synchronized; you need to try it yourself;
Read Only = Yes
Note: Read-Only is read-only, that is, the client is not allowed to upload files to the server. There is also a write only option.

# Limit access to private LANs hosts allow = 192.168.2.0/255.255.255.0
Note: You can specify a single IP address or the entire network segment to improve security. The format is separated by spaces between IP addresses and IP addresses, between IP addresses and CIDR blocks, and between CIDR blocks;
Max connections = 10
Note: The maximum number of client connections;
Motd file =/opt/APP/rsync/rsyncd. motd
Note: The motd file defines the server information. You must write the rsyncd. motd File Content yourself. This information is displayed when you log on. For example:
++
+ Linux.com rsync 2002-2007 +
++
Log File =/var/log/rsync. Log
Note: rsync server logs;
Transfer logging = Yes
Note: This is the log for transferring files;
Log format = % T % A % m % F % B
Syslog facility = local3
Timeout = 300

Module definition:
What does a module define? It mainly defines which directory on the server to be synchronized. Each module must be in the [name] format. This name is the name seen on the rsync client. It is actually a bit like the sharing name provided by the Samba server. The data actually synchronized by the server is specified through path. You can specify multiple modules as needed. Each module must specify the authenticated user, password file, but the exclusion is not necessary;

The following is an example of the configuration file module:
[Linux_file]
Note: The module provides us with the name of a link. Where is the link? In this module, the/opt/case/www.linux.com directory is linked. It should be in the form of [name;
Path =/opt/case/www.linux.com/
Note: the location of the specified file directory must be specified;
Auth users = root
Note: The authenticated user is root and must exist on the server;
List = Yes
Note: List indicates whether the directory on the rsync server that provides data synchronization is displayed in the module on the server. The default value is yes. If you do not want to list the contents, no is required. If no is used, at least others do not know which directories are provided on your server. You just need to know it;
Ignore errors
Note: Ignore Io errors. For more information, see this document;
Secrets file =/opt/APP/rsyncd/Linux. Pas
Note: Which file does the password have;
Comment = Linux Web Data
NOTE: Annotations can be defined by yourself. You can write anything. Just write the relevant content;
Exclude = Cache/
Note: exclude indicates exclusion, that is, the cahce/in the/opt/case/www.linux.com directory should be excluded;

3.3 start the rsync server:
It is quite simple to start the rsync server. -- daemon enables rsync to run in server mode;
[Root @ Linux: ~] # Rsync -- daemon -- Config =/opt/APP/rsync/rsyncd. conf -- Port 3334
Note: If you cannot find the rsync command, you should know where Rsync is installed. For example, the rsync executable command may be installed in the/usr/local/bin directory, that is, the following command;
[Root @ Linux: ~] # Rsync -- daemon -- Config =/etc/rsyncd. conf -- Port 3334 (the default port number is 873 if no port is added)
This command is written to the RC. Local file and runs automatically upon startup;

Complete configuration of the server configuration file VI/usr/local/rsync. confpid file =/usr/local/rsync/APP/run/rsync. PID
# Port = 3334
Address = 192.168.1.163
Uid = root
Gid = root
Use chroot = Yes
Read Only = Yes
# Limit access to private LANs
Hosts allow = 192.168.1.0/255.255.255.0
Hosts deny = *
Max connections = 10
Motd file =/usr/local/rsync/APP/run/rsyncd. motd
Log File =/usr/local/rsync/logs/rsyncd. Log
Timeout = 300
[Linux_file]
Path =/opt/test/www.linux.com/
List = Yes
Ignore errors
Auth users = root
Uid = root
Gid = root
Secrets file =/usr/local/rsync/Linux. Pas
Read Only = No
Client synchronization command rsync-auzv -- Progress -- password-file =/usr/local/rsync/Linux. Pas root@192.168.1.163: linux_file/opt/test/(last local path)

Remember: The permission for the Linux. Pas file must be 600

(Note: This security setting is very important. If you do not connect the client to the server like this, the following message will be displayed:
@ Error: AUTH failed on module smb_recover_files
Rsync: Connection unexpectedly closed (102 bytes read so far)
Rsync error: Error in rsync protocol data stream (Code 12) at I/O. C (165)
The following error occurs in server logs:
06:32:01 [8388] Secrets file must not be other-accessible (see strict modes option)
06:32:01 [8388] continuing without secrets File
06:32:01 [8388] auth failed on module smb_recover_files from documentserver

Server-side Linux. PAS (User: password) <the user must be a system user, and the password should not be the System user password> client Linux. PAS (password) <server-side password>

The account and password of the server and client cannot contain spaces. Otherwise

@ Error: AUTH failed on Module

If the port number is changed, you must change the corresponding port in/etc/services to run properly.

 

For example, change rsync 873/tcp

Rsync 3334/tcp

@ Error: chdir failed
Rsync error: Error starting client-server protocol (Code 5) at main. C (1296) [handler ER = 2.6.8]
Cause and solution:

This is generally because no directory is created on the server.

If SELinux is enabled, run the following command:
SELinux;
Setsebool-P rsync_disable_trans on

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.