CDH重新初始化Hive元数据库

初始化元数据需要使用cdh hive中的schematool 脚本工具进行初始化,初始化脚本位置为cloudera/parcels/CDH/lib/hive/bin/

接下来执行初始化命令

./schematool -initSchema -dbType mysql --verbose

执行报错:

[root@prod-bigdata-pc7 bin]# ./schematool -dbType mysql -initSchema -passWord root -userName root --verbose
WARNING: Use "yarn jar" to launch YARN applications.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/jars/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLogger
Binder.class]SLF4J: Found binding in [jar:file:/data/cloudera/parcels/CDH-6.3.2-1.cdh6.3.2.p0.1605554/jars/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBi
nder.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:	 root
Starting metastore schema initialization to 2.1.1-cdh6.3.2
Initialization script hive-schema-2.1.1.mysql.sql
Connecting to jdbc:derby:;databaseName=metastore_db;create=true
Connected to: Apache Derby (version 10.14.1.0 - (1808820))
Driver: Apache Derby Embedded JDBC Driver (version 10.14.1.0 - (1808820))
Transaction isolation: TRANSACTION_READ_COMMITTED
0: jdbc:derby:> !autocommit on
Autocommit status: true
0: jdbc:derby:> /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */
Error: Syntax error: Encountered "" at line 1, column 64. (state=42X01,code=30000)
Closing: 0: jdbc:derby:;databaseName=metastore_db;create=true
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:568)
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:541)
	at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1137)
	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:313)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:227)
Caused by: java.io.IOException: Schema script failed, errorcode 2
	at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java:962)
	at org.apache.hive.beeline.HiveSchemaTool.runBeeLine(HiveSchemaTool.java:941)
	at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:564)
	... 8 more
*** schemaTool failed ***

根据错误提示可以看到,初始化过程中没有连接mysql数据库,而是去连接默认的derby数据库,于是打开/etc/hive/conf/hive-site.xml,我们可以看到它并没有相关mysql元数据库的配置,但是cdh页面中已经配置了mysql元数据库信息,如图:

CDH重新初始化Hive元数据库_第1张图片

 所以需要在/etc/hive/conf/hive-site.xml(cloudera/parcels/CDH/lib/hive/conf的软链实体)中手动添加元数据库配置,添加如下内容:


    hive.metastore.db.type
    mysql
    元数据库类型指定为使用mysql


    javax.jdo.option.ConnectionDriverName
    com.mysql.jdbc.Driver
    指定mysql的驱动


    javax.jdo.option.ConnectionUserName
    root
    指定元数据库用户


    javax.jdo.option.ConnectionPassword
    root
    指定元数据库密码

 
    javax.jdo.option.ConnectionURL
    jdbc:mysql://prod-bigdata-pc7/metastore?createDatabaseIfNotExist=true
    指定mysql连接串

保存配置后,再次执行元数据库初始化命令:

./schematool -initSchema -dbType mysql --verbose

初始化完成!

你可能感兴趣的:(大数据,hive,big,data,hadoop)