hadoop hive 建立表的坑
同事說spark-sql插入不了資料,讀取資料可以。寫會報以下錯誤
2019-02-20 19:12:40 INFO audit:371 - ugi=root ip=unknown-ip-addr cmd=get_table : db=dataall tbl=track_pc
Error in query: java.lang.IllegalArgumentException: Wrong FS: hdfs://aaaaa:9000/user/hive/warehouse/dataall.db/track_pc/.hive-staging_hive_2019-02-20_19-12-39_656_7771985312772642109-1/-ext-10000/part-00000-53761c78-6e3b-47e0-b203-57fba5f90856-c000, expected: hdfs://bbbbb;
hive讀取資料,插入資料都可以。
一,問題分析
錯誤提示也很清楚了,hdfs地址不對。期望的是hdfs://bbbbb,而實際的是hdfs://aaaaa:9000
1,hdfs的配置檢查,做了ha後,也不會在使用帶埠的hdfs,應當不是這塊問題
2,檢查spark的配置檔案,使用hdfs的地方,也使用了ha,應當不是這塊問題
3,無意間看了看元資料,發現數據庫裡面竟然有hdfs://aaaaa:9000, 這些屬於配置,放到資料庫裡面無語哦。配置的改動,資料庫並不會根著變動。
二,解決辦法有二
1,使用metatool,這是hive自帶工具(官方推薦,本人沒有實驗成功)
# metatool -updateLocation hdfs://aaaaa:9000/ hdfs://bbbbb///更換 # metatool -listFSRoot//檢視
如果通過更新操作,出現以下內容,說明更新成功,不然不成功。
# metatool -listFSRoot SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/bigdata/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/bigdata/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] Initializing HiveMetaTool.. Listing FS Roots.. hdfs://bbbbb/user/hive/warehouse hdfs://bbbbb/user/hive/warehouse/dataall.db
我用的是hive2.3.4 bin版的,安裝方法參考: hive mysql 安裝配置
2,直接修改元資料庫
要改DBS和SDS二張表,

元資料庫表dbs修改

元資料庫sds修改
三,意外收穫
namenode做ha,請參考: zookeeper hadoop 叢集 安裝配置 ,如果active的namenode發生宕機時,排程的任務會切換到ha的其他節點。整個yarn的排程任務,以及hdfs的儲存任務是不會受影響的。
但是隻要hdfs://aaaaa:9000,這臺機器由active轉變成standby後,hive和spark根本連不上去,直接報,READ is not supported in state standby
這個問題,在元資料庫改過以後,就在也沒發生過 。
其實還有一種解決辦法就是,讓hdfs://aaaaa:9000,一直active,如果這樣,HA就失去它的價值了。