首页 > 其他 > 详细

rsync同步服务部署

时间:2017-02-02 16:40:18      阅读:229      评论:0      收藏:0      [点我收藏+]
#!/bin/bash
#rsync no system user
#xinetd rsync(873)
#server
#/root/
#读取文件记录集
function ReadLine()
{
   cat $1 | while read line
   do
     if [ "$2" = "$line" ]; then
        return 1
     else
        result=0
     fi
   done
   return $result
}

rpm -ivh xinetd-2.3.14-39.el6_4.x86_64.rpm
rpm -ivh rsync-3.0.6-9.el6_4.1.x86_64.rpm

sed -i "6c disable = no" /etc/xinetd.d/rsync
chkconfig xinetd on
/etc/init.d/xinetd start

rsyncConf=/etc/rsyncd.conf
rsyncArray=(
"uid = nobody"                         
"gid = nobody"                           
"address =192.168.2.63"    #rsync服务主机IP                   
"port =873"                               
"hosts allow =192.168.2.64"    #允许同步的服务器主机IP                    
"use chroot = yes"                               
"max connections =5"                             
"pid file =/var/run/rsyncd.pid"        
"lock file =/var/run/rsync.lock"         
"log file =/var/log/rsyncd.log"          
"motd file =/etc/rsyncd.motd"
"[wwwroot]"            
"path =/var/www/html"                       
"comment = used for web-data root"    
"read only = yes"                                 
"list = yes"                                         
"auth users = rsyncuser"         #虚拟用户名               
"secrets file =/etc/rsync.passwd"        
)

[ -f /etc/rsyncd.conf ]
if [ $? -eq 0 ];then
	exit 0
else
	touch $rsyncConf
fi

for ((i = 0; i < ${#rsyncArray[@]}; i++))
do
  ReadLine $rsyncConf "${rsyncArray[$i]}"
  if [ $? = 0 ]; then
    echo ${rsyncArray[$i]} >> $rsyncConf
  fi
done

echo "Welcome to Backup Server" > /etc/rsyncd.motd #登录提示信息自行更改
echo "rsyncuser:123" >> /etc/rsync.passwd #账户密码自行更改
chmod 600 /etc/rsync.passwd
/etc/init.d/xinetd restart


本文出自 “何阳光” 博客,请务必保留此出处http://heyangguang.blog.51cto.com/10930823/1894553

rsync同步服务部署

原文:http://heyangguang.blog.51cto.com/10930823/1894553

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!