Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Installation and Configuration rsync server under CentOS 6.3     - Oracle archive log size than the size of the online journal of the much smaller (Database)

- How to Create a file can not be changed under Linux (Linux)

- Timing task Crontab under Linux system (Linux)

- Process monitoring tools Supervisor start MongoDB (Database)

- Ubuntu How to install Pacman (Linux)

- Use OpenSSL to generate a certificate detailed process (Linux)

- Firewall chapter of Linux server security configuration (Linux)

- Btrfs file system creation and their characteristics in Linux (Linux)

- Web database security tips (Linux)

- OpenDaylight Helium version installed (Linux)

- How to test your MongoDB application upgrade? (Database)

- Broadcom transplanted to OpenWrt summary (Programming)

- Manually create Oracle Database Explanations (Database)

- Getting Started with Linux system to learn: how to use tcpdump to capture TCP SYN, ACK and FIN packets (Linux)

- Zend Studio PHP syntax color scheme to export (Linux)

- Linux Network Programming --TCP and UDP datagram type Explanation (Programming)

- Oracle 11g RAC manually playing GI PSU patch (11.2.0.4.8) (Database)

- Linux use iptables ban Ping (Linux)

- Text editing and viewing text Linux command (Linux)

- How do I switch from NetworkManager to systemd-network on Linux (Linux)

 
         
  Installation and Configuration rsync server under CentOS 6.3
     
  Add Date : 2017-04-13      
         
         
         
  First, rsync Profile

Rsync (remote synchronize) is a remote data synchronization tool via LAN / WAN quickly synchronize files between multiple hosts can also be used to synchronize the local hard disk Rsync different directories.

Rsync is a tool used to replace rcp, Rsync uses so-called "Rsync algorithm" to enable local and remote files between two hosts to achieve synchronization, the algorithm only transmit different portions of the two files, but not always the whole transmission parts, so very fast. You can refer to How Rsync Works A Practical Overview Learn more about the operating mechanism of rsync.

Rsync supports most Unix-like systems, whether it is on Linux, Solaris or BSD have been a good test. In addition, it also has a corresponding windows platform version, more well-known cwRsync and Sync2NAS.

Rsync initial author is Andrew Tridgell and Paul Mackerras, it is currently the http://rsync.samba.org maintenance.

Rsync basic characteristics are as follows:

1. The mirror can save the entire directory tree and file systems;

2. You can easily do to keep the original file permissions, time, soft and hard links;

3. No special privileges to install;

4. optimized processes, high efficiency of file transfer;

5. You can use rcp, ssh and other ways to transfer files, of course, can also be connected through a direct socket;

6. Support anonymous transfers, in order to facilitate website mirrors.

When using rsync for remote synchronization, you can use two ways: Remote Shell mode (recommended to use ssh, the responsibility of the user authentication ssh) and C / S mode (that is, customers connect to a remote rsync server, rsync server responsible for user authentication).

Whether local or remote directory synchronization to synchronize data, the first run will put all the files are copied once, only copies changed files (for new files) or a file change part (to the original file) later runtime.

rsync when first copy is no speed advantage, slower than tar, so when the large amount of data you can consider using tar for the first copy, and then use rsync to synchronize data.

Second, the system environment

Platform: CentOS release 6.3 (Final)

rsync version: rsync-3.0.9-2.el6.rfx.x86_64.rpm

rsync server: TS-DEV (172.16.1.135)
rsync client: TS-CLIENT (172.16.1.136)

Third, the server-side installation rsync service

3.1. Check whether you have installed rsync

# Rpm -qa | grep rsync

If you have already installed, use the rpm -e command to uninstall.

3.2. Download the RPM package

# Wget http://pkgs.repoforge.org/rsync/rsync-3.0.9-2.el6.rfx.x86_64.rpm

3.3. Installing rsync

# Rpm -ivh rsync-3.0.9-2.el6.rfx.x86_64.rpm

Fourth, configure the rsync service

4.1. To configure rsync server

First, choose the server startup mode
For heavier loads rsync server should use a separate operating mode
For a lighter load rsync server can use xinetd Run
Create a profile rsyncd.conf
For non-anonymous access rsync server also create an authentication password file
4.2. In xinetd run rsync service

CentOS by default xinetd run rsync service. rsync configuration file of xinetd
In /etc/xinetd.d/rsync. To configure to run rsync service xinetd need to execute the following command:

# Chkconfig rsync on
# Service xinetd restart
/etc/xinetd.d/rsync Administrator can modify the configuration files to suit your needs. For example, you can modify the configuration row

server_args = --daemon
Later add rsync service options.

4.3 Independent running rsync service

The easiest independently run rsync service is to execute the following command:

# / Usr / bin / rsync --daemon
You can write the above command to run rsync service /etc/rc.local file every time you start the server. Of course, you can also write a script to start rysnc service automatically at boot time.

4.4. Profile rsyncd.conf

Two kinds of rsync service running mode should be configured rsyncd.conf, its main configuration file format is similar to the samba.
Rsyncd.conf default configuration files in the / etc directory. To all the rsync service-related files in a separate directory, you can execute the following command:

# Mkdir / etc / rsyncd
# Touch /etc/rsyncd/rsyncd.conf
# Ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
Profile rsyncd.conf by the global configuration and configuration composed of several modules. Configuration file syntax is:

Module [module name] start
Format parameter configuration line is name = value, where value can be of two types of data:
String (without quotation marks can be delimited string)
Boolean value (1/0 or yes / no or true / false)
With # or; beginning are comments
\ As a line continuation character
Global Parameters

In the configuration file, all rows [module] than are global parameters. Of course, can also be part of the definition in the global parameter module parameters, then the value of this parameter is the default for all modules.

Parameter Description Default
address in a separate operation, the IP address used to specify the server is running. This parameter is ignored is run by xinetd, use the -address option on the command line instead. All local IP
port designated rsync daemon listening port number. This parameter is ignored is run by xinetd, use the -port option on the command line alternatives. 873
motd file to specify a message file, connect to the server when the client displays the contents of the file to the client. no
pid file rsync daemon to write its PID file specified. no
log file specified rsync daemon log file, rather than send the logs to syslog. no
syslog facility designated rsync to send log messages to the syslog message level when. daemon
socket options specify custom TCP options. no
Module parameters

The main module parameters used to define the rsync server which directories are to be synchronized. Format module declaration must [module] form, the name is seen in rsync client's name, similar to the share name Samba server. The real server to synchronize data is specified by the path. According to their own needs, to specify multiple modules, you can define the following parameters:

a. The basic module parameters

Parameter Description Default
path Specifies the current path synchronization module on the rsync server, this parameter must be specified. no
comment to the module is given a description, the description is displayed along with the name of the module to the customer when the customer is connected to get the module list. no
b. parameter control module

Parameter Description Default
use chroot If true, the rsync file first before transferring to the chroot directory path specified by the parameter. The reason for this is to implement additional security, but the drawback is the need for root privileges, and can not point to the backup path outside the symbolic link points to a file directory. true
uid Specifies the module with the specified UID to transfer files. nobody
gid of this module with the specified GID transfer files. nobody
The maximum number of concurrent connections max connections of this module is to protect the server, the connection request exceeds the limit will be informed then try again. 0 (no limit)
lock file support max connections parameter specifies the lock file. /var/run/rsyncd.lock
list to specify when the client requests a list of list of modules that can be used, whether the module should be listed. If this option is set to false, you can create hidden modules. true
read only specify whether to allow customers to upload files. If it is true it is not allowed to upload; if it is false, and also have access to the directory server is allowed to upload. true
write only specify whether to allow customers to download files. If it is true it is not allowed to download; if it is false, and the directory server also has read permission are allowed to download. false
ignore errors specify whether to ignore I / O error when running delete operation on the rsync server. Generally rsync in the I / O operation will be skipped -delete errors, in order to prevent serious problems because of a temporary shortage of resources or other I / O error. true
ignore nonreadable specify rysnc server completely ignores the user does not have access to those files. This is when the need to back up some directories should not be backed up files to gain is significant. false
timeout This option can override the client specified IP timeout. Ensuring rsync server does not wait forever for a client crash. For anonymous rsync server, the ideal number is 600 (seconds). 0 (no limit)
dont compress is used to specify those files prior to transmission without compression process. This option can define a list of command options do not allow some of the customers of the module. You must use the full name of the option, not a short. When a situation occurs reject an option, the server will report an error message and exits. For example, to prevent the use of compression, it should be: "dont compress = *". * .gz * .tgz * .zip * .z * .rpm * .deb * .iso * .bz2 * .tbz
c. filter parameter module file

Parameter Description Default
exclude specify multiple separated by spaces of multiple files or directories (relative path), and add it to exclude list. This is equivalent to using -exclude client command to specify the mode. air
Specify a file name exclude from the definition exclude rule contained in the list of server reads exclude from the definition of the file. air
specify multiple separated by spaces include multiple files or directories (relative path), and add it to the include list. This is equivalent to the client using -include command to specify the mode. air
Specify a file name include from rules include the definition contained in the server reads the list include the definition from the file. air
Exclude a module can specify only one parameter, include a parameter.
Combined with include and exclude can define complex exclude / include rules.
These parameters with respective rsync client command options equivalent, the only difference is their role in the server side.
Information on how to write rules file, please refer http://www.howtocn.org/rsync:use_rsync.
d. Module User authentication parameters

Parameter Description Default
auth users designated by a space or a comma-separated list of user names, only those users are allowed to connect to the module. Here the user and the system user does not have any relationship. Username and password in clear text secrets file stored in the parameter file specified. (Anonymous)
rsync secrets file to specify a password file authentication. Only when the auth users is defined, the file takes effect. air
strict modes specify whether monitoring of the password file permissions. If it is true then the password file can only be accessed rsync server running the identity of the user, any other user can not access the file. true
Rsync authentication password file permissions must be 600, otherwise the client will not connect to the server.
rsync authentication password file in each line specify a user name: password pairs in the format:
username: passwd

Generally password is best not more than eight characters. If you only configure anonymous access rsync server, you need to set these parameters.
e. Access control module parameters

Parameter Description Default
Which hosts hosts allow customers to specify a list of hosts allowed to connect with the module. Does not match the host list of hosts will be denied. *
Specify which hosts are allowed to connect hosts deny customers the module with a list of hosts. air
Customer-defined host list may be of the form:

Single IP address. For example: 192.168.0.1
The entire network segment. For example: 192.168.0.0/24,192.168.0.0/255.255.255.0
Single host name resolvable. For example: centos, centos.bsmart.cn
All host domain. For example:. * Bsmart.cn
"*" Indicates all.
Use multiple list items by spaces.
f. Module Parameters

Parameter Description Default
transfer logging rsync servers will record transfer operations to transfer log files. false
log format specified field transfer log files. "% O% h [% a]% m (% u)% f% l"
When setting the "log file" parameter, at the beginning of each log line will add "% t [% p]".

Delimiter log format that can be used as follows:
% A - Remote IP address
% H - the remote host name
% L - the length of the file number of characters
The PID times rsync session -% p
% O - operation type: "send" or "recv"
% F - the file name
% P - module path
% M - the module name
% T - the current time
% U - the user name (when Anonymous is null)
% B - the number of bytes actually transferred
% C - when sending a file, record the file checksum
Five, rsync server application cases

5.1. Configuring rsync service on the server side TS-DEV

a. Edit the configuration file

# Vi /etc/rsyncd/rsyncd.conf

# Minimal configuration file for rsync daemon
# See rsync (1) and rsyncd.conf (5) man pages for help

# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root
gid = root
use chroot = no
read only = yes

#limit access to private LANs
hosts allow = 172.16.0.0 / 255.255.0.0 192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0
hosts deny = *
max connections = 5

pid file = /var/run/rsyncd.pid

secrets file = /etc/rsyncd/rsyncd.secrets
#lock file = /var/run/rsync.lock

motd file = /etc/rsyncd/rsyncd.motd

#This Will give you a separate log file
log file = /var/log/rsync.log

#This Will log every file transferred - up to 85,000+ per user, per sync
transfer logging = yes

log format =% t% a% m% f% b
syslog facility = local3
timeout = 300
# MODULE OPTIONS
[Davidhome]
path = / home / david /
list = yes
ignore errors
auth users = david
comment = David home
exclude = important /

[Chinatmp]
path = / tmp / china /
list = no
ignore errors
auth users = china
comment = tmp_china
b. Establish /etc/rsyncd/rsyncd.secrets file

# Vim /etc/rsyncd/rsyncd.secrets

david: asdf # format username: password
china: jk # The user does not require users of the system

c. For password security, we have the authority to 600

# Chown root: root /etc/rsyncd/rsyncd.secrets

# Chmod 600 /etc/rsyncd/rsyncd.secrets

Welcome information file d. To establish a connection to the server, the client can see /etc/rsyncd/rsyncd.motd

# Vim /etc/rsyncd/rsyncd.motd

+++++++++++++++++++++++++++
+ David Camp +
+++++++++++++++++++++++++++

e. Start rsync

# /etc/init.d/xinetd Restart

f. Check whether the port is up 873

# Netstat -an | grep 873

If rsync successfully started, then you can see the 873 port has been listening.

g. server-side file details

5.2. Client Configuration

a. Client Installation rsync

# Yum -y install rsync

b. By rsync client to synchronize data

scene one:

# Rsync -avzP david@172.16.1.135 :: davidhome / tmp / david /

Password: david here to enter a password, the server is provided, in the previous example, we are using a asdf, enter the password is not displayed; lose after a good carriage;
NOTE: This command is meant to say, with david user logs on to the server, the davidhome data synchronized to the local directory / tmp / david / on. Of course, the local directory is your own definition, such as dave also possible; when you're on the client, the directory of the current operation does not davidhome this directory, the system automatically creates one for you; when there davidhome this directory, you should pay attention to its written permission.

Explanation:
-a parameter, which is equivalent -rlptgoD, -r is recursive -l is linked files, meaning that copies of the linked file ;-p document indicates to maintain the existing permissions; -t time keeping the original document; -g maintaining the original file user group ; -o keep the original file owner ;-D equivalent block device file;
-z compression transmission;
-P Transmission schedule;
Progress of transmission of information -v, and -P somewhat related, for yourself. You can look at the document;

Scene Two:
# Rsync -avzP --delete david@172.16.1.135 :: davidhome / tmp / david /

This time we introduce a -delete option to indicate that the data on the client to be completely consistent with the server side, if the / tmp / david / files in the directory on the server does not exist, then delete it. The ultimate goal is to make data / tmp / david / directory is completely consistent with the server; use the time to be careful, it is best not to have an important number of the data directory, as local update directory, otherwise you will delete all data;

Scene Three:
# Rsync -avzP --delete --password-file = / tmp / rsync.password david@172.16.1.135 :: davidhome / tmp / david /

This time we added an option -password-file = rsync.password, then when we david rsync server synchronization user login data, passwords /tmp/rsync.password read this file. The content of the document is david user's password. We want to do the following;

# Touch /tmp/rsync.password
# Chmod 600 /tmp/rsync.password
# Echo "asdf"> /tmp/rsync.password
# Rsync -avzP --delete --password-file = / tmp / rsync.password david@172.16.1.135 :: davidhome / tmp / david /

NOTE: This password is not required; in fact, this is more important, because the server program by crond task is still necessary;

5.3. Rsync client to automatically synchronize data with the server

Edit crontab
# Crontab -e
Add the following code:

10 0 * * * rsync -avzP --delete --password-file = / tmp / rsync.password david@172.16.1.135 :: davidhome / tmp / david /
For every day 0:10 behind the implementation of the order.

Sixth, error analysis

@ERROR: Chdir failed
rsync error: error starting client-server protocol (code 5) at main.c (1530) [receiver = 3.0.6]

rsync: opendir (in xxxxxxx) failed ".": Permission denied (13)

Solution:

1, selinux remove all restrictions on the rsync:
# / Usr / sbin / setsebool -P rsync_disable_trans 1
# Service xinetd restart

2, a little hard, the whole ban selinux:
# Vim / etc / selinux / config
Will be one of SELINUX = enforcing modify SELINUX = disabled
Save and exit, restart the machine.

So far, rsync server configured.
     
         
         
         
  More:      
 
- Ubuntu Locale configuration problem solving Can not set LC_CTYPE (Linux)
- Sublime Text 3 practical functions and shortcut keys used to collect (Linux)
- Android float ball and boot from the start (Programming)
- VMware Workstation virtual machine startup error: Could not open / dev / vmmon in CentOS 6 (Linux)
- On FreeBSD 10.2 Bugzilla how to install and configure Apache SSL (Server)
- CentOS 6.4 installation and configuration LNMP build PHP server runtime environment (Server)
- Bash How to read a file line by line (Programming)
- Use Bosh deploy CloudFoundry problems encountered on OpenStack (Server)
- Upgrading KDE Plasma 5.3 in Ubuntu 15.04 (Linux)
- jobs command example (Linux)
- Linux system security infrastructure Highlights (Linux)
- JITwatch installation under Linux (Linux)
- SecureCRT session buffer size settings (Linux)
- MySQL migration tool used in the production environment (Database)
- The three-way division of the sorting algorithm Quicksort (Programming)
- Using Python multithreaded mistakes summary (Programming)
- Do not enter password login ssh (Server)
- Dialogue UNIX:! $ # @ *% (Linux)
- Linux compression and decompression command (Linux)
- CentOS 6.5 / Linux restart network card being given Determining if ip address x.x.x.x is already in use (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.