zookeeper啟動後檢視狀態報Error contacting service. It is probably not running.錯誤
阿新 • • 發佈:2019-01-06
在叢集上安裝並啟動zookeeper後,檢視zookeeper狀態,出現以下情況:
[[email protected] zookeeper-3.4.12]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/modules/zookeeper-3.4.12/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
但實際上zookeeper程序是啟動了並且正常執行的:
[[email protected] hadoop]$ zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/modules/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... already running as process 16783.
使用jps命令檢視已啟動程序,報錯如下:
[[email protected] zookeeper-3.4.12]$ jps
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
從報錯可以看出是Java虛擬機器(JVM)分配的記憶體大於系統可用記憶體數,所以沒有足夠的空間分配給JVM來建立Object。
解決方法:可以看看機器的系統記憶體目前還剩下多少,保證足夠啟動Java時設定的記憶體。
在/etc/profile中設定JVM引數並生效
export _JAVA_OPTIONS="-Xmx10240M"
重新啟動zookeeper,檢視狀態,不再報錯。
[hadoop@oceanbase06 zookeeper-3.4.12]$ zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/modules/zookeeper-3.4.12/bin/../conf/zoo.cfg
Mode: follower
[hadoop@oceanbase06 zookeeper-3.4.12]$
[hadoop@oceanbase06 zookeeper-3.4.12]$ jps
Picked up _JAVA_OPTIONS: -Xmx10240M
17528 Jps
17326 QuorumPeerMain
如果JVM的-Xmx設定太大,可能會報如下錯誤:
[[email protected] ~]$ java -version
Picked up _JAVA_OPTIONS: -Xmx10240M
Error occurred during initialization of VM
Could not reserve enough space for the card marking array