您的位置:首页 > 其它

Hive本地模式安装和配置(官网简单翻译)

2018-08-27 15:08 218 查看

安装步骤据官网简单翻译:(我部署的本地模式,按照官网的部署成功了,参照网上的步骤都没成功。在命令行运行hive时候一直报错)

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、java1.7,Hive版本1.2以上的要求jdk1.7及 以上。Hive版本0.4-1.1的1.6也可。强烈建议将java版本升到1.8

2、Hadoop2.x,1.x

3、Linux或windows环境。Mac常用于生产环境。

2、Installing Hive from a Stable Release

Start by downloading the most recent stable release of Hive from one of the Apache download mirrors (see Hive Releases).     从官网下载最近稳定版本的Hive。网址https://hive.apache.org/downloads.html

Next you need to unpack the tarball. This will result in the creation of a subdirectory named 

hive-x.y.z
 (where 
x.y.z
 is the release number):解压

[code]  $ tar -xzvf hive-x.y.z.tar.gz

Set the environment variable 

HIVE_HOME
 to point to the installation directory: 设置HIVE_HOME指向安装目录

[code]  $ cd hive-x.y.z
$ export HIVE_HOME={{pwd}}

Finally, add 

$HIVE_HOME/bin
 to your 
PATH
:将Hive的执行bin目录添加到环境变量中去。

[code]  $ export PATH=$HIVE_HOME/bin:$PATH

另从源码编译Hive进行安装部署的方式自行查看官网。我是直接下载的稳定版。

3、Running Hive

Hive uses Hadoop(Hive使用Hadoop的HDFS), so:

  • you must have Hadoop in your path OR
  • export HADOOP_HOME=<hadoop-install-dir>

In addition, you must use below HDFS commands to create 

/tmp
 and 
/user/hive/warehouse
 (aka 
hive.metastore.warehouse.dir
) and set them 
chmod g+w
 before you can create a table in Hive.(这一步为在HDFS中创建Hive的仓库和临时文件,并赋予g+w权限

[code]  $ $HADOOP_HOME/bin/hadoop fs -mkdir       /tmp
$ $HADOOP_HOME/bin/hadoop fs -mkdir       /user/hive/warehouse
$ $HADOOP_HOME/bin/hadoop fs -chmod g+w   /tmp
$ $HADOOP_HOME/bin/hadoop fs -chmod g+w   /user/hive/warehouse

You may find it useful, though it's not necessary, to set 

HIVE_HOME
:

$ export HIVE_HOME=<hive-install-dir>

Starting from Hive 2.1, we need to run the schematool command below as an initialization step. For example, we can use "derby" as db type. (这一步非常重要,我就是因为没有创建这个一直报如下的错,初始化dbType,这时候会自动在hive所在的目录创建metadata_db,已经创建再次初始化会报错

[code]  $ $HIVE_HOME/bin/schematool -dbType <db type> -initSchema

到此我们的Hive内嵌模式,简单版算是正式部署好了,但是还可能在hive cli里运行的时候还是出现错误:

得到网上汇总方案:

1.hive的版本过高导致的问题,所以其他伙伴有类似错误请考虑版本

2.需要hive元数据库初始化,执行 schematool -dbType mysql -initSchema

3.HIVE_HOME/lib 下的derby-10.11.1.1.jar问题,,把derby-10.11.1.1.jar 换成derby-10.10.2.0.jar问题成功解决

内嵌模式的部署就说到这,不懂欢迎来问!

以上部署的Hive使用内嵌的derby作为元数据的存储,但是在实际上还可以用MysQL和其他的远程(比如分布式数据库、HDFS作为存储Hive元数据的容器)。一般生产上也都是是使用分布式的文件系统或者数据库存储。

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: