码迷,mamicode.com
首页 > 其他好文 > 详细

【大数据学习--hive】hive中执行select * from tablename 报错问题。

时间:2020-01-01 20:18:25      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:query   rect   ignore   ace   学习   数据   match   dir   搭建   

在虚拟机中搭建hive之后,创建了表,在执行select * from tablename的时候报错,具体报错信息如下:

hive> select * from hive_01;
FAILED: SemanticException Unable to determine if hdfs://master:9000/user/hive/warehouse/hive_1.db/hive_01 is encrypted: java.lang.IllegalArgumentException: java.net.UnknownHostException: master

报错的大致意思是:hive_1库被锁,后面的提示是未知的主机名:master;根据报错提示:说明创建hive_1库的时候默认保存路径是

hdfs://master:9000/user/hive/warehouse/hive_1.db/hive_01,但是实际上现在找不到这个路径,即:未知的主机名:master,这才像想起来namenode之前设置的主机名为master,后来改了主机名为namenode,
由于hive的元数据已经设置保存在mysql中,因此需要修改mysql中记录的默认路径即可,此处主要修改两张表,分别如下:
mysql> select * from DBS;
+-------+-----------------------+--------------------------------------------------+---------+------------+------------+-----------+
| DB_ID | DESC                  | DB_LOCATION_URI                                  | NAME    | OWNER_NAME | OWNER_TYPE | CTLG_NAME |
+-------+-----------------------+--------------------------------------------------+---------+------------+------------+-----------+
|     1 | Default Hive database | hdfs://master:9000/user/hive/warehouse           | default | public     | ROLE       | hive      |
|     2 | NULL                  | hdfs://master:9000/user/hive/warehouse/hive_1.db | hive_1  | root       | USER       | hive      |
+-------+-----------------------+--------------------------------------------------+---------+------------+------------+-----------+
mysql> select * from SDS;
+-------+-------+------------------------------------------+---------------+---------------------------+----------------------------------------------------------+-------------+------------------------------------------------------------+----------+
| SD_ID | CD_ID | INPUT_FORMAT                             | IS_COMPRESSED | IS_STOREDASSUBDIRECTORIES | LOCATION                                                 | NUM_BUCKETS | OUTPUT_FORMAT                                              | SERDE_ID |
+-------+-------+------------------------------------------+---------------+---------------------------+----------------------------------------------------------+-------------+------------------------------------------------------------+----------+
|     1 |     1 | org.apache.hadoop.mapred.TextInputFormat |               |                           | hdfs://master:9000/user/hive/warehouse/hive_1.db/hive_01 |          -1 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat |        1 |
+-------+-------+------------------------------------------+---------------+---------------------------+----------------------------------------------------------+-------------+------------------------------------------------------------+----------+
1 row in set (0.00 sec)

 

修改DBS表的DB_LOCATION_URI 的值

mysql> update DBS set DB_LOCATION_URI=REPLACE(DB_LOCATION_URI,hdfs://master:9000/user/hive/warehouse,hdfs://namenode:9000/user/hive/warehouse)      
    -> ;
Query OK, 2 rows affected (0.05 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> select * from DBS;   
+-------+-----------------------+-----------------+---------+------------+------------+-----------+ | DB_ID | DESC | DB_LOCATION_URI | NAME | OWNER_NAME | OWNER_TYPE | CTLG_NAME | +-------+-----------------------+-----------------+---------+------------+------------+-----------+ | 1 | Default Hive database | DB_LOCATION_URI | default | public | ROLE | hive | | 2 | NULL | DB_LOCATION_URI | hive_1 | root | USER | hive | +-------+-----------------------+-----------------+---------+------------+------------+-----------+ 2 rows in set (0.00 sec)

修改SDS表中LOCATION字段的值

mysql> update SDS set LOCATION=REPLACE(LOCATION,hdfs://master:9000/user/hive/warehouse/hive_1.db/hive_01,hdfs://namenode:9000/user/hive/warehouse/hive_1.db/hive_01);     
Query OK, 1 row affected (0.08 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from SDS;    

+-------+-------+------------------------------------------+---------------+---------------------------+------------------------------------------------------------+-------------+------------------------------------------------------------+----------+ | SD_ID | CD_ID | INPUT_FORMAT | IS_COMPRESSED | IS_STOREDASSUBDIRECTORIES | LOCATION | NUM_BUCKETS | OUTPUT_FORMAT | SERDE_ID | +-------+-------+------------------------------------------+---------------+---------------------------+------------------------------------------------------------+-------------+------------------------------------------------------------+----------+ | 1 | 1 | org.apache.hadoop.mapred.TextInputFormat | | | hdfs://namenode:9000/user/hive/warehouse/hive_1.db/hive_01 | -1 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | 1 | +-------+-------+------------------------------------------+---------------+---------------------------+------------------------------------------------------------+-------------+------------------------------------------------------------+----------+ 1 row in set (0.01 sec)

修改完毕,重启mysql服务后,在hive中执行查询操作:

hive> select * from hive_01;
OK
Time taken: 2.329 seconds
hive> 

OK......一切正常。

此例可适用于修改了HDFS默认端口,主机名等情况。

【大数据学习--hive】hive中执行select * from tablename 报错问题。

标签:query   rect   ignore   ace   学习   数据   match   dir   搭建   

原文地址:https://www.cnblogs.com/kylinku/p/12129540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!