启动hive hiveserver2会报警告-Mon Oct 16 10:25:12 CST 2017 WARN: Establishing SSL connection without server

启动hive hiveserver2会报警告,如下所示警告信息,那该怎么解决呢?

Mon Oct 16 10:25:12 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决过程中又遇到如下错的,该怎么解决呢?

[Fatal Error] hive-site.xml:554:80: The reference to entity "useSSL" must end with the ';' delimiter.Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:/Users/a6/Applications/apache-hive-2.3.0-bin/conf/hive-site.xml; lineNumber: 554; columnNumber: 80; The reference to entity "useSSL" must end with the ';' delimiter.

下面将从发现问题,解决问题,总结经验这几个方面来介绍:

(1) 启动hive hiveserver2会报警告,如下所示警告信息:
localhost:bin a6$ hive --service hiveserver2 &
[1] 2135
localhost:bin a6$ 2017-10-16 10:25:05: Starting HiveServer2
localhost:bin a6$ SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/a6/Applications/apache-hive-2.3.0-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/a6/Applications/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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]
Mon Oct 16 10:25:12 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Mon Oct 16 10:25:12 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

(2)根据提示和百度,需要在jdbc连接字符串中使用useSSL=true或者useSSL=false

第一次修改如下所示:

javax.jdo.option.ConnectionURL
jdbc:mysql://localhost:3306/hive_meta_db?characterEncoding=utf8&useSSL=true&createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore
或者

javax.jdo.option.ConnectionURL
jdbc:mysql://localhost:3306/hive_meta_db?characterEncoding=utf8;useSSL=true;createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore

(3)修改配置后jdbc连接字符后,需要执行初始化命令,却都报了如下错误:
localhost:bin a6$ schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/a6/Applications/apache-hive-2.3.0-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/a6/Applications/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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]
[Fatal Error] hive-site.xml:554:80: The reference to entity "useSSL" must end with the ';' delimiter.
Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:/Users/a6/Applications/apache-hive-2.3.0-bin/conf/hive-site.xml; lineNumber: 554; columnNumber: 80; The reference to entity "useSSL" must end with the ';' delimiter.
    at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2597)
    at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2454)
    at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2361)
    at org.apache.hadoop.conf.Configuration.get(Configuration.java:1188)
    at org.apache.hadoop.hive.conf.HiveConf.getVar(HiveConf.java:3901)
    at org.apache.hadoop.hive.conf.HiveConf.getVar(HiveConf.java:3970)
    at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:4057)
    at org.apache.hadoop.hive.conf.HiveConf.(HiveConf.java:4005)
    at org.apache.hive.beeline.HiveSchemaTool.(HiveSchemaTool.java:82)
    at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: org.xml.sax.SAXParseException; systemId: file:/Users/a6/Applications/apache-hive-2.3.0-bin/conf/hive-site.xml; lineNumber: 5
(4) 给出原因和解决方案

几番查找,终于找到症结:连接jdbc时,路径连接参数之前一直是使用 & 符号连接,但是这次却提示用 ; 来进行连接,于是 按照编译器的提示 我把 & 改为;,于是 运行起来它把两个参数 当做了一个参数,OhMyGod!在没头没脑的一番探索后,终于发现问题,在xml文件中 &符号 需要转义 这个根据 HTML 的转义规则 更改就行& -> & 于是便成功解决了。

正确代码如下:

javax.jdo.option.ConnectionURL
jdbc:mysql://localhost:3306/hive_meta_db?characterEncoding=utf8&useSSL=true&createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore
1) 再次执行初始化hive的元数据库命令
localhost:bin a6$ pwd
/Users/a6/Applications/apache-hive-2.3.0-bin/bin
localhost:bin a6$
localhost:bin a6$ schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/a6/Applications/apache-hive-2.3.0-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/a6/Applications/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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://localhost:3306/hive_meta_db?characterEncoding=utf8&useSSL=true&createDatabaseIfNotExist=true
Metastore Connection Driver :     com.mysql.jdbc.Driver
Metastore connection User:     hive_user
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed
localhost:bin a6$
2) 查看初始化后的信息: schematool -dbType derby -info
localhost:bin a6$ schematool -dbType derby -info
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/a6/Applications/apache-hive-2.3.0-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/a6/Applications/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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://localhost:3306/hive_meta_db?characterEncoding=utf8&useSSL=true&createDatabaseIfNotExist=true
Metastore Connection Driver :     com.mysql.jdbc.Driver
Metastore connection User:     hive_user
Hive distribution version:     2.3.0
Metastore schema version:     2.3.0
schemaTool completed
localhost:bin a6$
3) 之后再次启动hiveserver2服务,则发现不会报警告信息啦
localhost:bin a6$ hive --service hiveserver2 &
[1] 4722
localhost:bin a6$ 2017-10-16 16:58:31: Starting HiveServer2
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/a6/Applications/apache-hive-2.3.0-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/a6/Applications/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.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]
4) 使用jps,可以查看hiveserver2服务,顺利启动啦。
localhost:bin a6$ jps
4909 Jps
4722 RunJar
localhost:bin a6$

(5)其他介绍

1)如果是第一次需要执行初始化命令:schematool -dbType mysql -initSchema
    以Mysql数据库为例:创建好用户:hive_user;database: test_hivedb 。Remote方式需要分别配置服务端和客户端的配置文件:
服务端的 hive-site.xml 中jdbc URL、驱动、用户名、密码等属性值配置。
如果是第一次需要执行初始化命令: schematool -dbType mysql -initSchema
2)hive metastore 服务端启动命令:
hive --service metastore -p
如果不加端口默认启动: hive --service metastore ,则默认监听端口是:9083 ,注意客户端中的端口配置需要和启动监听的端口一致。服务端启动正常后,客户端就可以执行hive操作了。

你可能感兴趣的:(hive,thrift,hive)