java連接HBase,連接不上報錯can not resolve問題及解決
java連接HBase,連接不上報錯can not resolve
[INFO] [2020-06-23 21:30:16][org.apache.hadoop.hbase.client.RpcRetryingCaller - 165]Call exception, tries=10, retries=35, started=47508 ms ago, cancelled=false, msg=java.net.UnknownHostException: can not resolve hserver1,16000,1592917603843, details=, see https://s.apache.org/timeout
[INFO] [2020-06-23 21:30:28][org.apache.hadoop.hbase.client.RpcRetryingCaller - 165]Call exception, tries=11, retries=35, started=59772 ms ago, cancelled=false, msg=java.net.UnknownHostException: can not resolve hserver1,16000,1592917603843, details=, see https://s.apache.org/timeout
[INFO] [2020-06-23 21:30:50][org.apache.hadoop.hbase.client.RpcRetryingCaller - 165]Call exception, tries=12, retries=35, started=82155 ms ago, cancelled=false, msg=java.net.UnknownHostException: can not resolve hserver1,16000,1592917603843, details=, see https://s.apache.org/timeout
[INFO] [2020-06-23 21:31:13][org.apache.hadoop.hbase.client.RpcRetryingCaller - 165]Call exception, tries=13, retries=35, started=104512 ms ago, cancelled=false, msg=java.net.UnknownHostException: can not resolve hserver1,16000,1592917603843, details=, see https://s.apache.org/timeout
hserver1是我HBase的主機名,但是我的代碼中并為出現(xiàn)該名詞。
出現(xiàn)這種錯誤很有可能是hosts里面沒有添加HBase的地址。
將HBase的ip地址寫在hosts中便可正常。
添加之后java就可以正常連接HBase了
java連接Hbase異常
java連接Hbase出現(xiàn)如下異常:
org.apache.hadoop.hbase.MasterNotRunningException:java.net.unknownHostException:can not resolve hdp14,16000
問題原因
hbase的配置文件中hbase-site.xml里面關于 hbase.zookeeper.quorum 這個配置,使用的不是ip,而是hosts映射地址,導致無法解析諸如hdp14之類的主機名
解決辦法
把hbase所在主機的hosts文件中的配置,拷貝到java代碼運行環(huán)境中。
如果java代碼是在本地啟動的,就把hosts中的映射地址放在windows中的C:\WINDOWS\system32\drivers\etc\hosts里面,如果java代碼是在linux服務上啟動的,就把hosts的映射地址放在 /etc/hosts中。
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Springboot實現(xiàn)接口傳輸加解密的步驟詳解
這篇文章主要給大家詳細介紹了Springboot實現(xiàn)接口傳輸加解密的操作步驟,文中有詳細的圖文解釋和代碼示例供大家參考,對大家的學習或工作有一定的幫助,需要的朋友可以參考下2023-09-09Springcloud hystrix服務熔斷和dashboard如何實現(xiàn)
這篇文章主要介紹了Springcloud hystrix服務熔斷和dashboard如何實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-12-12spring?和?idea?建議不要使用?@Autowired注解的原因解析
@Autowired?是Spring框架的注解,而@Resource是JavaEE的注解,這篇文章主要介紹了spring和idea建議不要使用@Autowired注解的相關知識,需要的朋友可以參考下2023-11-11