hive实例化schema报错: Failed to get schema version.

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:08   1672   0

具体报错:

Metastore connection URL:     jdbc:mysql://hm02:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :     com.mysql.cj.jdbc.Driver
Metastore connection User:     hive
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: com.mysql.cj.jdbc.exceptions.CommunicationsException : Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
SQL Error code: 0
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

原因及解决方案:

说来惭愧,自己都想打自己(这个问题困扰了我一整天),出错是因为我跟着别人的教程配置,在配置hive/conf/hive-site.xml的时候,javax.jdo.option.ConnectionURL没有改成自己的,用的别人的所以报错:

解决方案:

注意:下面标红的位置要特别注意用自己的

修改hive配置文件: hive/conf/hive-site.xml:

<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168..129.105:3306/hive?createDatabaseIfNotExist=true</value> <!-- 192.168..129.105是我的ip,此处填自己的ip,也可以填 /etc/hosts 里面ip映射的用户名-->
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.cj.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value> <!-- hive是我的mysql用户,此处填自己的用户-->
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value> <!-- mysql hive用户的密码-->
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>

如果还是不行,应该是对应用户没有授权:

注释掉 /etc/mysql/mysql.conf.d/mysqld.cnf 里面的这一句 bind-address = 127.0.0.1

登录mysql: mysql -u root -p

use mysql;

GRANT ALL ON *.* to 'hive'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

flush privileges;

quit;

重启mysql: sudo service mysql restart

重新实例化成功: ./schematool -dbType mysql -initSchema

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP