具体报错:

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实例化schema报错: Failed to get schema version.

原因及解决方案: 

说来惭愧,自己都想打自己(这个问题困扰了我一整天),出错是因为我跟着别人的教程配置,在配置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 

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

登录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

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

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

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

 

 

 

 

相关文章:

  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2021-12-20
  • 2022-01-15
  • 2022-01-09
  • 2022-01-22
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案