Installation and configuration of rsync server under CentOS 6.5

rsync installation#

bash#Check if rsync is installed,Need to uninstall if it has been installed
rpm -qa|grep rsync
# Install rsync uninstall
rpm -e rsync
# Download the latest rpm package(Pay attention to the matching of the operating system and the number of bits) 
# Rsync's rpm package list address: http://pkgs.repoforge.org/rsync
wget http://pkgs.repoforge.org/rsync/rsync-3.1.1-1.el6.rfx.x86_64.rpm
# rpm package installation
rpm -ivh rsync-3.1.1-1.el6.rfx.x86_64.rpm

Rsync server configuration#

Start configuration##

CentOS runs rsync in xinetd mode by default, and the xinetd configuration file of rsync is /etc/xinetd.d/rsync
If you configure rsync to run in xinetd mode, execute the following command

bashchkconfig rsync on
service xinetd restart
# If you execute service xinetd restart to find xinetd:unrecognized service xinetd service is not installed
# Execute yum install xinetd to install xinetd service
# Start the xinetd service after installation(service xinetd start)

Edit the rsync xinetd configuration file /etc/xinetd.d/rsync file, modify the parameter server_args = --daemon --config=/etc/rsyncd/rsyncd.conf to configure the parameters when the rsync server starts

If you use standalone mode, execute the following command

bash/usr/bin/rsync --daemon
# edit/etc/rc.local file added/usr/bin/rsync --The daemon guarantees that the rsync service will be started automatically every time it starts up

Configuration file##

bash#Create rsync service directory
mkdir /etc/rsyncd
# Create configuration file
touch /etc/rsyncd/rsyncd.conf
# Create a password file
touch /etc/rsyncd/rsyncd.passwd
# Permission modification
chown root:root /etc/rsyncd/rsyncd.passwd
chmod 600/etc/rsyncd/rsyncd.passwd

Introduction to configuration file syntax

Global parameters (configurations other than [module name] are global configurations)

Module parameters
Module parameters are mainly used to define which directory of the rsync server is to be synchronized. The format of the module declaration must be in the form of [module]. This name is the name seen on the rsync client, similar to the share name provided by the Samba server. The data that the server really synchronizes is specified by path. You can specify multiple modules according to your needs. The following parameters can be defined in the module:

The client host list definition can be in the following forms:
Single IP address for example: 192.168.0.1
For example, the entire network segment: 192.168.0.0/24, 192.168.0.0/255.255.255.0
Resolvable single host name such as centos, centos.bsmart.cn
All hosts in the domain, for example: .bsmart.cn* "*" means all.
Multiple list items should be separated by spaces.

  • The permission of the rsync authentication password file must be 600, otherwise the client will not be able to connect to the server.

Configuration file example

bash# 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.0192.168.1.0/255.255.255.010.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

Password file

shdavid:asdf             #Format username:Password
china:jk               #The user is not required to be a system user

Check whether the rsync service is started
netstat -an | grep 873

rsync client#

bash#Install the client
yum -y install rsync
# Sync command
# - a parameter, equivalent to-rlptgoD
# - r is recursion-l is the link file, which means to copy the link file;-p means to keep the original permissions of the file
# - t keep the original time of the file;-g keep text#Original user group;-o Keep the original owner of the file;-D is equivalent to a block device file
# - z Compression during transmission;
# - P transmission progress;
# - v Progress and other information during transmission, and-P is a bit related, try it yourself. You can read the document;
# Synchronize
rsync -avzP [email protected]::davidhome  /tmp/david/
# The client data and server data are consistent
rsync -avzP  --delete [email protected]::davidhome  /tmp/david/
# Specify the password file when transferring, password file permissions 600
rsync -avzP  --delete--password-file=/tmp/rsync.password  [email protected]::davidhome  /tmp/david/

Recommended Posts

Installation and configuration of rsync server under CentOS 6.5
Installation and configuration of redis under centos7
Centos7 installation and configuration of Jenkins
Java-JDK installation and configuration under CentOS
CentOS NTP server installation and configuration
Installation and use of Mysql under CentOS
Tomcat installation and configuration under CentOS 7 (Tomcat startup)
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Detailed explanation of Spark installation and configuration tutorial under centOS7
Centos7 installation and deployment of gitlab server
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
Installation and configuration of JDK in CentOS 7 system
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of CentOS 7 in VMware Workstation
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Installation and cracking of confluence6.3 operation records under Centos
Installation and cracking of Jira7 operation records under Centos
Environment configuration of JDK, mysql and tomcat under Centos7
Centos6.5 installation and deployment of KVM
Installation under centos6.9 of jenkins learning
CentOS7 installation and maintenance of Gitlab
CentOS 7 Tomcat service installation and configuration
Erlang 20.2 installation and deployment under CentOS 7
Centos7 mysql database installation and configuration
CentOS 7 system installation and configuration graphic tutorial
Centos-6.5 installation and deployment of LNMP environment
Installation and uninstallation of CUDA under Ubuntu 16.04
Zabbix installation and deployment and localization under CentOS
Centos7 hive stand-alone mode installation and configuration
Jenkins installation and deployment tutorial under CentOS 7
KVM installation and preliminary use under CentOS 7.2
Centos7 installation and deployment of Airflow detailed
Detailed explanation of quick installation and configuration of Subversion (SVN) under Ubuntu
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
OpenMPI-Ubuntu installation and configuration
Installation of pulseaudio and API usage under Ubuntu 12.04
Centos7 installation of PHP and Nginx tutorial detailed
Graphical installation of CentOS8
Mysql8.0.15 installation configuration (centos7)
Install svn and configuration through yum under CentOS
Redis3 installation under Centos7
Kaldi installation and configuration graphic tutorials under Ubuntu
Installation, configuration and uninstallation of GitLab in Ubuntu19.1
MySQL 8.0 installation and deployment under CentOS, super detailed!
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
Non-Root installation of Microsoft R Open under Centos
Distributed deployment of Apollo configuration center under CentOS8
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
From installation to entry of FastDFS under Centos7
Ubuntu16.04 mirror complete installation and configuration tutorial under VMware
Installation and use of GDAL in Python under Ubuntu
Installation and usage instructions of rz/sz command under ubuntu
Build OpenV** Server under CentOS7
Build OpenLDAP server under CentOS7
Redis cluster installation under CentOS
Ubuntu16.04 installation and simple configuration
Redis cluster installation under CentOS