VMware:VMware-workstation-full-15.1.0-13591040.exe
百度网盘链接:https://pan.baidu.com/s/1sGgU2jYcrMXtxge-cP_QtA
提取码:xqg6
虚拟镜像:CentOS-7-x86_64-DVD-1810.iso 【网易CentOS镜像-下载】
在VMware15.1.0上安装了三台(单数) CentOS_7虚拟机。
我准备的ip分别如下(每个人可以根据自己情况而定):【虚拟机设置静态IP-详细教程】
192.168.109.100 ;192.168.109.101 ;192.168.109.102
进入到/opt/zookeeper/文件夹下,【如果没有zookeeper文件夹,可以用[mkdir zookeeper]命令创建zookeeper文件夹】
******************命令如下******************
cd /opt/
mkdir zookeeper
cd zookeeper/
【我准备的是zookeeper-3.5.9版本】
******************命令如下******************
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.5.9/apache-zookeeper-3.5.9-bin.tar.gz
******************命令如下******************
tar -zxvf apache-zookeeper-3.5.9-bin.tar.gz
进入【apache-zookeeper-3.5.9-bin/conf/】路径下。
******************命令如下******************
cd /opt/zookeeper/apache-zookeeper-3.5.9-bin/conf/
cp zoo_sample.cfg zoo.cfg
如果bin路径下没有data和logs,则通过【mkdir 目录名】命令创建目录。
******************命令如下******************
vim zoo.cfg
******************修改dataDir值如下******************
dataDir=/opt/zookeeper/apache-zookeeper-3.5.9-bin/data
dataLogDir=/opt/zookeeper/apache-zookeeper-3.5.9-bin/logs
进入前边配置的dataDir路径下。
******************命令如下******************
cd /opt/zookeeper/apache-zookeeper-3.5.9-bin/data/
touch myid
【配置范围1~255】 【id在集群的所有节点中不可重复】
这里我192.168.109.100 、192.168.109.101 、192.168.109.102三台机器分别配置的1、2、3。
******************命令如下******************
vim myid
格式:【server.A=ip:port1:port2】;
******************我配置的信息如下******************
server.1=192.168.109.100:8888:8889
server.2=192.168.109.101:8888:8889
server.3=192.168.109.102:8888:8889
******************命令如下******************
cd /opt/zookeeper/apache-zookeeper-3.5.9-bin/bin/
./zkServer.sh start
******************命令如下******************
./zkServer.sh status
有问题:
可能是设置的8888和8889端口未开放,查询8888和8889端口是否开放,查询后果然是没有开放。
********查询8888和8889端口是否开放,命令如下********
firewall-cmd --query-port=8888/tcp
firewall-cmd --query-port=8889/tcp
依次在每台虚拟机上执行如下三个命令:
******分别将 2888和3888 端口添加到开放端口中,命令如下******
firewall-cmd --add-port=8888/tcp --permanent
firewall-cmd --add-port=8889/tcp --permanent
******重启防火墙,命令如下******
firewall-cmd --reload
2181端口没有设置开放;并且需要关闭linux防火墙。
******************命令如下******************
##开放指定的端口号,永久有效
firewall-cmd --zone=public --add-port=这里替换成未开放的端口号/tcp --permanent
## 重启防火墙 【以上开启或关闭端口命令执行后,都需要重启后才能生效】
firewall-cmd --reload
=============================================================================
org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = NodeExists for /registry/com.gupaoedu.vip.IHelloService-v1.0/192.168.109.1:8080
at org.apache.zookeeper.KeeperException.create(KeeperException.java:123)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1525)
at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1189)
at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1166)
at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1163)
at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:603)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:593)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:571)
at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:47)
at com.gupaoedu.vip.registry.RegistryCenterWithZk.registry(RegistryCenterWithZk.java:35)
at com.gupaoedu.vip.GpRpcServer.setApplicationContext(GpRpcServer.java:81)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:121)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:97)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
at com.gupaoedu.vip.Bootstrap.main(Bootstrap.java:14)
需要关闭zookeeper所在机器的防火墙;
以下简单列举能适配CentOS7的一些命令,其他命令自己可以百度看看怎么操作,这里就不做全部列举啦!
**************CentOS7关闭zookeeper所在的机器的防火墙************
## 启动防火墙(重启计算器后恢复到原来的设置)
systemctl start firewalld.service
systemctl start firewalld
## 关闭防火墙(重启计算器后恢复到原来的设置)
systemctl stop firewalld.service
systemctl stop firewalld
## 开机禁用防火墙
systemctl disable firewalld.service
systemctl disable firewalld
## 开机启用防火墙
systemctl enable firewalld.service
systemctl enable firewalld
## 查看防火墙状态
systemctl status firewalld
在linux端需要开放 2181(zookeeper默认) 端口;
******************命令如下******************
## 查看所有开放的端口
firewall-cmd --zone=public --list-ports
## 查看是否开放2181端口(no-未开放;yes-已开放)
firewall-cmd --query-port=2181/tcp
## 开放2181端口,【--permanent】重启后不失效(永久生效)
firewall-cmd --zone=public --add-port=2181/tcp --permanent
## 关闭2181端口,【--permanent】重启后不失效(永久生效)
firewall-cmd --zone=public --remove-port=2181/tcp --permanent
## 重启防火墙 【以上开启或关闭端口命令执行后,都需要重启后才能生效】
firewall-cmd --reload
后续有关zookeeper问题不断更新中~~~
……
帮助他人,快乐自己,最后,感谢您的阅读!
所以如有纰漏或者建议,还请读者朋友们在评论区不吝指出!
个人网站…知识是一种宝贵的资源和财富,益发掘,更益分享…