Linux上安装Zookeeper教程

 安装步骤:

     1、下载zookeeper jar包:

       下载地址: http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz  

     2、将下载好的上的jar 通过 xftp 上传到 opt 目录下:

      

    3、解压jar:

cd /opt/zookeeper #进入到opt

tar -zxvf zookeeper-3.4.10.tar.gz #解压文件

4、进入到刚刚解压好的目录中,创建两个文件夹,分别是data和logs:

cd zookeeper-3.4.10/ 

mkdir data && mkdir logs  #文件创建

 

5、进入conf目录  将 zoo_sample.cfg文件拷贝一份命名为zoo.cfg,如下:

cp zoo_sample.cfg  zoo.cfg  

 6、修改zoo.cfg文件,添加data和log目录,如下:

vim zoo.cfg

 

7、启动zookeeper:

      进入到bin目录下 输入如下命令:


./zkServer.sh start

  输出如下内容表示 zookeeper启动成功:

  

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值