Hive2.x 版本的安装及配置 以及要注意的事项

博主学习Hadoop学习到Hive,一开始跟着资料去安装Hive 1.x一点问题也没有,方便快捷啊,但是看了一下官方文档,上面好像说Hive 2.0修复了很多bug,那么我想,我还是用Hive2.0好了。于是我开始按照原来的流程配置Hive2.0,遇到了各种问题,而且由于版本太新,国内网站上的解决方案基本上没有用。查阅各种资料,现在终于配置好了。所以写这篇博文分享,希望减少跟我一样的新手在使用Hive2.0的时候遇到的阻力。



Hive 1.x与2.x

As of June 2015, Hive has two “main lines”, master and branch-1. 
All new feature work and bug fixes in Hive are contributed to the master branch. As of June 2015, releases from master are numbered 2.x. The 2.x versions are not necessarily backwards compatible with 1.x versions. 
branch-1 is used to build stable, backward compatible releases. Releases from this branch are numbered 1.x (where 1.3 will be the first release from it, as 1.2 was released from master prior to the creation of branch-1). Until at least June 2016 all critical bug fixes (crashes, wrong results, security issues) applied to master must also be applied to branch-1. The decision to port a feature from master to branch-1 is at the discretion of the contributor and committer. However no features that break backwards compatibility will be accepted on branch-1.

Requirements

Java 1.7 
Note: Hive versions 1.2 onward require Java 1.7 or newer. Hive versions 0.14 to 1.1 work with Java 1.6 as well. Users are strongly advised to start moving to Java 1.8 (see HIVE-8607). 
Hadoop 2.x (preferred), 1.x (not supported by Hive 2.0.0 onward). 
Hive versions up to 0.13 also supported Hadoop 0.20.x, 0.23.x. 
Hive is commonly used in production Linux and Windows environment. Mac is a commonly used development environment. The instructions in this document are applicable to Linux and Mac. Using it on Windows would require slightly different steps.



上面只是一些了解材料,我就从官方文档上贴了过来,下面进入正题。

1 下载解压

第一步当然是和老版本一样,在官网上下载Hive的最新的稳定版压缩包,在Linux系统下解压。如果你只使用这一个版本的Hive,可以把HIVE_HOME和其bin目录添加到环境变量PATH中去。安装过Hadoop的朋友对这个应该相当熟悉。像我的话,由于想要Hive 1.x和2.x一起使用,所以我没有配置环境变量,这样每次要使用Hive的时候就cd到对应的bin目录下执行就行了。



2 mysql metastore

Hive的元数据是需要一个关系型数据库保存的,它内置了一个deby,但是最好用的无疑还是MySQL,而且安装配置也简单。所以博主建议使用mysql。这一步的详细过程请参考博主的另一篇博文:http://blog.csdn.net/cds86333774/article/details/51132532

然后Hive要连接mysql啊,这个时候熟悉mysql的朋友就一定会意识到:哦!驱动!

对的,安装好mysql并配置好了之后,还要将连接mysql的驱动:mysql-connector-java-5.1.28.jar 拷贝到HiveHome 目录下的lib文件夹中,这样Hive才可能成功连接mysql。



3 配置hive-site.xml

在hive的目录下有一个conf文件夹,里面全是配置文件。

cp hive-default.xml.template hive-site.xml 
  • 1
  • 1

将模板复制并命名为 hive-site.xml,我们要做的配置就是在这个文件中修改一些参数。这一点也和Hadoop类似。

在这个文件中,查找到如下属性,然后修改其中的value到与你的主机相符的配置,例如mysql所在的主机? 端口一般都是3306;hive是用来存元数据的数据库名称;username和password要与你在上一步设置mysql时的一致:

    <property>
      <name>javax.jdo.option.ConnectionURL</name>
      <value>jdbc:mysql://hadoop00:3306/hive?createDatabaseIfNotExist=true</value>
      <description>JDBC connect string for a JDBC metastore</description>
    </property>

    <property>
      <name>javax.jdo.option.ConnectionDriverName</name>
      <value>com.mysql.jdbc.Driver</value>
      <description>Driver class name for a JDBC metastore</description>
    </property>

    <property>
      <name>javax.jdo.option.ConnectionUserName</name>
      <value>root</value>
      <description>username to use against metastore database</description>
    </property>

    <property>
      <name>javax.jdo.option.ConnectionPassword</name>
      <value>123</value>
      <description>password to use against metastore database</description>
    </property>

注意事项:

如果你在使用mysql之前启动过Hive,注意使用下面的命令将元数据同步到mysql,不然会报错:

schematool -dbType mysql -initSchema

 

这里写图片描述



4 错误1

错误1:忘记启动Hadoop集群了。

这里写图片描述



5 错误2

这里写图片描述

这个问题卡得我有点久,因为在百度上没有找到解决方案。后来在stackoverflow上找到了完美解答:

这里写图片描述

解决后反思一下,我发现自己有一个问题,就是很不喜欢认真看错误信息,其实只要认真看了错误信息,然后到hive-site.xml文件去找出特定字段,然后看description,是可以自己找出解决方案的。国内的网站上还没有出现这个问题的解答,是因为版本太新。而每当一个全新的问题出现,总有一些大牛可以为我们这些小白解决问题,而这种解决全新问题的能力也是我所欠缺的。简单总结为一句话,对我自己说的:【请认真分析错误信息,不要嫌麻烦,不要一遇到问题就百度,不要一看到别人贴出的解决方案,看都不看清楚就直接复制粘贴】。

这里写图片描述



6 成功

这里写图片描述

 

 

 

安装HIVE 过程中要注意

1,MySQL 是否正常运行

2.   创建好mysql 用户并分配好相应的访问权限以及数据库端口号等

3.   mysql-connector-java-5.1.26-bin.jar  是否放到hive/lib 目录下 建议修改权限为777 (chmod 777 mysql-connector-java-5.1.26-bin.jar)

4. 修改conf/hive-site.xml 中的 “hive.metastore.schema.verification”  值为 false  即可解决 “Caused by: MetaException(message:Version information not found in metastore. )” 

5. 调试 模式命令  hive -hiveconf hive.root.logger=DEBUG,console

 

 
posted on 2017-01-24 18:09  junle  阅读(9245)  评论(1编辑  收藏  举报