Linux系统安装Zookeeper教程

1. 在root账户下创建zookeeper安装目录:mkdir /home/zookeeper

2. 进入zookeeper目录:cd /home/zookeeper
3. 通过wget命令下载zookeeper安装包:wget https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.7.0/apache-zookeeper-3.7.0-bin.tar.gz
我这里安装的是3.7.1版本,如果想要安装其他版本可以去Zookeeper官网找http下载地址。 Zookeeper下载地址

下载时可能会遇到这样的错误。在这里插入图片描述

解决方式:
按照错误信息中提示的内容操作,命令后加 --no-check-certificate
完整命令:wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz --no-check-certificate

4.解压zookeeper安装包:tar -xvzf apache-zookeeper-3.7.1-bin.tar.gz

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Linux安装Zookeeper教程: 1. 下载Zookeeper 首先,你需要从官方网站下载Zookeeper的二进制文件。你可以在这里找到最新版本的Zookeeper:https://zookeeper.apache.org/releases.html 2. 解压缩Zookeeper 下载完成后,你需要将Zookeeper解压缩到你的Linux系统中。你可以使用以下命令将Zookeeper解压缩到/opt目录下: ``` tar -zxf zookeeper-3.4.14.tar.gz -C /opt ``` 3. 配置Zookeeper 接下来,你需要配置Zookeeper。你可以在Zookeeper的conf目录下找到一个名为zoo_sample.cfg的示例配置文件。你需要将它复制一份,并将其命名为zoo.cfg: ``` cd /opt/zookeeper-3.4.14/conf cp zoo_sample.cfg zoo.cfg ``` 然后,你需要编辑zoo.cfg文件,以便将Zookeeper配置为使用单个节点模式。你可以使用以下命令打开zoo.cfg文件: ``` vi zoo.cfg ``` 在文件中,你需要找到以下行: ``` # The number of milliseconds of each tick tickTime=200 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/tmp/zookeeper # the port at which the clients will connect clientPort=2181 ``` 你需要将这些行修改为以下内容: ``` # The number of milliseconds of each tick tickTime=200 # The number of ticks that the initial # synchronization phase can take initLimit=5 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=2 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/opt/zookeeper-3.4.14/data # the directory where the transaction log is stored. dataLogDir=/opt/zookeeper-3.4.14/logs # the port at which the clients will connect clientPort=2181 # disable the per-ip limit on the number of connections since this is a single-node setup maxClientCnxns= ``` 4. 启动Zookeeper 现在,你可以启动Zookeeper了。你可以使用以下命令启动Zookeeper: ``` cd /opt/zookeeper-3.4.14/bin ./zkServer.sh start ``` 你可以使用以下命令检查Zookeeper是否已经启动: ``` ./zkServer.sh status ``` 如果一切正常,你应该会看到以下输出: ``` Mode: standalone ``` 5. 测试Zookeeper 现在,你可以测试Zookeeper是否正常工作了。你可以使用以下命令连接到Zookeeper: ``` ./zkCli.sh -server 127...1:2181 ``` 如果一切正常,你应该会看到以下输出: ``` Connecting to 127...1:2181 Welcome to ZooKeeper! JLine support is disabled WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 127...1:2181(CONNECTED) ] ``` 现在,你可以在Zookeeper中创建一个节点。你可以使用以下命令创建一个名为/test的节点: ``` create /test mydata ``` 如果一切正常,你应该会看到以下输出: ``` Created /test ``` 现在,你可以使用以下命令获取/test节点的数据: ``` get /test ``` 如果一切正常,你应该会看到以下输出: ``` mydata cZxid = x ctime = Thu Jan 01 00:00:00 UTC 197 mZxid = x mtime = Thu Jan 01 00:00:00 UTC 197 pZxid = x1 cversion = dataVersion = aclVersion = ephemeralOwner = x dataLength = 6 numChildren = ``` 恭喜你,你已经成功安装和配置了Zookeeper

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值