/bin/zkEnv.sh: Syntax error: "(" unexpected (expecting "fi")

1. Zookeeper 执行客户端的启动脚本时,出错提示:/bin/zkEnv.sh: Syntax error: "(" unexpected (expecting "fi"),如下:
/bin/zkEnv.sh: Syntax error:

2. 解决方案(顺序执行以下几个操作)

(1)root@host8:~# cd /bin/
(2)root@Ubuntu:/bin# ls -l /bin/sh
    lrwxrwxrwx 1 root root 4  5月 29  2017 /bin/sh -> dash(默认)
(3)root@Ubuntu:/bin# ln -sf bash /bin/sh
(4)root@Ubuntu:/bin# ln -sf bash /bin/sh
(5)root@Ubuntu:/bin# ls -l /bin/sh
    lrwxrwxrwx 1 root root 4  8月  3 06:20 /bin/sh -> bash  //已经改变


//找到2181端口号所对应的进程id,kill掉,然后重启zookeeper服务
root@Ubuntu:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin# lsof -i:2181
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    15498 root   26u  IPv6 367868      0t0  TCP *:2181 (LISTEN)

root@Ubuntu:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin# kill -9 15498

//重新启动zookeeper服务
root@Ubuntu:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin# sh zkServer.sh start ../conf/zoo.cfg &
[1] 17407
root@Ubuntu:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin# ZooKeeper JMX enabled by default
Using config: ../conf/zoo.cfg
Starting zookeeper ... STARTED

[1]+  已完成               sh zkServer.sh start ../conf/zoo.cfg



重新登陆zookeeper客户端,即可成功

 sh zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2018-08-03 06:22:25,125 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
2018-08-03 06:22:25,131 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=Ubuntu
2018-08-03 06:22:25,132 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_162
2018-08-03 06:22:25,136 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2018-08-03 06:22:25,136 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/usr/local/java/jdk1.8.0_162/jre
2018-08-03 06:22:25,136 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../build/classes:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../build/lib/*.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../lib/slf4j-api-1.6.1.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../lib/netty-3.10.5.Final.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../lib/log4j-1.2.16.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../lib/jline-0.9.94.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../zookeeper-3.4.10.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../src/java/lib/*.jar:/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin/../conf:.:/usr/local/java/jdk1.8.0_162/lib:/usr/local/java/jdk1.8.0_162/jre/lib:
2018-08-03 06:22:25,137 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2018-08-03 06:22:25,137 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2018-08-03 06:22:25,137 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=
2018-08-03 06:22:25,137 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2018-08-03 06:22:25,138 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2018-08-03 06:22:25,138 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.13.0-144-generic
2018-08-03 06:22:25,138 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2018-08-03 06:22:25,138 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2018-08-03 06:22:25,139 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/home/lxg/code/2018-08-02_mongoose.tar.gz_can_use/zookeeper/zookeeper-3.4.10/bin
2018-08-03 06:22:25,147 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@7aec35a
Welcome to ZooKeeper!
2018-08-03 06:22:25,213 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2018-08-03 06:22:25,409 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@876] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
[zk: 127.0.0.1:2181(CONNECTING) 0] 2018-08-03 06:22:25,485 [myid:] - INFO  [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x164fcbb89600000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null


博主最新开了一个网店 [ 点击查看->华少潮牌男装店 ],款式多样,价格实惠,质量保证。欢迎各位读者进店查看。购买时请说明是CSDN读者,优惠更大。期待你的光临!!!

你可能感兴趣的:(Zookeeper)