一、Hive包的下载
到http://mirror.bit.edu.cn/apache/hive/hive-2.1.1/网址下载
apache-hive-2.1.1-bin.tar.gz
二、部署需求
Installation and Configuration
You can install a stable release of Hive by downloading a tarball, or you can download the source code and build Hive from that.
Running HiveServer2 and Beeline
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
从官网这句话我们可以知道部署hive的条件
1、需要部署一个hadoop集群,而且是hadoop2.X。
2、需要安装java1.7+
三、开始部署
我已经部署了hadoop2.8.1的环境,java1.8也已部署完毕。
具体参照http://blog.youkuaiyun.com/gavin_chun/article/details/77944019
1、将apache-hive-2.1.1-bin.tar.gz上传至/opt/soft目录下解压并重命令为hive
[root@hadoop001 soft]
[root@hadoop001 soft]
2、配置hive环境变量
[root@hadoop001 conf]
export HIVE_HOME=/opt/soft/hive
export PATH=$HIVE_HOME/bin:$PATH
使环境变量生效source /etc/profile,验证
[root@hadoop001 conf]
which: no hbase in (/opt/soft/hive/bin:/opt/soft/hadoop/bin:/opt/soft/hadoop/sbin:/opt/soft/zookeeper/bin:/usr/java/jdk1.7.0_67-cloudera/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/soft/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/soft/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
usage: hive
-d,--define <key=value> Variable subsitution to apply to hive
commands. e.g. -d A=B or --define A=B
--database <databasename> Specify the database to use
-e <quoted-query-string> SQL from command line
-f <filename> SQL from files
-H,--help Print help information
--hiveconf <property=value> Use value for given property
--hivevar <key=value> Variable subsitution to apply to hive
commands. e.g. --hivevar A=B
-i <filename> Initialization SQL file
-S,--silent Silent mode in interactive shell
-v,--verbose Verbose mode (echo executed SQL to the
console)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
3、修改hive-env.sh(48行)添加HADOOP_HOME配置
vim hive-env.sh
HADOOP_HOME=/opt/soft/hadoop
4、编辑hive-site.xml设置元数据存储使用的数据库类型
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/ruoze_hive?createDatabaseIfNotExist=true</value>
</property>
<property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value>
</property>
<property> <name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property> <name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property> </configuration>
5、拷贝数据库驱动到hive/lib目录下
[root@hadoop001 soft]
四、启动Hive
1、启动前先初始化
[root@hadoop001 ~]
2、启动hive
[root@hadoop001 ~]# hive
which: no hbase in (/opt/soft/hive/bin:/opt/soft/hadoop/bin:/opt/soft/hadoop/sbin:/opt/soft/zookeeper/bin:/usr/java/jdk1.7.0_67-cloudera/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/soft/hive/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/soft/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http:
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in jar:file:/opt/soft/hive/lib/hive-common-2.1.1.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X releases.
hive>
注:hive是一个客户端组件,在Hadoop集群中选择一台安装即可!