先决条件:
1)java环境,须要安装java1.6以上版本号
2)hadoop环境,Hadoop-1.2.1的安装方法參考hadoop-1.2.1安装方法具体解释
本文採用的hadoop是hadoop-1.2.1。hive採用的是hive-0.11.0
hive有三种安装模式:
内嵌模式:元数据保持在内嵌的Derby模式。仅仅同意一个会话连接
本地独立模式:在本地安装Mysql,把元数据放到Mysql内
远程模式:元数据放置在远程的Mysql数据库
内嵌模式安装:
1、上传并解压hive-0.11.0.tar.gz
[[email protected] temp]$ cp /mnt/cdrom/hive-0.11.0.tar.gz
.
[[email protected] temp]$ tar xzf
hive-0.11.0.tar.gz
2、配置hive环境变量,改动 .bashrc文件,加入改动下面内容
export HIVE_HOME=/home/hadoop/hive-0.11.0 export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HBASE_HOME/bin:$HIVE_HOME/bin
3、复制/home/hadoop/hive-0.11.0/conf文件夹下的*.template文件生成相应的*.xml文件和*.properties文件
[[email protected] conf]$ cp
hive-default.xml.template hive-site.xml
[[email protected] conf]$ cp
hive-log4j.properties.template hive-log4j.properties
4、改动/home/hadoop/hive-0.11.0/bin/hive-config.sh配置文件。末尾加入下面配置
export JAVA_HOME=/usr/java/jdk1.6.0_45
export HADOOP_HOME=/home/hadoop/hadoop-1.2.1
export HIVE_HOME=/home/hadoop/hive-0.11.0
5、启动hive并进行測试
[[email protected] ~]$ hive
Logging initialized using configuration in file:/home/hadoop/hive-0.11.0/conf/hive-log4j.properties
Hive history file=/tmp/hadoop/[email protected]_201506060628_925403123.txt
hive> show
tables;
OK
Time taken: 4.711 seconds
hive> quit;
[[email protected] ~]$
显示以上信息,就可以说明hive内嵌模式已经成功安装
独立模式安装:
在内嵌模式的基础上,继续安装
1、安装mysql。mysql的安装方法參考 linux安装mysql的方法
2、root用户登录mysql。创建hadoop用户并授权
mysql> create
user ‘hadoop‘ identified by ‘123456‘;
Query OK, 0 rows affected (0.03 sec)
mysql> grant
all on *.* to [email protected]‘%‘ with grant option;
Query OK, 0 rows affected (0.00 sec)
3、用hadoop用户登录mysql并创建hive专用数据库
mysql> create
database hive;
Query OK, 1 row affected (0.00 sec)
4、改动/home/hadoop/hive-0.11.0/conf/hive-site.xml 配置,改动信息例如以下:
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://mdw: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>hadoop</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
5、上传并解压mysql驱动包,然后拷贝到hive的lib文件夹下
[[email protected] mysql]$ cp
/mnt/cdrom/mysql-connector-java-5.1.29.tar.gz .
[[email protected] mysql]$ tar
xzf mysql-connector-java-5.1.29.tar.gz
[[email protected] mysql-connector-java-5.1.29]$ cp
mysql-connector-java-5.1.29-bin.jar /home/hadoop/hive-0.11.0/lib/
6、測试hive安装情况
[[email protected] ~]$ hive
Logging initialized using configuration in file:/home/hadoop/hive-0.11.0/conf/hive-log4j.properties
Hive history file=/tmp/hadoop/[email protected]_201506060714_1104310497.txt
hive> show
tables;
OK
Time taken: 8.004 seconds
hive>
显示以上内容则表示,hive独立模式已安装成功
远程模式安装:
在独立模式的基础上,改动/home/hadoop/hive-0.11.0/conf/hive-site.xml 配置,改动信息例如以下:
1、改动javax.jdo.option.ConnectionURL參数,调整主机名为远程机的主机名
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://远程主机的主机名:3306/hive?=createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
2、改动hive.metastore.uris參数,该參数默觉得空
<property>
<name>hive.metastore.uris</name>
<value>thrift://远程主机名:9083</value>
<description>Thrift uri for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>