初学hive的时候遇到的问题集锦:
hive-site.xml文件的配置如下:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver driver class 192.168.0.104 javax.jdo.option.ConnectionURL jdbc:mysql://192.168.0.104:3306/hive?serverTimezone=UTC mysql url javax.jdo.option.ConnectionUserName root username javax.jdo.option.ConnectionPassword root mysql passwd hive.metastore.schema.verification false hive.server2.thrift.port 10000 TCP 的监听端口,默认为10000。 Port number of HiveServer2 Thrift interface. Can be overridden by setting $HIVE_SERVER2_THRIFT_PORT hive.server2.thrift.bind.host 0.0.0.0 host设置成0.0.0.0,来接收未知来源的ip Bind host on which to run the HiveServer2 Thrift interface. Can be overridden by setting $HIVE_SERVER2_THRIFT_BIND_HOST hive.metastore.warehouse.dir /user/hive_data location of default database for the warehouse#初始化mysql为元数据库输入命令:schematool -dbType mysql -initSchema
报错1.hive初始化元数据Error: Syntax error: Encountered “<EOF>“ at line 1, column 64. (state=42X01,code=30000)or
这个错误是因为在hive-site.xml的文件中少了内容,导致无法解析xml文件:
本人在该文件开头加上:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
就可以了。
报错2.:org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version
under by SQLERROE,就是说连接不上作为目的的mysql数据库地址。
原因:我hive-site.xml文件的mysql地址写错了。我电脑用得wifi网络。我应该用WLAN网络的ip地址。可是我却用的是网线的那种ip地址。
报错3:Metastore Connection Driver : com.mysql.cj.jdbc.Driver Metastore connection User: root org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version. Underlying cause: java.sql.SQLException : No suitable driver found for jdbc:mysql://192.168.0.110:3306/hive_2020_test1?
这个错误的原因是:window下的mysql的版本在6点几以上的时候用的jdbc连接jar包是com.mysql.cj.jdbc.Driver,而我的mysql版本是5.7,我应该在hive-site.xml里写为com.mysql.jdbc.Driver
报错4:org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: java.sql.SQLException : The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
SQL Error code: 0
这个错误的原因是:区时没有设置,在hive-site.xml里设置一下:
jdbc:mysql://192.168.0.110:3306/hive?serverTimezone=UTC
报错5:exception in thread “main”java.lang"noSuchMethodError"
原因:jdbc的连接jar包不匹配(版本太低,或者版本太高,换个版本的jdbc连接jar即可)