Centos7 安装Zookeeper、启动、排除Jar包冲突

1、zookeeper下载地址:

http://mirror.bit.edu.cn/apache/zookeeper/

在这里插入图片描述

2、将下载好的压缩包上传到Centos7上面,(注意:要下载 /bin的压缩包,原因百度)
在这里插入图片描述
3、解压压缩包 到 /usr/local下面(路径自定义)

tar -zxvf apache-zookeeper-3.6.1-bin.tar.gz -C /usr/local

4、重新命名文件夹的名字(可不操作)

[root@VM_0_17_centos ~]# cd /usr/local
[root@VM_0_17_centos ~]# mv apache-zookeeper-3.6.1-bin zookeeper-3.6.1

5、进入zookeeper的config目录下,复制一份配置文件

[root@VM_0_17_centos ~]# cp  zoo_sample.cfg  zoo.cfg

在这里插入图片描述

6、然后进入zookeeper的bin目录下,启动server

[root@VM_0_17_centos ~]# ./zkServer.sh start

在这里插入图片描述

7、最后启动client

[root@VM_0_17_centos bin]# ./zkCli.sh

成功后输入命令:ls /
显示如下则成功!
在这里插入图片描述
注:当你的pom中zookeeper版本高于你服务器的版本的时候,需要排除jar包

        <!-- SpringBoot整合zookeeper客户端 -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
<!--            &lt;!&ndash;先排除自带的zookeeper3.5.3&ndash;&gt;-->
            <exclusions>
                <exclusion>
                    <groupId>org.apache.zookeeper</groupId>
                    <artifactId>zookeeper</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
<!--        &lt;!&ndash;添加zookeeper3.4.9版本&ndash;&gt;-->
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.4.9</version> <!-- 指定你的版本-->
        </dependency>

猜你喜欢

转载自blog.csdn.net/qq_38428298/article/details/108487702
今日推荐