阿里云centos 7下安装配置Zookeeper

安装环境:

JDK 1.8

Zookeeper-3.4.9

Zookeeper是java开发的可以运行在windows、linux环境。需要先安装jdk。

1.JDK安装

注意:rpm与软件相关命令 相当于window下的软件助手 管理软件

步骤:

1)查看当前Linux系统中是否已经安装jdk,

 输入:rpm -qa|grep java

 

 

2) 如果系统中已经预安装了OpenJdk,则需要卸载这两个openJDK

卸载命令: rpm -e --nodeps 要卸载软件

 

3)上传JDk到Linux

4)安装jdk运行需要的插件yum install glibc.i686(选做)

5)解压jdk/usr/local tar xvf jdk-7u71-linux-i586.tar.gz C /usr/local

6)配置jdk环境变量,打开/etc/profile配置文件,将下面配置拷贝进去

#set java environment
    JAVA_HOME=/usr/local/jdk1.7.0_71
    CLASSPATH=.:$JAVA_HOME/lib.tools.jar
    PATH=$JAVA_HOME/bin:$PATH
    export JAVA_HOME CLASSPATH PATH 

7)重新加载配置文件 

 2.Zookeeper安装步骤:

第一步:安装jdk

第二步: 创建/usr/local/zookeeper 文件夹,zookeeper的压缩包上传到linux系统的该文件夹中

mkdir -p /usr/local/zookeeper

第三步:解压缩压缩包

tar -zxvf zookeeper-x.x.x.tar.gz

mv zookeeper-x.x.x  zookeeper 

第四步:进入zookeeper目录,创建data、logs文件夹

cd /usr/local/zookeeper/zookeeper

mkdir -p data

mkdir -p logs

第五步:进入到 /usr/local/zookeeper/zookeeper/conf 目录中

 cd zookeeper/conf/

将 zoo_sample.cfg 文件的重命名为为 zoo.cfg: mv zoo_sample.cfg zoo.cfg

用 vim 打开 zoo.cfg 文件并修改其内容为如下:

vim zoo.cfg

 

修改data属性:dataDir=/usr/local/zookeeper/zookeeper/data

增加日志文件属性:dataLogDir=/usr/local/zookeeper/zookeeper/logs

保存并关闭 zoo.cfg 文件

用 vim 打开 /etc/ 目录下的配置文件 profile:

[root@iZm5e2hgyz7c2q62xndkw4Z ~]# vim /etc/profile

 

 

 

 

并在其尾部追加如下内容

export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH

 

 使 /etc/ 目录下的 profile 文件即可生效

[root@iZm5e2hgyz7c2q62xndkw4Z ~]# source /etc/profile

启动 zookeeper 服务

[root@iZm5e2hgyz7c2q62xndkw4Z ~]# zkServer.sh start

打印如下信息则表明启动成功:

 

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... START

 

 查询 zookeeper 状态 :

[root@iZm5e2hgyz7c2q62xndkw4Z ~]# zkServer.sh status

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone

关闭 zookeeper 服务:

#zkServer.sh stop

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

 

重启 zookeeper 服务:

 #zkServer.sh restart

 

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper/bin/../conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper/bin/../conf/zoo.cfg
Stopping zookeeper ... no zookeeper to stop (could not find file /usr/local/zookeeper/zookeeper/data/zookeeper_server.pid)
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 

 

 

posted @ 2020-06-14 17:08  慕容天白  阅读(629)  评论(0编辑  收藏  举报