dubbo与zookeeper注意事项
1.(zookeeper)启动和关闭客户端和服务端(入门级)
- 第一步:来到zookeeper文件的bin目录
[root@hadoop1 zookeeper-3.5.7-01]# ls
bin lib NOTICE.txt zkData
conf LICENSE.txt README.md
docs logs README_packaging.txt
[root@hadoop1 zookeeper-3.5.7-01]# cd bin
[root@hadoop1 bin]# ls
README.txt zkServer.cmd
zkCleanup.sh zkServer-initialize.sh
zkCli.cmd zkServer.sh
zkCli.sh zkTxnLogToolkit.cmd
zkEnv.cmd zkTxnLogToolkit.sh
zkEnv.sh
- 第二步:启动和关闭服务端
//正例
[root@hadoop1 bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7-01/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@hadoop1 bin]# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.5.7-01/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
//反例
[root@hadoop1 bin]# zkServer.sh start
-bash: zkServer.sh: command not found
[root@hadoop1 bin]# zkServer.sh stop
-bash: zkServer.sh: command not found
- 第三步:启动和关闭客户端(注意:启动前先看下一标题内容)
//正例
[root@hadoop1 bin]# ./zkCli.sh //启动
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]
[zk: localhost:2181(CONNECTED) 0] quit //关闭
//反例
[root@hadoop1 bin]# zkCli.sh
-bash: zk.Cli.sh: command not found
2.(zookeeper)启动客户端连接报错
1.是否已经配置好集群
1.1没有配置好集群
- zoo.cfg文件内容如下
# The number of milliseconds of each tick
tickTime=2000
# 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=/opt/module/zookeeper-3.5.7-01/zkData
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
- zkData文件夹中没有myid文件
- 满足以上两个条件,则可以通过标题一把客户端连接成功
1.2配置集群之后
- zoo.cfg文件内容如下
tickTime=2000
# 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=/opt/module/zookeeper-3.5.7-01/zkData
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.121.130:2881:3881
server.2=192.168.121.130:2882:3882
server.3=192.168.121.130:2883:3883
- zkData文件夹中存在myid文件
- 满足以上两个条件就可以通过标题一把客户端连接成功
2.启动服务端与客户端的顺序
- 先启动服务端,后启动客户端,可连接成功
3.(dubbo)启动服务提供端报错
- 错误显示
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1599)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
at org.apache.zookeeper.KeeperException.create(KeeperException.java:91)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkBackgroundRetry(CuratorFrameworkImpl.java:844)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.performBackgroundOperation(CuratorFrameworkImpl.java:972)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.backgroundOperationsLoop(CuratorFrameworkImpl.java:925)
at org.apache.curator.framework.imps.CuratorFrameworkImpl.access$300(CuratorFrameworkImpl.java:73)
at org.apache.curator.framework.imps.CuratorFrameworkImpl$4.call(CuratorFrameworkImpl.java:322)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
- 解决办法及说明:zookeeper在配置了集群的情况下,如果只启动一个zookeeper,就会报上面的错误,因此要启动的是集群,而不是单个zookeeper
4.(dubbo)访问dubbo-admin报错
- windows-powershell中错误描述
Proxy error: Could not proxy request /api/dev/user/login?userName=root&password=root from localhost:8082 to http://localhost:8081/.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).
- 解决办法及说明
1.运行文件夹dubbo-admin-distribution中dubbo-admin-0.3.0.jar,找到加载信息中的2021-10-09 18:39:51.400 INFO 14676 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
,知道tomcat端口为8080
2.查看文件夹dubbo-admin-ui中的vue.config.js文件中的target值,如下所示:
proxy: {
'/': {
target: 'http://localhost:8080/',
changeOrigin: true,
pathRewrite: {
'^/': '/'
}
}
3.保证以上两处端口号一致即可
5.(dubbo)dubbo-admin管理平台登录显示权限失败
- 从dubbo3版本(其中启动jar包为dubbo-admin-0.3.0.jar)开始进行权限验证,可以降低版本使用。