1下载
Index of apache-local/hive/hive-2.3.6
到路径/Users/xx/Downloads/tool
2解压重命名 apache-hive-2.3.6
3把mysql-connector-java-5.1.47.jar驱动包放到lib目录下面/Users/xx/Downloads/tool/hive_conf/lib
4在路径/Users/xx/Downloads/tool/hive_conf/conf路径新建hive-site.xml,配置mysql元数据
<?xml version="1.0"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>hive.metastore.server.min.threads</name>
<value>200</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>hive.metastore.metrics.enabled</name>
<value>true</value>
</property>
<property>
<name>hive.service.metrics.file.frequency</name>
<value>30000</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hivemate?createDatabaseIfNotExist=true&characterEncoding=UTF-8</value>
</property>
<property>
<name>hive.metastore.server.max.threads</name>
<value>1000</value>
</property>
<property>
<name>init.meta.db</name>
<value>false</value>
</property>
<property>
<name>allow.console.modify.meta.db</name>
<value>true</value>
</property>
<property>
<name>hive.service.metrics.file.location</name>
<value>/tmp/hivemetastore_metric.json</value>
</property>
</configuration>
5初始化元数据
schematool -initSchema -dbType mysql报错
-bash-3.2$ schematool -initSchema -dbType mysql
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/kongaiqin/Downloads/tool/apache-hive-2.3.6/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/kongaiqin/Downloads/tool/hadoop-2.8.5/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:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User: APP
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Error: Syntax error: Encountered "<EOF>" at line 1, column 64. (state=42X01,code=30000)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
Use --verbose for detailed stacktrace.
*** schemaTool failed ***
可以看到报错信息,连接的数据库是默认的jdbc:derby:;databaseName=metastore_db;create=true
而我们配置的是mysql数据库,hive-site.xml配置文件没有生效。把hive-site.xml放到hive的安装目录/Users/xx/Downloads/tool/apache-hive-2.3.6/conf目录下面,重新初始化成功