Linux 安装Zookeeper 图解教程

1.进入Zookeeper官网

http://zookeeper.apache.org/
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.连接上xftp

下载好之后,用xftp连接上,然后我在我自己的/usr里面新建一个zookeeper文件夹,把下载好的包上传到里面。
在这里插入图片描述

3.然后使用xshell连接上虚拟机

进入zookeeper的目录
在这里插入图片描述
然后使用命令: tar -zxvf 上传文件的名字
在这里插入图片描述
我们进入到conf文件夹下面,将zoo_sample.cfg这个文件复制为zoo.cfg(必须是这个文件):
使用命令: cp zoo_sample.cfg zoo.cfg
在这里插入图片描述
进入到刚刚解压好的目录中,创建两个文件夹,分别是data和logs,如下:
在这里插入图片描述
接下来我们需要需改刚才复制的zoo.cfg文件,对内容进行修改:
输入命令: vi zoo.cfg
按i进入编辑模式, 编辑完按esc键退出编辑模式,输入: :wq保存并退出
在这里插入图片描述
注意:dataDir和dataLogDir后面所指的文件夹必须要存在如果不存在的话,在启动Zookeeper服务端的时候是会报错的。

4.进入/etc/profile 添加环境变量

在这里插入图片描述
export ZOOKEEPER_INSTALL=/usr/zookeeper/zookeeper-3.4.10/(修改自己的路径)
export PATH= P A T H : PATH: PATH:ZOOKEEPER_INSTALL/bin
编辑完按esc键退出编辑模式,输入: :wq 保存并退出
使其配置生效:
在这里插入图片描述

5.关闭防火墙

停止防火墙:systemctl stop firewalld.service
禁止防火墙开机启动:systemctl disable firewalld.service

6.启动Zookeeper服务

在这里插入图片描述
启动成功了。
客户端启动, 可以查看启动状态和日志
在这里插入图片描述

以下是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、付费专栏及课程。

余额充值