Set Zookeeper boot __zookeeper

Source: Internet
Author: User
Tags zookeeper

Two ways to achieve power-on self-boot

First: Direct modification of/etc/rc.d/rc.local files

In the/etc/rc.d/rc.local file, you need to enter two lines, where export java_home=/usr/java/jdk1.8.0_112 is necessary, or startup is not successful, everyone according to their own JDK installation location changes. The other line/usr/local/zookeeper-3.4.5/bin/zkserver.sh start is our zookeeper start command. Once configured, restart the virtual machine, and you will find that you are ready to boot.

[Root@zookeeper ~]# vim/etc/rc.d/rc.local 

#!/bin/sh
# This script'll be
executed *after* It scripts.
# You can put your own initialization stuff in-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_112
/usr/local/zookeeper-3.4.5/bin/ zkserver.sh start
The second kind: make the Zookeeper service

1, into the/ETC/RC.D/INIT.D directory, a new zookeeper script

[Root@zookeeper ~]# cd/etc/rc.d/init.d/
[root@zookeeper init.d]# pwd/etc/rc.d/init.d] [
Root@zookeeper init.d]# Touch Zookeeper
2, add execution permissions to the script

[Root@zookeeper init.d]# chmod +x Zookeeper
3, the use of the command vim zookeeper for editing, in the script entered the following content, which with the above attention to the same line to add export java_home=//usr/java/jdk1.8.0_112, otherwise it will not start normally.
[Root@zookeeper init.d]# vim zookeeper 

#!/bin/bash
#chkconfig: 2345
#description: Zookeeper
# Processname:zookeeper
Export java_home=//usr/java/jdk1.8.0_112 case in
        start) su root/usr/local/ zookeeper-3.4.5/bin/zkserver.sh start;;
        Stop) su root/usr/local/zookeeper-3.4.5/bin/zkserver.sh stop;;
        Status) su root/usr/local/zookeeper-3.4.5/bin/zkserver.sh status;;
        restart) su/usr/local/zookeeper-3.4.5/bin/zkserver.sh restart;;
        *) echo "require Start|stop|status|restart";;
Esac
4, use the service Zookeeper Start/stop command to try to start the shutdown zookeeper, use service zookeeper status to view the zookeeper status.

First look at the start and status

[Root@zookeeper init.d]# Service zookeeper start
JMX enabled by default
Using config:/usr/local/ zookeeper-3.4.5/bin/.. /conf/zoo.cfg
Starting Zookeeper ... Started
[root@zookeeper init.d]# Service Zookeeper status
JMX enabled by default
Using config:/usr/local/ zookeeper-3.4.5/bin/.. /conf/zoo.cfg
Mode:standalone
Then look at the shutdown and the status

[Root@zookeeper init.d]# Service zookeeper stop
JMX enabled by default
Using config:/usr/local/zookeeper-3.4.5 /bin/.. /conf/zoo.cfg
Stopping zookeeper ... STOPPED
[root@zookeeper init.d]# Service Zookeeper status
JMX enabled by default
Using config:/usr/ local/zookeeper-3.4.5/bin/.. /conf/zoo.cfg
Error Contacting service. It is probably not running.
[Root@zookeeper init.d]#
5. Add to power-on self-starter

After the addition, we use Chkconfig--list to see if the boot service has our zookeeper, as shown below, we can see that the last line is our zookeeper service.

[Root@zookeeper init.d]# chkconfig--list auditd 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Close Blk-availability 0: Close 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off Crond 0: Turn off 1: Turn off 2: Enable 3: Enable 4: Turn on 5: Enable 6: Close Ip6tables 0: Turn off 1: Turn off 2: Enable 3: Enable 4: Enable 5: Enable 6: Close Iptables 0: off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off iSCSI 0: Close 1: Close 2: Close 3: Enable 4: Enable 5: Enable 6: Turn off Iscsid 0 : Turn off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Turn off Lvm2-monitor 0: Turn off 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off Mdmonitor 0: Turn off 1: Turn off 2: Enable 3: Enable 4          	: Enable 5: Enable 6: Turn off MULTIPATHD 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close Netconsole 0: Close 1: Close 2: Close 3: Close 4: Close Netfs	0: Close 1: Close 2: Turn off 3: Enable 4: Enable 5: Enable 6: Close Network 0: Close 1: Close 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off Postfix 0: Turn off 1: Off	2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off Rdisc 0: off 1: Close 2: Close 3: Close 4: Close 5: Close 6: Off Restorecond 0: Shut 1: Close 2: Close 3: Close           	6: Close Rsyslog 0: Close 1: Close 2: Enable 3: Enable 4: Enable 5: Enable 6: Close SASLAUTHD 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close sshd 0: Turn off 1: Close 2: Enable 3: Enable 4: KaiWith 5: Enable 6: Close Udev-post 0: Close 1: Enable 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off Zookeeper 0: Close 1: Close 2: Enable 3: Enable 4: Enable 5: Enable 6: Turn off
 
The boot configuration is ready, so let's reboot and try again, as shown below. Everything's fine. This means that our startup has been successful.

[Root@zookeeper ~]#/usr/local/zookeeper-3.4.5/bin/zkserver.sh status
JMX enabled by default
Using config:/ usr/local/zookeeper-3.4.5/bin/.. /conf/zoo.cfg
Mode:standalone












Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.