Hive配置hive-site.xml后启动出错

本文记录了一次Hive启动过程中遇到的错误,并详细解析了错误原因。通过检查MySQL权限设置,最终解决了因数据库连接问题导致的Hive无法启动的问题。

错误信息:

[hadoop@hadoop1 conf]$ hive

Logging initialized using configuration in jar:file:/home/hadoop/happ/apache-hive-0.14.0-bin/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/happ/hadoop-2.4.1/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/happ/apache-hive-0.14.0-bin/lib/hive-jdbc-0.14.0-standalone.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.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
	at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:672)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:616)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
	at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1449)
	at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:63)
	at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:73)
	at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:2661)
	at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:2680)
	at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:425)
	... 7 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1447)
	... 12 more
Caused by: javax.jdo.JDOFatalDataStoreException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://hadoop1:3306/hive?createDatabaseIfNotExist=true, username = root. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: Access denied for user 'root'@'hadoop1' (using password: YES)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:928)
	at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4736)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1342)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:187)
	at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
	at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
	at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
	at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getConnection(ConnectionFactoryImpl.java:501)
	at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:298)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45
        ........
从第三个cause by的Original Exception可以看出登陆Mysql数据库被拒绝,想到root@hadoop1可能没有权限,

进入mysql查看一下:

mysql> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | %         |
| root | 127.0.0.1 |
| root | hadoop1   |
| root | localhost |
+------+-----------+
4 rows in set (0.01 sec)
  
//给root@'hadoop1'赋权限
mysql> grant all privileges on *.* to root@'hadoop1' identified by 'root';
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye
[hadoop@hadoop1 conf]$ hive   //启动正常

Logging initialized using configuration in jar:file:/home/hadoop/happ/apache-hive-0.14.0-bin/lib/hive-common-0.14.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/happ/hadoop-2.4.1/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/happ/apache-hive-0.14.0-bin/lib/hive-jdbc-0.14.0-standalone.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.slf4j.impl.Log4jLoggerFactory]
hive> exit
    > ;


<think>好的,用户现在需要关于Hive配置文件hive-site.xml的示例和参数说明。首先,我需要确认用户的具体需求。他们可能是在配置Hive时遇到了问题,或者想了解各个参数的作用。接下来,我得回忆Hive的常见配置参数,尤其是hive-site.xml中的关键设置。 Hive-site.xmlHive的主要配置文件,用于覆盖默认设置。常见的参数包括连接元数据库的配置、执行引擎、日志路径等。比如javax.jdo.option.ConnectionURL指定元数据库的JDBC连接,hive.execution.engine设置执行引擎为MapReduce、Tez或Spark。 用户可能需要一个示例文件,展示这些参数的结构和用法。同时,每个参数的说明也很重要,帮助他们理解如何根据需求调整配置。例如,hive.metastore.warehouse.dir定义了Hive表数据的存储位置,用户可能需要修改这个路径到HDFS中的合适位置。 还需要注意一些性能调优参数,比如hive.vectorized.execution.enabled启用向量化查询,提升性能。或者hive.auto.convert.join是否自动优化MapJoin。这些参数对提升Hive作业效率很关键。 另外,用户可能对元数据存储、查询结果压缩、动态分区等配置感兴趣。比如hive.compression.codec设置压缩格式,hive.exec.dynamic.partition启用动态分区。 要确保提供的示例参数正确,语法无误,并且有详细的中文说明。同时,可能需要提醒用户根据实际环境(如数据库类型、Hadoop版本)调整配置值,比如MySQL的连接URL和驱动类。 最后,生成相关的问题,帮助用户深入理解配置的影响,比如如何调优性能、配置高可用、安全设置等。这些问题能引导用户进一步探索Hive配置和优化。</think>### Hive配置文件hive-site.xml示例及参数说明 Hive配置文件`hive-site.xml`用于定义Hive服务的运行时行为,包括元数据存储、计算引擎、资源管理等核心参数。以下是一个典型配置示例及关键参数说明: ```xml <?xml version="1.0"?> <configuration> <!-- 元数据存储配置 --> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive_metastore?createDatabaseIfNotExist=true</value> <description>JDBC连接元数据库的URL</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>元数据库驱动类</description> </property> <!-- 执行引擎配置 --> <property> <name>hive.execution.engine</name> <value>tez</value> <description>可选值:mr(默认)/tez/spark</description> </property> <!-- 数据仓库路径 --> <property> <name>hive.metastore.warehouse.dir</name> <value>/user/hive/warehouse</value> <description>HDFS中表数据的存储根目录</description> </property> <!-- 查询结果展示配置 --> <property> <name>hive.cli.print.header</name> <value>true</value> <description>是否显示查询结果的列名</description> </property> </configuration> ``` #### 核心参数说明(部分) 1. **元数据存储相关** - `javax.jdo.option.ConnectionUserName`:元数据库用户名 - `hive.metastore.schema.verification`:是否验证元数据存储模式版本(生产环境建议设置为`true`) 2. **查询优化参数** ```xml <property> <name>hive.vectorized.execution.enabled</name> <value>true</value> <description>启用向量化查询(Tez/Spark引擎适用)</description> </property> <property> <name>hive.auto.convert.join</name> <value>true</value> <description>自动优化MapJoin</description> </property> ``` 3. **资源管理参数** ```xml <property> <name>hive.server2.tez.sessions.per.default.queue</name> <value>5</value> <description>每个队列的Tez会话数限制</description> </property> ``` 4. **安全配置** ```xml <property> <name>hive.security.authorization.enabled</name> <value>true</value> <description>启用SQL标准授权</description> </property> ``` [^1]: 具体参数值需根据实际Hadoop集群环境和元数据库类型调整,如MySQL连接参数需对应实际部署信息。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值