sheel命令 centos7 环境 zookeeper357自动安装

/opt/download/zookeeperinstall/zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/software/zookeeper357/mydata
server.1=singlefangliang:2888:3888
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

2 ~/installsheel/zookeepersixthinstall.sh

#!/bin/bash
#注意事项 
	#1/opt/download中有apache-zookeeper-3.5.7-bin.tar.gz
	#提前写好配置文件 /opt/download/zookeeper/zoo.cfg
source /etc/profile
ENV_DIR='/etc/profile.d/'
SOFTWARE_DIR='/opt/software/'
DOWNLOAD_DIR='/opt/download/'
ZOOKEEPER_ENV='#zookeeper;export-ZOOKEEPER_HOME=/opt/software/zookeeper357;export-PATH=$ZOOKEEPER_HOME/bin:$PATH'

#删除myenv.sh 文件中的配置内容
function removeIfExists(){
        if [ $# -lt 2 ]
        then
                echo '参数给的太少'
        fi
        sed -rin "/^#.*?$1/,+$2d" $ENV_DIR'myenv.sh'
}   

function addEnv(){
	DIR="$1"
        DIR=${DIR//;/ }
        for item in $DIR
        do
                sed -in '$a'$item $ENV_DIR'myenv.sh'
        done
        sed -in 's/-/ /g' $ENV_DIR'myenv.sh'
        echo 'myenv.sh添加zookeeper配置文件信息'
}

RST=`ls $SOFTWARE_DIR|grep zookeeper`
if [[ -z $RST ]]
then
        echo '原机未安装zookeeper'
        tar -zxf $DOWNLOAD_DIR'apache-zookeeper-3.5.7-bin.tar.gz' -C $SOFTWARE_DIR
	mv /opt/software/apache-zookeeper-3.5.7-bin /opt/software/zookeeper357
        echo '安装完毕'
else
        rm -rf $SOFTWARE_DIR'zookeeper357'
        echo '原机安装过hive'
        tar -zxf $DOWNLOAD_DIR'apache-zookeeper-3.5.7-bin.tar.gz' -C $SOFTWARE_DIR
				echo $SOFTWARE_DIR'--------------------------------------------'
	mv /opt/software/apache-zookeeper-3.5.7-bin /opt/software/zookeeper357
        echo '删除原hive 重新安装成功'
fi


RST=`ls $ENV_DIR|grep myenv.sh`
if [[ -z $RST ]]
then
	touch $ENV_DIR'myenv.sh'
	echo '原myenv.sh配置文件不存在,新建完成'
else
	echo '原机存在myenv.sh配置文件'
	removeIfExists zookeeper 2
	echo '原机myenv.sh中的zookeeper配置文件信息已删除'
fi

addEnv $ZOOKEEPER_ENV

mkdir /opt/software/zookeeper357/mydata
touch /opt/software/zookeeper357/mydata/myid
echo '1'>/opt/software/zookeeper357/mydata/myid
echo '添加文件/opt/software/zookeeper357/mydata/myid中内容写1'

mv /opt/software/zookeeper357/conf/zoo_sample.cfg /opt/software/zookeeper357/conf/zoo.cfg
cat /opt/download/zookeeperinstall/zoo.cfg>/opt/software/zookeeper357/conf/zoo.cfg
cp /opt/software/zookeeper357/conf/zoo.cfg /opt/software/zookeeper357/

source /etc/profile```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值