web123456

zookeeper - FAQs in Starting zookeeper

Original address:/luhao8415/item/23c6e7f075aa18b730c1993a

Recently, there are often problems with starting zookeeper. Please organize it and post it. You can also refer to it in the future. .

1. After starting zookeeper, noClassFound and other errors appear, such as:

Exception in thread "main" : method with signature (); was not found.

at org.apache..registerLog4jMBeans(:48)

at (:114)

at (:103)

at (:7

Possible reason is thatserverThe jdk version of the sys- or environment variable is not set properly.

For example, the original Linux already has jdk-1.4, and then the new version of jdk-1.6 is installed. After we follow the steps of the online tutorial to install zookeeper and set environment variables,

echo $JAVA_HOME displays java-1.6,

However, using the java -version command, it is found that java-1.4 is still displayed, indicating that the environment variables are not matched well. The jdk version read by zookeeper is still the old version of jdk-1.4.

The solution is to end the /etc/bashrc file.

export JAVA_HOME=/usr/java/jdk1.6.0_23

export JRE_HOME=$JAVA_HOME/jre

export PATH=$JAVA_HOME/bin:$PATH

//Note here that $PATH should be placed at the tail instead of at the head. There is an installation tutorial on the Internet that says $PATH:$JAVA_HOME/bin, so what zookeeper reads will be the old version of jdk in $PATH and an error occurs.

export CLASSPATH=.:$JAVA_HOME/lib/*.jar

2. When a machine or machine repeatedly appears, it cannot open channel to xxxx:2888/3888, an error is reported (such as the error cannot be synchronized with the leader, etc.), and the election cannot be completed (this error has always occurred before, but sometimes it is not, I don’t know why).

The possible reason is that the firewall is turned on, which causes the port of a certain machine to not be turned on, and generally 2888 cannot be turned on. Many under LinuxdistributedThe application will ask for a firewall to be turned off. . . So just turn it off. Today, the firewall will be turned off directly and zookeeper will start normally.

Use the service iptables status command to view and display a series of messages, indicating that the firewall is in the open state; you can use the service iptables stop to close the firewall. But this is just a temporary shutdown of the firewall.

To makesystemIf the firewall is not automatically started at startup, you can use the command chkconfig –list iptables to view the firewall information and chkconfig iptables off to close the firewall. To open it later, use the chkconfig iptables on command.

---

PS This morning I found that the firewall was turned on again, and it seemed to be useless. Or use the following three commands to close.

chkconfig --level 35 iptables off ; /etc//iptables stop; iptables -P INPUT DROP

3. Zookeeper can start normally, but the following error is displayed:

Starting zookeeper…

./: line 80: /home /sysdata/zookeeper/zookeeper-data/zookeeper_server.pid: No such file or directory

STARTED

The location of the generated pid file initiated by zookeeper is specified in the configuration file: dataDir=/home/sysdata/zookeeper/zookeeper-data, but we found that the pid was not generated. And it is obvious that it cannot be successful if you want to stop zookeeper:

Stopping zookeeper ...

error: could not find file /zookeeper_server.pid。

After asking the big guy, this problem that I had a headache for a long time was finally solved. . .

It turns out that there is an extra space before assigning the dataDir path in my file! When zookeeper reads this configuration file, it will also read the space into the file name (why is the script not smart). After deleting this space, it will be normal to start and close it!

The file is not smart, and there is also a space after the comment #.



Others: /shenlan211314/article/details/6187034