1. 安装配置hive之后, 进入hive命令行,show databases失败;
hive> show databases;
FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
hive> quit;
2. 初始化hive shchema: schematool -initSchema -dbType mysql -verbose
报错如下:
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
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
首先确认:
1. jdbc url地址正确
然后排查,排查好久,连接不上mysql:
2. 确认connector等jar 包没有问题:(附上mysql-connector下载连接:MySQL :: Download MySQL Connector/J (Archived Versions))
3. 换一个角度,重新搜索hive配置mysql metastore的流程,看哪里配置漏了
发现这个配置:查看mysql配置文件绑定地址:cat /etc/mysql/mysql.conf.d/mysqld.cnf
显示bind_address=127.0.0.1
注:bind_address=127.0.0.1,该绑定地址仅支持本地连接localhost链接,所以需要修改绑定地址。
sudo vim /etc/mysql/conf.d/mysql.cnf
改为:bind-address = 0.0.0.0 #授权mysql远程访问
然后重启mysql :service mysql restart
再重新初始化hive
进入hive, show databases 成功