自从我将namenode的端口从9000 改为 8020后,再次连接hive,查询表中数据时报错
hive> select * from student;
FAILED: SemanticException Unable to determine if hdfs://kylin141:9000/user/hive/warehouse/test.db/student is encrypted: org.apache.hadoop.hive.ql.metadata.HiveException: java.net.ConnectException: Call From kylin141/192.168.59.141 to kylin141:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
查看了几篇CSDN博客,终于找到了解决方法
进入MySQL,找到元数据库中DBS、SDS两张表,然后修改一下两张表中一个字段值
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| metastore |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> use metastore;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
找到两张表,修改字段值
mysql> update DBS set DB_LOCATION_URI=REPLACE(DB_LOCATION_URI,'kylin141:9000','kylin141:8020');
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> update SDS set LOCATION=REPLACE(LOCATION,'kylin141:9000','kylin141:8020');
Query OK, 2 rows affected (0.00 sec)
Rows matched: 3 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 | hdfs://kylin141:8020/user/hive/warehouse | default | public | ROLE | hive |
| 6 | NULL | hdfs://kylin141:8020/user/hive/warehouse/test.db | test | root | USER | hive |
+-------+-----------------------+--------------------------------------------------+---------+------------+------------+-----------+
2 rows in set (0.00 sec)
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://kylin141:8020/user/hive/warehouse/test | -1 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | 1 |
| 6 | 6 | org.apache.hadoop.mapred.TextInputFormat | | | hdfs://kylin141:8020/user/hive/warehouse/test.db/student | -1 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | 6 |
| 11 | 11 | org.apache.hadoop.mapred.TextInputFormat | | | hdfs://kylin141:8020/user/hive/warehouse/test1 | -1 | org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat | 11 |
+-------+-------+------------------------------------------+---------------+---------------------------+----------------------------------------------------------+-------------+------------------------------------------------------------+----------+
3 rows in set (0.00 sec)
确认端口修改成功,重新登录hive即可!
注意点:1.元数据库有的人是hive,有的人是metastore,这个要根据自己创建的元数据名字
2.修改语句中,要把kylin141 改成自己的机器名字
乐于奉献共享,帮助你我他!