首先可以确定master是正常启动的,hbase shell命令行可以创建命名空间。
hbase:008:0> create_namespace 'test_wj'
Took 0.1184 seconds
hbase:009:0> list_namespace
list_namespace list_namespace_tables
hbase:009:0> list_namespace
NAMESPACE
default
hbase
test_wj
3 row(s)
Took 0.0154 seconds
但是hbase api创建时就会报错:访问iZ2ze77za5f39z5j0xexocZ:16000失败,而且重试16次,耗时特别长。
org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=16, exceptions:
2023-03-25T12:20:56.994Z, RpcRetryingCaller{globalStartTime=2023-03-25T12:20:55.842Z, pause=100, maxAttempts=16}, org.apache.hadoop.hbase.MasterNotRunningException: java.net.UnknownHostException: Call to address=iZ2ze*********xexocZ:16000 failed on local exception: java.net.UnknownHostException: iZ2z*********xocZ:16000 could not be resolved
在zookeeper的日志中可以看到来自RPC的请求,并且带着我windows的ip地址,说明访问是成功的,而且有个特点是,程序运行开始时有一行日志,超时结束时又有一行提示超时的日志。为什么会超时呢?感觉是建立链接请求成功后,后续的访问就断了。
2023-03-25 21:35:59,372 INFO server.NIOServerCnxnFactory: Accepted socket connection from /222.129.48.64:29824
2023-03-25 21:35:59,373 INFO server.ZooKeeperServer: Client attempting to establish new session at /222.129.48.64:29824
2023-03-25 21:35:59,374 INFO server.ZooKeeperServer: Established session 0x10000695650000b with negotiated timeout 40000 for client /222.129.48.64:29824
2023-03-25 21:38:17,687 INFO server.PrepRequestProcessor: Processed session termination for sessionid: 0x10000695650000b
2023-03-25 21:38:17,689 INFO server.NIOServerCnxn: Closed socket connection for client /222.129.48.64:29824 which had sessionid 0x10000695650000b
可以看到,建立连接和超时的时间差不多有3分钟。
而iZ2ze77********xexocZ是我的阿里云ECS实例名称,就是那台主机的名称,应该是这个主机名称在API RPC远程调用后,被主机返回,在后续的访问中,要继续使用这个名称,而windows不认识这个名称,需要在windows中配置hosts。用管理员权限打开编辑hosts文件,添加上主机的IP和主机名,问题解决。