第一步:使用vim /etc/rc.d/rc.local
[root@localhost Desktop]# vim /etc/rc.d/rc.local
第二步:查找JDK的安装目录
[root@localhost Desktop]# which java
/usr/bin/java
[root@localhost Desktop]# ls -lrt /usr/bin/java
lrwxrwxrwx. 1 root root 22 Oct 20 09:36 /usr/bin/java -> /etc/alternatives/java
[root@localhost Desktop]# ls -lrt /etc/alternatives/java
lrwxrwxrwx. 1 root root 46 Oct 20 09:36 /etc/alternatives/java -> /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
[root@localhost Desktop]#
得到jdk的安装目录:/usr/lib/jvm/jre-1.8.0-openjdk.x86_64
第三步:查找zookeeper的安装目录
zookeeper的安装目录:/root/zookeeper-3.4.6/bin
zookeeper的安装目录相信大家应该都能找到。
第四步:添加参数
#!/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/lib/jvm/jre-1.8.0-openjdk.x86_64
/root/zookeeper-3.4.6/bin/zkServer.sh start
好了,到这就完成了,大家可以重启Linux看看检查是否自启成功。
|