hive安装

Posted slgkaifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hive安装相关的知识,希望对你有一定的参考价值。

1. Hive的安装

系统环境
装好hadoop的环境后。我们能够把Hive装在namenode机器上(NameNode-82)。

下载: hive-0.9.0.tar.gz
解压到: /home/hadoop/hive


hive配置


[[email protected] ~]# cd /home/hadoop/hive/conf
[[email protected] conf]cp hive-default.xml.template hive-site.xml
[[email protected] conf]cp hive-log4j.properties.template hive-log4j.properties
[[email protected] conf]cp hive-env.sh.template  hive-env.sh


配置hive-env.sh
vi hive-env.sh
HADOOP_HOME=/home/hadoop/hadoop
export HIVE_CONF_DIR=/home/hadoop/hive/conf
export HIVE_AUX_JARS_PATH=/home/hadoop/hive/lib
source hive-env.sh


改动hive-site.xml配置文件
把Hive的元数据存储到mysql

vi conf/hive-site.xml

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_metadata?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>hive</value>
<description>username to use against metastore database</description>
</property>


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


<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>


环境变量设置

vi /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_45
export JRE_HOME=/usr/local/jdk1.8.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export JAVA_HOME=/usr/local/jdk1.8.0_45

export HADOOP_HOME=/home/hadoop/hadoop
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin

export HBASE_HOME=/home/hadoop/hbase
export PATH=$PATH:$HBASE_HOME/bin

export HIVE_HOME=/home/hadoop/hive

在hdfs上面。创建文件夹

hadoop fs -mkidr /tmp
hadoop fs -mkidr /user/hive/warehouse
hadoop fs -chmod g+w /tmp
hadoop fs -chmod g+w /user/hive/warehouse


在MySQL中创建数据库

create database hive_metadata;
grant all on hive_metadata.* to [email protected]‘%‘ identified by ‘hive‘;
grant all on hive_metadata.* to [email protected] identified by ‘hive‘;
ALTER DATABASE hive_metadata CHARACTER SET latin1;


手动上传mysql的jdbc库到hive/lib
ls /home/hadoop/hive/lib
mysql-connector-java-5.1.22-bin.jar

启动hive

#启动metastore服务
hive --service metastore 
Starting Hive Metastore Server

#启动hiveserver服务
hive --service hiveserver 
Starting Hive Thrift Server


#启动hiveclient
hive shell
Logging initialized using configuration in file:/root/hive-0.9.0/conf/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201211141845_1864939641.txt

hive> show tables
OK

以上是关于hive安装的主要内容,如果未能解决你的问题,请参考以下文章

Hive-安装

Hive学习:Hive安装

hadoop安装hive及java调用hive

Hive 2.1.1安装配置

Hive的安装和部署

搭建hadoop+spark+hive环境(配置安装hive)