Zookeeper cannot be launched remotely via ssh
Strange issue: The zookeeper works normally on my cluster if I start it using ./zkServer.sh on each machine, respectively.
However, when I try to start it remotely from the master node:
ssh 192.168.xxx.xxx "/opt/apache/zookeeper-3.4.5/bin/zkServer.sh start"
it looks fine:
JMX enabled by default Using config: /opt/apache/zookeeper-3.4.5/bin/../conf/zoo.cfg Starting zookeeper ... STARTED
But actually, zookeeper is not running on that machine, which can be confirmed by jps.
The most strange thing is: If I directly start zookeeper on that node using ./zkServer.sh start then I can successfully stop it remotely from the master node using
ssh 192.168.xxx.xxx "/opt/apache/zookeeper-3.4.5/bin/zkServer.sh stop"
Why could this happen? Any help would be appreciated.
Though after a lot of search I was able to get it, below is the command that successfully starts it.
ssh -i "somekey.pem" username@hostname 'bash -i -c "~/zookeeper-3.4.6/bin/zkServer.sh start"'