3.1. The second option of the content of the 2 document use the VIM command to modify the contents of the file:
#!/bin/bash
#chkconfig: 2345
#description: Service zookeeper
export java_home=/opt/java/ jdk1.8.0_121
export zoo_log_dir=/opt/zookeeper/log
zookeeper_home=/opt/zookeeper/zookeeper-3.4.10
case "in start" su root ${zookeeper_home}/bin/zkserver.sh start;;
Start-foreground) su root ${zookeeper_home}/bin/zkserver.sh start-foreground;;
Stop) su root ${zookeeper_home}/bin/zkserver.sh stop;;
Status) su root ${zookeeper_home}/bin/zkserver.sh status;;
Restart) su root ${zookeeper_home}/bin/zkserver.sh restart;;
upgrade) su root ${zookeeper_home}/bin/zkserver.sh upgrade;;
print-cmd) su root ${zookeeper_home}/bin/zkserver.sh print-cmd;;
*) echo "Requirestart|start-foreground|stop|status|restart|print-cmd";;
Esac
3.1.3 Other Notes Note 1: The command to create a new file is touch, and the command to edit the file with VI and VIM is OK. If you don't use the VI and VIM commands, edit the files directly locally and upload them with remote tools, but be aware that if you use a local Windows system, you need to convert the files to UNIX format. There are many conversion tools, such as using notepad++
as shown in figure:
NOTE 2: The portion of the file head # annotation in the two scenarios is not less, and the zookeeper path needs to be modified for your own in the file, such as the JDK path. 3.2 Execute a series of commands
To add executable permissions for the new/etc/rc.d/init.d/zookeeper file, the command is:
chmod +x/etc/rc.d/init.d/zookeeper
Add the zookeeper script to the boot entry, and the command is:
chkconfig--add Zookeeper
as shown in figure:
If you want to see if you added success, the command is:
chkconfig--list
as shown in figure:
3.3 Perform test to see if boot up
Restart the machine using the command:
reboot
Method One
View the status of zookeeper
Restart the machine, and then execute the command without manually starting the zookeeper:
Service Zookeeper Status
As shown in figure:
Method Two
to see if Port 2181 is enabled, execute the command:
lsof-i:2181
As shown in figure:
Method Three
To view the network status, execute the command:
Netstat-lntup
As shown in figure:
4 Error and resolution 4.1 service zookeeper does not support Chkconfig
Perform chkconfig--add zookeeper error :
Servicezookeeper does not support Chkconfig
problem Reason and resolution:
The header in the/etc/rc.d/init.d/zookeeper script does not add the following words (description can be written casually):
#!/bin/bash
#chkconfig: 2345
#description: Service Zookeeper
4.2Error contacting service. It is probably not running Execute Service Zookeeper status error :
JMX enabled by default
usingconfig:/opt/zookeeper/zookeeper-3.4.10/bin/. /conf/zoo.cfg
errorcontacting Service. It is probably not running.
problem Reason and resolution:
/etc/rc.d/init.d/zookeeper is not configured, please see 3.1.1 and 3.1.2 configuration, inside must have export java_home This sentence, the following path is your own JDK installation path.
As for export Zoo_log_dir=/opt/zookeeper/log This sentence is optional, meaning to specify zookeeper boot log storage directory, if the directory does not exist, you must manually create one. 5 Downloads related to this blog
The above items can either be downloaded from the Internet or can be downloaded from here, including configuration files.
Download address is:http://download.csdn.net/detail/pucao_cug/9834762