• linux中zookeeper开机自启动和注册为服务


    1.安装jdk,zookeeper就不说啦,自己搜索下。

    2.开机自启动和注册为服务。

    (1)开机自启动:编辑/etc/rc.d/rc.local文件,添加zkServer.sh路径。

      vi /etc/rc.d/rc.local

      #!/bin/sh

     # This script will be executed *after* all the other init scripts.
     # You can put your own initialization stuff in here if you don't
     # want to do the full Sys V style init stuff.
    
     touch /var/lock/subsys/local
     export JAVA_HOME=/usr/java/jdk1.8.0_221        --jdk的路径,自己安装的目录
     /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start   --zookeeper的zkServer.sh的路径

    (2)注册为服务:到/etc/rc.d/init.d目录下添加,zookeeper脚本

      cd /etc/rc.d/init.d

      touch zookeeper

      ls -al                        --查看到没有执行权限,修改权限

      chmod +x zookeeper

      vi zookeeper     -- 打开zookeeper编辑脚本,下面为要 编辑的内容

      #! /bin/bash

      #chkconfig: 2345 20 90    -- 系统启动级别为2 3 4 5 启动优先级20 关闭优先权90。必须,否则执行chkconfig命令是会报错

      #description:zookeeper

      #processname:zookeeper

      export JAVA_HOME=/usr/java/jdk1.8.0_221

      case $1 in
        start) su root /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh start;;
        stop) su root /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh stop;;
        status) su root /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh status;;
        restart) su /home/zookeeper/zookeeper-3.4.14/bin/zkServer.sh restart;;
        *) echo "require start|stop|status|restart" ;;
      esac

    添加好后保存。测试:

      service zookeeper start

    启动成功后则添加服务成功了。

    (3)将服务添加为开机启动。

      chkconfig --add zookeeper                --zookeeper为刚才注册的服务

      chkconfig --list                                   --查看刚才添加的zookeeper是否成功。有显示为成功。

      

      


       


  • 相关阅读:
    交换机与路由器之间进行链路聚合知识总结
    003 测试成功只是完整更改项目的本地仓库路径,不更改内容的情况下(特别是.git没有更改的情况下),是否依然可以成功上传到Github远程仓库?
    十、MySQL连接
    Spring Boot中的Spring Security
    python中logging库使用记录
    unittest接口测试:数据驱动的两种实现(一个测试用例跑多份测试数据)
    python 类中的三种方法
    192405实验八 Web安全
    picture1
    电影随笔
  • 原文地址:https://www.cnblogs.com/xiangxinhouse/p/11318457.html
Copyright © 2020-2023  润新知