Hive本地跨机连接mysql出现com.mysql.jdbc.exceptions.jdbc4.CommunicationsException : Communications link failure
环境:
主机sam02安装hive,主机sam03安装mysql
当主机sam02用hive尝试连接主机sam03的客户端mysql时,出现以下错误
[root@sam02 conf]# schematool --initSchema -dbType mysql
which: no hbase in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/usr/local/jdk:/usr/local/jdk/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/zookeeper/bin:/usr/local/flume/bin:/root/bin:/usr/local/jdk:/usr/local/jdk/bin:/usr/local/hadoop/bin:/usr/local/hadoop/sbin:/usr/local/zookeeper/bin:/usr/local/flume/bin:/usr/local/hive/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL: jdbc:mysql://sam03:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: com.mysql.jdbc.exceptions.jdbc4.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 ***
网上说是因为waittime_out的问题,按照网上所说修改后bug还是复现;
后面尝试在安装了hive的主机上连接自身的mysql,发现连接成功说明不是waittime_out的问题,最后发现是因为防火墙没有关闭,关闭了防火墙就解决了。
解决方法:关闭主机sam03的防火墙
systemctl stop firewalld