(2)Hive安装与配置——深入浅出学Hive

转自:http://sishuok.com/forum/blogPost/list/6220.html
第一部分:软件准备与环境规划
Hadoop环境介绍
•Hadoop安装路径
•/home/test/Desktop/hadoop-1.0.0/
•Hadoop 元数据存放目录
•/home/test/data/core/namenode
•Hadoop 数据存放路径
•/home/test/data/core/datanode
Hive环境规划
•Hive安装路径
•/home/test/Desktop/
•Hive数据存放路径
•hdfs
•/user/hive/warehouse
•Hive元数据
•第三方数据库
•derby mysql
软件准备
•OS:  ubuntu
•JDK:  java 1.6.0_27
•Hadoop:  hadoop-1.0.0.tar
•Hive:  hive-0.8.1.tar
第二部分:Hive项目介绍
项目结构
(2)Hive安装与配置——深入浅出学Hive_第1张图片
 
Hive配置文件介绍
•hive-site.xml      hive的配置文件
•hive-env.sh        hive的运行环境文件
•hive-default.xml.template  默认模板
•hive-env.sh.template     hive-env.sh默认配置
•hive-exec-log4j.properties.template   exec默认配置
• hive-log4j.properties.template log默认配置
hive-site.xml
< property>
  <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createData baseIfNotExist=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>root</value>
   <description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
   <value>test</value>
   <description>password to use against metastore database</description>
</property>
hive-env.sh
•配置Hive的配置文件路径
export HIVE_CONF_DIR= your path
•配置Hadoop的安装路径
HADOOP_HOME=your hadoop home
第三部分:使用Derby数据库的安装方式
什么是Derby安装方式
•Apache Derby是一个完全用java编写的数据库,所以可以跨平台,但需要在JVM中运行
•Derby是一个Open source的产品,基于Apache License 2.0分发
•即将元数据存储在Derby数据库中,也是Hive默认的安装方式
 安装Hive
•解压Hive
tar zxvf  hive-0.8.1.tar  /home/test/Desktop
•建立软连接
ln –s hive-0.8.1 hive
•添加环境变量
•export HIVE_HOME=/home/test/Desktop/hive
•export PATH=….HIVE_HOME/bin:$PATH:.
配置Hive
•进入hive/conf目录
•依据hive-env.sh.template,创建hive-env.sh文件
cp  hive-env.sh.template hive-env.sh
•修改hive-env.sh
•指定hive配置文件的路径
export HIVE_CONF_DIR=/home/test/Desktop/hive/conf
•指定Hadoop路径
HADOOP_HOME=/home/test/Desktop/hadoop  
hive-site.xml
<property>
  <name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=metastore_db;create=true</value>
  <description>JDBC connect string for a JDBC metastore</description>
</property>
 
<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>org.apache.derby.jdbc.EmbeddedDriver</value>
  <description>Driver class name for a JDBC metastore</description>
</property>
<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>APP</value>
  <description>username to use against metastore database</description>
</property>
 
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>mine</value>
  <description>password to use against metastore database</description>
</property>

启动Hive
•命令行键入
•Hive
•显示
WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.
Logging initialized using configuration in jar:file:/home/test/Desktop/hive-0.8.1/lib/hive-common-0.8.1.jar!/hive-log4j.properties
Hive history file=/tmp/test/hive_job_log_test_201208260529_167273830.txt
hive>
测试语句
•建立测试表test
•create table test  (key string);
•show tables;
 
 
第四部分:使用MySQL数据库的安装方式
安装MySQL
•Ubuntu 采用apt-get安装
•sudo apt-get install mysql-server
•建立数据库hive
•create database hive 
•创建hive用户,并授权
•grant all on hive.* to hive@'%'  identified by 'hive';  
•flush privileges;  
 
安装Hive
•解压Hive
•tar zxvf  hive-0.8.1.tar  /home/test/Desktop
•建立软连接
•ln –s hive-0.8.1 hive
•添加环境变量
•export HIVE_HOME=/home/test/Desktop/hive
•export PATH=….HIVE_HOME/bin:$PATH:.
修改hive-site.xml
<property> 
   <name>javax.jdo.option.ConnectionURL </name> 
   <value>jdbc:mysql://localhost:3306/hive </value> 
</property> 
 
<property> 
   <name>javax.jdo.option.ConnectionDriverName </name> 
   <value>com.mysql.jdbc.Driver </value> 
</property>
<property> 
   <name>javax.jdo.option.ConnectionPassword </name> 
   <value>hive </value> 
</property> 
 
<property> 
   <name>hive.hwi.listen.port </name> 
   <value>9999 </value> 
   <description>This is the port the Hive Web Interface will listen on </descript ion> 
</property> 
<property> 
   <name>datanucleus.autoCreateSchema </name> 
   <value>false </value> 
</property> 
 
<property> 
   <name>datanucleus.fixedDatastore </name> 
   <value>true </value> 
</property> 
<property> 
         <name>hive.metastore.local </name> 
         <value>true </value> 
         <description>controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM </description> 
</property> 
启动Hive
•命令行键入
•Hive
•显示
WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.
Logging initialized using configuration in jar:file:/home/test/Desktop/hive-0.8.1/lib/hive-common-0.8.1.jar!/hive-log4j.properties
Hive history file=/tmp/test/hive_job_log_test_201208260529_167273830.txt
hive>
测试语句
•建立测试表test
•create table test (key string);
•show tables;

你可能感兴趣的:((2)Hive安装与配置——深入浅出学Hive)