/*

centos7 安装zookeeper

下载安装包

进入安装目录

cd /home/install/

下载

[root@localhost install]#wget https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz

下载完成

安装

1)创建和解压至安装目录

  mkdir /usr/local/zookeeper
  tar -xvf zookeeper-3.4.14.tar.gz -C /usr/local/zookeeper/

2)拷贝样本配置为主配置

进入配置目录,赋值拷贝样本

[root@localhost install]# cd /usr/local/zookeeper/zookeeper-3.4.14/conf/
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg

3)简单修改配置

创建数据存储目录与日志目录

[root@localhost conf]# mkdir /usr/local/zookeeper/zookeeper-3.4.14/dataDir
[root@localhost conf]# mkdir /usr/local/zookeeper/zookeeper-3.4.14/dataLogDir

修改数据存储和日志目录
[root@localhost conf]# vim /usr/local/zookeeper/zookeeper-3.4.14/conf/zoo.cfg

配置zookeeper环境变量

1)依赖JVM环境,所以JVM与zookeeper环境变量都要配置

vim /etc/profile

在尾部追加

期间遇到找不到JAVA_HOME,路径不对,可以使用java -version查看安装版本,没有安装的话,运行命令:yum -y install java-1.8.0-openjdk.x86_64
JAVA_HOME 可以使用whereis java查看路径

2)生效

source /etc/profile

测试

启动

    /usr/local/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start

连接

    /usr/local/zookeeper/zookeeper-3.4.14/bin/zkCli.sh

增删改查

开机启动

编辑zookeeper.service文件

    vim /usr/lib/systemd/system/zookeeper.service
加入如下内容

[Unit]
Description=zookeeper
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start
ExecReload=/usr/local/zookeeper/zookeeper-3.4.14/bin/zkServer.sh restart
ExecStop=/usr/local/zookeeper/zookeeper-3.4.14/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target

生效

    systemctl daemon-reload

改变文件权限

    chmod 777 /usr/lib/systemd/system/zookeeper.service

systemctl开机启动zookeeper

    systemctl enable /usr/lib/systemd/system/zookeeper.service
    或
    systemctl enable /usr/lib/systemd/system/zookeeper

查看是否开机启动

    systemctl is-enabled zookeeper.service

systemctl取消开机启动

    systemctl disable zookeeper.service

posted @ 2020-04-27 19:02  Enthusiast  阅读(176)  评论(0编辑  收藏  举报