龙空技术网

CentOS 8 设置Zookeeper开机启动

架构笔记 145

前言:

现时姐妹们对“centos6开机启动”大致比较关心,你们都需要知道一些“centos6开机启动”的相关内容。那么小编在网摘上网罗了一些有关“centos6开机启动””的相关内容,希望咱们能喜欢,各位老铁们快快来了解一下吧!

首先,查询JAVA_HOME和ZOOKEEPER_HOME环境变量,如下所示:

[root@centos-160 ~]# echo $JAVA_HOME/usr/java/jdk1.8.0_202[root@centos-160 ~]# echo $ZOOKEEPER_HOME/usr/local/zookeeper-3.7

然后,按照如下步骤配置Zookeeper系统服务。

1、创建文件

vim /etc/rc.d/init.d/zookeeper

文件内容如下所示:

#!/bin/bash#chkconfig:2345 20 90#description:zookeeper#processname:zookeeperexport JAVA_HOME=/usr/java/jdk1.8.0_202case $1 in start) su root /usr/local/zookeeper-3.7/bin/zkServer.sh start;; stop) su root /usr/local/zookeeper-3.7/bin/zkServer.sh stop;; status) su root /usr/local/zookeeper-3.7/bin/zkServer.sh status;; restart) su root /usr/local/zookeeper-3.7/bin/zkServer.sh restart;; *) echo "require start|stop|status|restart" ;;esac

2、加可执行权限

chmod +x /etc/rc.d/init.d/zookeeper

3、注册为系统服务

[root@centos-160 ~]# chkconfig --add zookeeper

4、添加开机自启动

[root@centos-160 ~]# chkconfig zookeeper on

5、查看服务列表

[root@centos-160 ~]# chkconfig --listNote: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use 'systemctl list-unit-files'. To see services enabled on particular target use 'systemctl list-dependencies [target]'.zookeeper 0:off 1:off 2:on 3:on 4:on 5:on 6:off

6、重启验证

重启CentOS,然后执行jps 查看Zookeeper 进程是否运行中:

[root@centos-160 ~]# jps1233 QuorumPeerMain2033 Jps

查看Zookeeper运行状态:

[root@centos-160 ~]# service zookeeper statusZooKeeper JMX enabled by defaultUsing config: /usr/local/zookeeper-3.7/bin/../conf/zoo.cfgClient port found: 2181. Client address: localhost. Client SSL: false.Mode: leader

标签: #centos6开机启动 #centos设置启动项 #centos开机启动命令