大数据学习--hivehive中执行select * from tablename 报错问题。
Posted kylinku
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大数据学习--hivehive中执行select * from tablename 报错问题。相关的知识,希望对你有一定的参考价值。
在虚拟机中搭建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默认端口,主机名等情况。
以上是关于大数据学习--hivehive中执行select * from tablename 报错问题。的主要内容,如果未能解决你的问题,请参考以下文章