怎样将zookeeper的mode由standalone改成集群形式'
答案:2 悬赏:0
解决时间 2021-01-21 08:59
- 提问者网友:川水往事
- 2021-01-20 13:59
怎样将zookeeper的mode由standalone改成集群形式'
最佳答案
- 二级知识专家网友:举杯邀酒敬孤独
- 2021-01-20 14:21
将下载的 ZooKeeper 解压,进入 conf 目录,复制一份 zoo_sample.cfg 的配置文件命名为 zoo.cfg,修改如下:
# the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats
tickTime=2000
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/var/lib/zookeeper
# the port at which the clients will connect
clientPort=2181
2、 进入 bin 目录,启动 ZooKeeper:
./zkServer.sh start
启动运行后会创建相关目录,所以注意相关目录的写权限。启动的日志如下:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
3、 Client Connecting to ZooKeeper
客户端连接到 ZooKeeper:
./zkCli.sh -server 127.0.0.1:2181
连接成功的日志输出:
Welcome to ZooKeeper!
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)
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0]
# the basic time unit in milliseconds used by ZooKeeper. It is used to do heartbeats
tickTime=2000
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/var/lib/zookeeper
# the port at which the clients will connect
clientPort=2181
2、 进入 bin 目录,启动 ZooKeeper:
./zkServer.sh start
启动运行后会创建相关目录,所以注意相关目录的写权限。启动的日志如下:
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
3、 Client Connecting to ZooKeeper
客户端连接到 ZooKeeper:
./zkCli.sh -server 127.0.0.1:2181
连接成功的日志输出:
Welcome to ZooKeeper!
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)
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0]
全部回答
- 1楼网友:夜风逐马
- 2021-01-20 14:56
肯定是环境的配置那里有问题,仔细找找。我的是集群zoo.cfg放在的根目录下,而单机的zoo.cfg放在了/conf目录下。所以一直显示是standalone状态。
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯