First, the environment
System: centos6.4x64 Minimized installation
rsync-1:192.168.3.50
rsync-2:192.168.3.52
Ii. installation of Rsync
Uninstalling the existing rsync package
[Email protected] ~]# rpm-e ' rpm-qa |grep rsync '
Download the latest Rsync installation package and install
[Email protected] ~]# wget http://pkgs.repoforge.org/rsync/rsync-3.1.1-1.el6.rfx.x86_64.rpm[[email protected] ~]# RPM-IVH rsync-3.1.1-1.el6.rfx.x86_64.rpm warning:rsync-3.1.1-1.el6.rfx.x86_64.rpm:header V3 DSA/SHA1 Signature, key ID 6b8d79e6:nokeypreparing ... ########################################### [100%] 1:rsync ########################################### [100%]
Scenario: Push files directly from rsync-1 to rsync-2/root directory
Files under the/root directory of #查看rsync-2 [[EMAIL PROTECTED] ~]# LL /ROOT/TOTAL 56-RW-------. 1 root root 2790 may 4 13:49 anaconda-ks.cfg-rw-r--r--. 1 root root 3305 may 4 13:49 cobbler.ks-rw-r--r--. 1 Root root 20504 may 4 13:49 install.log-rw-r--r--. 1 root Root 5882 may 4 13:48 install.log.syslog-rw-r--r--. 1 root root 2241 may 4 13:49 ks-post.log-rw-r--r--. 1 root Root 1 may 4 13:49 ks-post-nochroot.log-rw-r--r--. 1 root root 978 may 4 13:45 ks-pre.log# Push files directly to rsync-2 on rsync-1 [[email protected] ~]# rsync -avz rsync-3.1.1-1.el6.rfx.x86_ 64.rpm 192.168.3.52:/root[email Protected] ' s password: sending incremental file listrsync-3.1.1-1.el6.rfx.x86_64. rpmsent 409,478 bytes received 35 bytes 117,003.71 bytes/ sectotal size is 413,760 speedup is 1.01# viewing results on Rsync-2 [[email PROTECTED] ~]# LL /ROOT/TOTAL 464-RW-------. 1 root root 2790 may 4 13:49 anaconda-ks.cfg-rw-r--r--. 1 root root 3305 may 4 13:49 cobbler.ks-rw-r--r--. 1 root root 20504 may 4 13:49 install.log-rw-r--r--. 1 root root 5882 may 4 13:48 install.log.syslog-rw-r--r--. 1 root root 2241 may 4 13:49 ks-post.log-rw-r--r--. 1 root root 1&nbsP May 4 13:49 ks-post-nochroot.log-rw-r--r--. 1 root root 978 May 4 13:45 ks-pre.log-rw-r--r-- 1 root root 413760 jun 23 2014 rsync-3.1.1-1.el6.rfx.x86_64.rpm
Third, configure the Rsync service
Configure Rsync to run xinetd mode
[[email protected] ~]# yum install xinetd -y# Modify/etc/xinetd.d/rsync [[email protected] ~]# vim /etc/xinetd.d/rsync service rsync{ disable = no # #将yes改成no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += userid} #启动xinetd服务 [[email protected] ~]# service xinetd startstarting xinetd: [ ok ]# The default listener port for Rsync is 873, to see if Port No. 873 is started [[Email protected] ~]# netstat -anptactive internet connections (servers and established) proto recv-q send-q local address foreign address state PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1244/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1321/master tcp 0 52 192.168.3.50:22 192.168.3.2:17985 Established 1812/sshd tcp 0 0 :::22 :::* listen 1244/sshd tcp 0 0 : :1:25 :::* LISTEN 1321/master tcp 0 0 :::873 :::* LISTEN 1957/xinetd
Add firewall rules, release 873 ports
[[email protected] ~]# iptables -i input -p tcp --dport 873 -j accept[[email protected] ~]# iptables -i input -p udp --dport 873 -j accept[[email protected] ~]# service iptables saveiptables: saving firewall rules to /etc/sysconfig/iptables:[ ok ][[email protected] ~]# iptables -L -n |grep 873ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:873 accept tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:873
Creating the rsync service catalog and configuration files
#创建rsync服务目录 [[email protected] ~]# MKDIR/ETC/RSYNCD # Create profile [[email protected] ~]# touch/etc/rsyncd/rsyncd.conf# Create cipher text [[email protected] ~]# touch/etc/rsyncd/rsyncd.secrets# permissions modification [[email protected] ~]# chown root:root/etc/rsyncd/ Rsyncd.passwd[[email protected] ~]# chmod 600/etc/rsyncd/rsyncd.secrets
Create User and password
[Email protected] ~]# echo "Rsync:test" >>/etc/rsyncd/rsyncd.secrets
Create an rsync configuration file
[[email protected] ~]# vim /etc/rsyncd/rsyncd.conf# global optionsuid = rootgid = rootuse chroot = noread only = yes#limit access to private lanshosts allow=192.168.3.0/255.255.0.0hosts deny=*max connections = 5pid file = /var/run/rsyncd.pidsecrets file = /etc/rsyncd/ rsyncd.secrets#lock file = /var/run/rsync.lock motd file = /etc/rsyncd/rsyncd.motd #This will give you a separate log filelog file = /var /log/rsync.log #This will log every file transferred - up to 85,000+ per User, per synctransfer logging = yeslog format = %t %a %m %f %bsyslog facility = local3timeout = 300# module options[test]path = /data/ Testlist=yesignore errorsauth users = rsynccomment = welcome to rsync server
Edit the rsync configuration file for xinetd, add the configuration file path
#添加rsync的配置文件路径 [[email protected] ~]# vim /etc/xinetd.d/rsyncservice rsync{ disable = no socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon -- config=/etc/rsyncd/rsyncd.conf #添加配置文件路径 log_on_failure += USERID}[[email protected] ~]# service xinetd restartStopping xinetd: [ OK ]Starting xinetd: [ OK ][[email protected] ~]# netstat -anpt |grep 873tcp 0 0 :::873 :::* listen 2045/xinetd
See what Data Services the RSYNC-1 provides on the client rsync-2
[Email protected] ~]# rsync--list-only [email protected]::test Welcome to Rsync server# now has a data service called Test Step to the local/root directory
This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1641713
centos6.4x64 Minimized installation Deployment rsync