Hive配置
(只需要主机上配置)
主机上先安装mysql,用于存放hadoop元数据
下载一个数据包mysql-connector-java-5.1.18-bin.jar,放到hive的lib目录下,
mysql>create database hive;
mysql>show databases;
+--------------------+
|Database |
+--------------------+
|information_schema |
|hive |
|mysql |
|test |
+--------------------+
mysql>insert into mysql.user(Host,User,Password)values("hadoop1","hadoop",password("hadoop"));
mysql>flush privileges;
[hadoop@hadoop1 ~]$ mysql -u hadoop -phadoop-h hadoop1
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 63
Server version: 5.1.71 Source distribution
Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved.
Oracle is a registered trademark of OracleCorporation and/or its
affiliates. Other names may be trademarksof their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the current input statement.
mysql>
mysql>grant all privileges on hive.* to hadoop@hadoop1identified by ‘hadoop’;
mysql>flush privileges;
从官网上下载hive软件包,上传到服务器后,使用以下命令进行解压:
[hadoop@hadoop1 soft]$ tar -zxvfapache-hive-0.13.1-bin.tar.gz
为了配置方便,可以对解压后的目录进行修改名称:
[hadoop@hadoop1 ~]$ mvapache-hive-0.13.1-bin hive2/
[hadoop@hadoop1 ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
.~/.bashrc
fi
# User specific environment and startupprograms
PATH=$PATH:$HOME/bin
export PATH
export JAVA_HOME=/usr/lib/jvm/java-1.7.0/
export HADOOP_HOME=/home/hadoop/hadoop2
export HIVE_HOME=/home/hadoop/hive2
export HIVE_CONF=/home/hadoop/hive2/conf
exportHIVE_CLASSPATH=$HIVE_HOME/lib:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
exportPATH=$PATH:$JAVA_HOME/bin/:$HADOOP_HOME/bin:$HIVE_HOME/bin
在hive的conf目录下创建文件hive-site.xml配置文件(数据库连接等信息自定义):
<?xml version="1.0"?>
<?xml-stylesheettype="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/hive2/warehouse</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>/home/hadoop/hive2/log</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop1:3306/hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hadoop</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hadoop</value>
</property>
</configuration>
exportHIVE_CONF_DIR=/home/hadoop/hive2/conf
# Folder containing extra ibraries requiredfor hive compilation/execution can be controlled by:
# export HIVE_AUX_JARS_PATH=
exportHIVE_AUX_JARS_PATH=/home/hadoop/hive2/lib
Cd/app/hive
./hive
查看数据表:
Showtables;
Ok,配置完成!
本文出自 “跃跃之鸟” 博客,请务必保留此出处http://jxplpp.blog.51cto.com/4455043/1564868
原文地址:http://jxplpp.blog.51cto.com/4455043/1564868