`
qindongliang1922
  • 浏览: 2180849 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
7265517b-f87e-3137-b62c-5c6e30e26109
证道Lucene4
浏览量:117399
097be4a0-491e-39c0-89ff-3456fadf8262
证道Hadoop
浏览量:125815
41c37529-f6d8-32e4-8563-3b42b2712a50
证道shell编程
浏览量:59781
43832365-bc15-3f5d-b3cd-c9161722a70c
ELK修真
浏览量:71224
社区版块
存档分类
最新评论

shell脚本一键安装zookeeper3.4.5

阅读更多
上篇shell脚本写了一键安装solr,本篇我们来看下如何一键安装zookeeper,散仙最近是最自动化安装脚本上迷了,咱们也不会复杂的,先从简单的开始联手,下面进入正题:


安装条件:

1,确保你的JAVA环境是OK的,JDK什么的
2,在root根目录下有一个zookeeper下好的压缩包
3,安装脚本默认放在root目录下
4,所有的安装目录,及压缩包命名,都在本脚本的前面几行定义,散仙为了方便写的比较固定,需要灵活的朋友们,可以做成动态的路径
5,确认上面的4步是ok的,下面就可以运行这个脚本了
6,安装完成后会在最后的状态里面打印出zk的运行情况



下面看散仙的安装日志:

zookeeper-3.4.5/contrib/zkfuse/src/event.cc
zookeeper-3.4.5/contrib/zkfuse/src/event.h
zookeeper-3.4.5/contrib/zkfuse/src/log.cc
zookeeper-3.4.5/contrib/zkfuse/src/log.h
zookeeper-3.4.5/contrib/zkfuse/src/log4cxx.properties
zookeeper-3.4.5/contrib/zkfuse/src/Makefile.am
zookeeper-3.4.5/contrib/zkfuse/src/mutex.h
zookeeper-3.4.5/contrib/zkfuse/src/thread.cc
zookeeper-3.4.5/contrib/zkfuse/src/thread.h
zookeeper-3.4.5/contrib/zkfuse/src/zkadapter.cc
zookeeper-3.4.5/contrib/zkfuse/src/zkadapter.h
zookeeper-3.4.5/contrib/zkfuse/src/zkfuse.cc
zookeeper-3.4.5/contrib/rest/zookeeper-3.4.5-rest.jar
zookeeper-3.4.5/contrib/loggraph/build.xml
zookeeper-3.4.5/contrib/loggraph/src/
zookeeper-3.4.5/contrib/loggraph/zookeeper-3.4.5-loggraph.jar
zookeeper-3.4.5/contrib/loggraph/src/java/
zookeeper-3.4.5/contrib/loggraph/src/java/org/
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/FilterException.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/FilterOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/FilterParser.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/JsonGenerator.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JEntry.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/Log4JSource.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogEntry.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogIterator.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogServer.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogSkipList.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/LogSource.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/MeasureThroughput.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/MergedLogSource.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/RandomAccessFileReader.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/TransactionEntry.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/TxnLogSource.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/FileLoader.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/Fs.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/GraphData.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/JsonServlet.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/NumEvents.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/StaticContent.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/servlets/Throughput.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/AndOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/Arg.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/EqualsOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/GreaterThanOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/LessThanOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/NotOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/NumberArg.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/OrOp.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/StringArg.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/SymbolArg.java
zookeeper-3.4.5/contrib/loggraph/src/java/org/apache/zookeeper/graph/filterops/XorOp.java
zookeeper-3.4.5/contrib/fatjar/build.xml
zookeeper-3.4.5/contrib/fatjar/conf/
zookeeper-3.4.5/contrib/fatjar/src/
zookeeper-3.4.5/contrib/fatjar/zookeeper-3.4.5-fatjar.jar
zookeeper-3.4.5/contrib/fatjar/src/java/
zookeeper-3.4.5/contrib/fatjar/src/java/org/
zookeeper-3.4.5/contrib/fatjar/src/java/org/apache/
zookeeper-3.4.5/contrib/fatjar/src/java/org/apache/zookeeper/
zookeeper-3.4.5/contrib/fatjar/src/java/org/apache/zookeeper/util/
zookeeper-3.4.5/contrib/fatjar/src/java/org/apache/zookeeper/util/FatJarMain.java
zookeeper-3.4.5/contrib/fatjar/conf/mainClasses
zookeeper-3.4.5/conf/configuration.xsl
zookeeper-3.4.5/conf/log4j.properties
zookeeper-3.4.5/conf/zoo_sample.cfg
zookeeper-3.4.5/bin/README.txt
zookeeper-3.4.5/bin/zkCleanup.sh
zookeeper-3.4.5/bin/zkCli.cmd
zookeeper-3.4.5/bin/zkCli.sh
zookeeper-3.4.5/bin/zkEnv.cmd
zookeeper-3.4.5/bin/zkEnv.sh
zookeeper-3.4.5/bin/zkServer.cmd
zookeeper-3.4.5/bin/zkServer.sh
解压完毕!
生成myid文件.......
写入zoo.cfg文件成功!
zk进程号: 2575
检测到zookeeper进程存在,已关闭!
开始启动zk.....
JMX enabled by default
Using config: /root/izk/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... bin/zkServer.sh: line 103: [: /tmp/zookeeper: binary operator expected
STARTED
启动完成....查看zookeeper状态
JMX enabled by default
Using config: /root/izk/zookeeper/bin/../conf/zoo.cfg
Mode: standalone
[root@ganglia ~]# jps
2693 Jps
2651 QuorumPeerMain
[root@ganglia ~]# 



注意散仙的是单机安装,如果想要分布式安装也是非常简单的,用for循环加上ssh,远程执行,再对myid和zoo.cfg稍作配置即可。

散仙上面运行的是多次,运行的,大于第一次运行的,会在后面检测如果已经有zk的进程,会杀死,重启,单机版本,zk成功的标志就是显示状态为standalone


脚本如下:

zkpath=/root/zookeeper-3.4.5.tar.gz
ipath=/root/izk
ipaddress="192.168.46.21"

if  [ ! -e $ipath  ] ; then

echo "路径不存在,创建安装路径!"

mkdir  $ipath
else  

rm -rf $ipath"/"*
echo "路径存在,已清空完毕!"

fi



echo "解压zk到指定目录下!"
sleep 2

tar -zxvf $zkpath -C $ipath


echo "解压完毕!"


cd $ipath
mv zookeeper-3.4.5 zookeeper

confpath=$ipath"/zookeeper"

cd $confpath

mkdir data 

cd data
echo "1" >> myid
echo "生成myid文件......."



cd $confpath"/conf"

mv zoo_sample.cfg zoo.cfg

echo "tikcTime=2000" >> zoo.cfg
echo "dataDir=$confpath/data" >> zoo.cfg
echo "server.1=$ipaddress:2887:3887" >> zoo.cfg

echo "写入zoo.cfg文件成功!"

sleep 3

pid=`ps -ef | grep  zookeeper | gawk '{ print $2}' | head -n 1`

echo "zk进程号: $pid"

sleep 2

#检查进程号是否为空
if [ ! -z $pid  ] ; then

kill -9 $pid

echo "检测到zookeeper进程存在,已关闭!"

fi



echo "开始启动zk....."

cd ..

bin/zkServer.sh start

echo "启动完成....查看zookeeper状态"

bin/zkServer.sh status



分享到:
评论

相关推荐

    安装zookeeper3.4.5.tar.gz软件

    本篇文章将详细解析“安装zookeeper3.4.5.tar.gz”这个过程,以及如何在Eclipse环境中查看和修改其配置文件。 首先,我们要了解的是`tar.gz`文件。这是一种常见的Linux/Unix文件压缩格式,由`tar`命令用于打包多个...

    zookeeper3.4.5.rar

    《Zookeeper 3.4.5:分布式协调服务的核心与实践》 Zookeeper,作为Apache的一个顶级项目,是分布式系统中的关键组件,尤其在大数据、云计算领域,它扮演着核心的协调者角色。Zookeeper 3.4.5是其稳定且广泛使用的...

    Hadoop2.2+Zookeeper3.4.5+HBase0.96集群环境搭建

    Zookeeper3.4.5安装和部署 Zookeeper是Hadoop和HBase集群环境中的核心组件,负责节点管理和配置管理。安装Zookeeper需要下载zookeeper-3.4.5.tar.gz安装包,然后解压缩并配置Zookeeper。 HBase0.96安装和部署 ...

    zookeeper-3.4.5-cdh5.15.1.tar.gz

    《Zookeeper 3.4.5-CDH5.15.1 安装详解》 Zookeeper,作为Apache的一款开源分布式协调服务,是大数据生态系统中的重要组件,它为分布式应用提供高效且可靠的命名服务、配置管理、集群同步、分布式锁等功能。在本篇...

    ZOOKEEPER3.4.5

    **ZooKeeper 3.4.5:服务治理与分布式部署的核心** ZooKeeper 是一个分布式的、开放源码的协调服务,它为分布式应用程序提供简单一致的命名服务、配置管理、分布式同步以及组服务。在Java编程环境中,ZooKeeper ...

    zookeeper3.4.5

    2. **解压Zookeeper**:将下载的`zookeeper-3.4.5`压缩包解压到指定目录,例如`C:\zookeeper-3.4.5`。 3. **配置环境变量**:在系统环境变量中添加`ZOOKEEPER_HOME`指向Zookeeper的安装目录,并在`PATH`变量中添加`...

    云计算 gpmall商城 部署脚本 linux shell脚本一键部署

    gpmall商城系统 linux shell脚本一键部署 mysql 主从,mysql读写分离,redis部署,zookeeper,kafka集群部署

    zookeeper-3.4.5.tar.gz(安装包).rar

    Zookeeper作为Hadoop的资源调度中心,应用十分广泛,有需要的自行下载 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为...

    zookeeper一键式安装脚本

    zookeeper一键式安装shell脚本,无需手动搭建集群环境,脚本运行即可自动配置

    zookeeper3.4.5.tgz的安装包

    标题中提到的"zookeeper3.4.5.tgz"是Zookeeper 3.4.5版本的Linux发行版安装包,以tar.gz格式压缩。这种格式是Linux环境下常见的软件打包方式,通过tar命令可以解压并提取文件内容。 在Linux系统中安装Zookeeper ...

    zookeeper-3.4.5.jar

    《Zookeeper 3.4.5.jar:Java开发中的关键组件》 Zookeeper是一个分布式协调服务,由Apache软件基金会开发并维护,它在分布式系统中扮演着重要角色,尤其是在Java开发环境中。Zookeeper 3.4.5.jar是Zookeeper的一个...

    Linux版zookeeper-3.4.5.tar.gz

    总之,Linux版的Zookeeper-3.4.5是一个强大而可靠的分布式协调服务,它的安装和使用对于理解和掌握分布式系统的设计与实现具有重要价值。通过深入学习和实践,你可以更好地利用ZooKeeper来构建和管理高可用、高性能...

    zookeeper-3.4.5-cdh5.15.2.tar.gz

    在大数据领域,Zookeeper扮演着至关重要的角色,特别是在CDH(Cloudera Distribution Including Apache Hadoop)这样的企业级Hadoop发行版中,Zookeeper 3.4.5-cdh5.15.2是其重要组成部分。 Zookeeper的核心特性...

    zookeeper-3.4.5-cdh5.16.2.tar.gz

    《Zookeeper-3.4.5-cdh5.16.2:分布式协调服务的核心解析》 Apache ZooKeeper,一个高度可靠的分布式协调系统,是大数据生态中的重要组件。本资源包"zookeeper-3.4.5-cdh5.16.2.tar.gz"包含了Zookeeper的3.4.5版本...

    zookeeper-3.4.5。

    在实际使用中,我们可以通过`zookeeper-3.4.5.tar.gz`这个压缩包获取到Zookeeper的源代码、文档以及相关的配置文件。`zookeeper.docx`可能包含更详细的Zookeeper使用指南、配置教程或案例分析,供开发者学习参考。 ...

    zookeeper-3.4.5.jar zookeeper-3.4.5.jar

    zookeeper-3.4.5.jar; zookeeper-3.4.5.jar; zookeeper-3.4.5.jar;

    zookeeper-3.4.5

    《Zookeeper-3.4.5:分布式协调服务的核心与应用》 Zookeeper,作为Apache的一个顶级项目,是分布式应用程序协调服务的开源实现,它提供了一种简单有效的原语集,使得分布式系统的开发者能够处理命名服务、配置管理...

Global site tag (gtag.js) - Google Analytics