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 "<EOF>" 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元数据库信息,如图:

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

<property>
    <name>hive.metastore.db.type</name>
    <value>mysql</value>
    <description>元数据库类型指定为使用mysql</description>
</property>
<property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.jdbc.Driver</value>
    <description>指定mysql的驱动</description>
</property>
<property>
    <name>javax.jdo.option.ConnectionUserName</name>
    <value>root</value>
    <description>指定元数据库用户</description>
</property>
<property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>root</value>
    <description>指定元数据库密码</description>
</property>
 <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://prod-bigdata-pc7/metastore?createDatabaseIfNotExist=true</value>
    <description>指定mysql连接串</description>
</property>

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

./schematool -initSchema -dbType mysql --verbose

初始化完成!

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

头顶榴莲树

你的鼓励是我最大的动力~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值