Nested Throwables StackTrace:
java.sql.SQLException: Unable to open a
test connection to the given database. JDBC url =
jdbc:mysql://192.168.1.148:3306/hive?createDatabaseIfNotExist=true,
username = hadoop. Terminating connection pool (set lazyInit to true if
you expect to start your database after your app). Original Exception:
------
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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
这只是报错的一部分,实在是太多了。
无法连接到mysql有可能是mysql本身的原因。我用 netstat -an | grep 3306查看3306端口发现 127.0.0.1 :: 3306 ,即mysql默认绑定localhost,远程访问不了。
于是 sudo vim /etc/mysql/my.cnf修改mysql配置文件,注释掉bind-address = 127.0.0.1,然后重启就行了
重启之后发现错误少了很多,
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:510)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:671)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)(只截取了错误日志的最前面部分,后面还有很多)
我把配置文件hive-site.xml改成下面就ok了
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hive.metastore.local</name> <value>true</value> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true</value> </property> <!-- <property> <name>datanucleus.autoCreateSchema</name> <value>true</value> </property> <property> <name>datanucleus.fixedDatastore</name> <value>false</value> </property> <property> <name>datanucleus.readOnlyDatastore</name> <value>false</value> </property> <property> <name>datanucleus.autoCreateTables</name> <value>true</value> </property>--> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hadoop</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hivepwd</value> </property> </configuration>
希望这能对遇到这种问题的朋友能有帮助。