zoukankan      html  css  js  c++  java
  • 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是否成功。有显示为成功。

      

      


       


  • 相关阅读:
    Mysql优化
    RabbitMQ教程
    手把手Centos7 安装jenkins详细教程
    FreeMarker学习系列之一
    Vue学习之Vue模拟后台数据
    vuejs学习之新的components组件挂载
    vuejs学习之项目结构解读
    VueJS学习之Vue-cli项目模板
    菜鸟手把手学Shiro之shiro授权流程
    js基石之---es7的decorator修饰器
  • 原文地址:https://www.cnblogs.com/xiangxinhouse/p/11318457.html
Copyright © 2011-2022 走看看