CentOS 5.5 安装rsync服务
	公司要做团购项目,发布了一个团购网站,我使用CentOS 5.5系统,基于LNMP配置的环境。考虑要同步服务器上的数据,于是便想到了Rsync服务。以前一直在使用Cwrsync,是Windows环境的。第一次在Linux系统下配置该服务,原本认为很简单,在实际操作过程中发现了若干问题,郁闷了几天,最终完全配置成功。整理如下。
	 
	服务器端的配置
	下面为安装步骤:
	一、服务器端配置:
	1、安装xinetd,并修改rsync相关配置
	# yum -y install xinetd
	# vi /etc/xinetd.d/rsync
	如下代码:
	# default: off
	# description: The rsync server is a good addition to an ftp server, as it \
	#       allows crc checksumming etc.
	service rsync
	{
	        disable = yes
	        socket_type     = stream
	        wait            = no
	        user            = root
	        server          = /usr/bin/rsync
	        server_args     = --daemon
	        log_on_failure  += USERID
	}
	将disable = yes改成disable = no
	然后重启xinetd
	# /etc/init.d/xinetd restart
	[
	  注:如果服务器上装有防火墙,需要打开端口,默认端口是873
	  # telnet 127.0.0.1 873
	  Trying 127.0.0.1...
	  telnet: connect to address 127.0.0.1: Connection refused
	  # iptables -A INPUT -s 192.168.0.0/255.255.255.0 -p tcp -m tcp --dport 873 -j ACCEPT
	  # iptables -A INPUT -p tcp -m tcp --dport 873 -j DROP
	]
	 
	2、编写rsync.conf配置文件
	# vi /etc/rsyncd.conf
	内容如下:
	port=873
	uid = nobody
	gid = nobody
	user chroot = no
	max connections = 200
	timeout = 600
	pid file = /var/run/rsyncd.pid
	lock file = /var/run/rsyncd.lock
	log file = /var/log/rsyncd.log
	 
	[backup]
	path = /home/www
	ignore errors
	read only = no
	list = no
	#hosts allow = 192.168.1.0/255.255.255.0
	auth users = root
	secrets file = /etc/rsyncd.secrets
	 
	注释:
	port  #开放端口
	uid = nobody  #进行备份的用户UID,nobody为任何用户
	gid = nobody  #进行备份的组GID,nobody为任意组
	use chroot = no  #如果"use chroot"指定为true,那么rsync在传输文件以前首先chroot到path参数所指定的目录下。这样做的原因是实现额外的安全防护,但是缺点是需要以root权限,并且不能备份指向外部的符号连接所指向的目录文件。默认情况下chroot值为true。但是这个一般不需要,所以我选择no或false
	list = no  #不允许列清单
	max connections = 200 #最大连接数
	timeout = 600 #覆盖客户指定的IP超时时间,也就是说rsync服务器不会永远等待一个崩溃的客户端。
	
相关新闻>>
- 发表评论
- 
				
- 最新评论 进入详细评论页>>







