码迷,mamicode.com
首页 > 其他好文 > 详细

Hive配置

时间:2014-10-16 21:35:33      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:hive   hadoop   

 

 

Hive配置

(只需要主机上配置)

 

MySQL数据库安装

元数据迁移到mysql

主机上先安装mysql,用于存放hadoop元数据

Mysql驱动

下载一个数据包mysql-connector-java-5.1.18-bin.jar,放到hivelib目录下,

创建mysql用户并赋权

创建hive数据库

mysql>create database hive;

mysql>show databases;

+--------------------+

|Database           |

+--------------------+

|information_schema |

|hive               |

|mysql              |

|test               |

+--------------------+

创建hadoop用户并设置密码

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>

 

hadoop用户赋权

mysql>grant all privileges on hive.* to hadoop@hadoop1identified by ‘hadoop’;

 

mysql>flush privileges;

 

hive配置

软件包下载

从官网上下载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数据库连接

hiveconf目录下创建文件hive-site.xml配置文件(数据库连接等信息自定义):

配置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>                 

 

 

配置hive-env.sh文件

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

 

 

Hive启动运行

Cd/app/hive

./hive

查看数据表:

Showtables;

Ok,配置完成!


本文出自 “跃跃之鸟” 博客,请务必保留此出处http://jxplpp.blog.51cto.com/4455043/1564868

Hive配置

标签:hive   hadoop   

原文地址:http://jxplpp.blog.51cto.com/4455043/1564868

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!