ubuntu下搭建hive(包括hive的web接口)记录
Hive版本 0.12.0(独立模式)
Hadoop版本 1.12.1
Ubuntu 版本 12.10
今天试着搭建了hive,差点迷失在了网上各种资料中,现在把我的经验分享给大家,亲手实践过,但未必每一步都是必须的,正确的,大家可以参考一下。
第一步:安装和测试mysql(已装好的可跳过)
见我总结的http://blog.csdn.net/unflynaomi/article/details/37811229
第二步.开始正式安装hive
1.在hdfs上建目录:
$ hadoop fs -mkdir /tmp
$ hadoop fs -mkdir /user/hive/warehouse
2.添加权限:
$ hadoop fs -chmod g+w /tmp
$ hadoop fs -chmod g+w /user/hive/warehouse
3.下载解压hive:
$ wget http://mirrors.hust.edu.cn/apache/hive/hive-0.12.0.tar.gz .
下载官网地址 http://mirrors.hust.edu.cn/apache/hive/
然后 mv hive-0.12.0.tar.gz /usr/local/hive-0.12.0
将压缩包移动到/usr/local/hive-0.12.0
$ tar -zxvf hive-0.12.0.tar.gz
去hive的官网观察兼容性
15 October, 2013: release 0.12.0 available
This release works with Hadoop 0.20.x, 0.23.x.y, 1.x.y, 2.x.y
可见hive-0.12.0版本与hadoop 1.2.1兼容
4.设置HADOOP_HOME、HIVE_HOME,并将其添加到~/.bashrc(你的hadoop和hive路径)配置环境变量,在etc/profile文件末尾添加以下内容:
export HADOOP_HOME=/usr/local/hadoop
export HIVE_HOME=/usr/local/hive-0.12.0
export PATH=$HIVE_HOME/bin:$PATH
执行source /etc/profile更新环境变量
5.
创建用户hive,并授权:
root用户登录mysql创建hive用户并授权,执行命令:
use mysql;
insert into user(Host,User,Password) values("localhost","hive",password("hive"));密码也是hive
FLUSH PRIVILEGES;
6.授予用户hive足够大的权限
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'localhost' IDENTIFIED BY 'hive';
FLUSH PRIVILEGES;
可以用hive用户登录观察是否创建用户成功
hadoop@ubuntu:/usr/local$ mysql -h localhost -u hive -p
显示:
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 78
Server version: 5.5.37-0ubuntu0.12.10.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
成功登录
7.修改hive的配置文件
hive的配置文件放在HIVE_HOME/conf目录下,我们需要修改hive-env.sh和hive-site.xml这两个文件。ls之后发现并没有这两个文件,但是有hive-env.sh.template,hive-default.xml.template,我们须复制这两个文件,并分别命名为hive-env.sh,hive-site.xml。一般还有一个hive-default.xml文件,同样由hive-default.xml.template复制而来。hive-default.xml是默认配置,hive-site.xml是个性化配置,将会覆盖hive-default.xml配置。切换到hadoop用户下,并复制两个文件:
leefon@ubuntu:/usr/local/hadoop/hive/conf$su hadoop
输入hadoop用户的密码:
hadoop@ubuntu:/usr/local/hadoop/hive/conf$cp hive-default.xml.template hive-default.xml
hadoop@ubuntu:/usr/local/hadoop/hive/conf$cp hive-default.xml.template hive-site.xml
hadoop@ubuntu:/usr/local/hadoop/hive/conf$cp hive-env.sh.template hive-env.sh
其实这个设计很贴心,给你弄个模板,改坏了再,可以复制
配置hive-env.sh
用vim打开
将export HADOOP_HEAPSIZE=1024前面的‘#’去掉,当然可以根据自己的环境对这个默认的1024进行优化;
把#去掉使得改动生效
将export HADOOP_HOME前面的‘#’号去掉,并让它指向您所安装hadoop的目录,我的/usr/local/hadoop;
将export HIVE_CONF_DIR=/usr/local/hadoop/hive/conf,并且把‘#’号去掉;
将export HIVE_AUX_JARS_PATH=/usr/local/hadoop/hive/lib,并且把‘#’号去掉。
esc(键) :wq
source ./hive-env.sh(生效文件)
配置hive-site.xml
首先创建相应的目录,以便与配置文件的路径相对应:
hadoop@ubuntu:/usr/local/hadoop/hive$mkdir /usr/local/hadoop/hive/warehouse
hadoop@ubuntu:/usr/local/hadoop/hive$mkdir /usr/local/hadoop/hive/log
在修改时可以用查找功能:/要查找的字符串比如 :/metastore.warehouse.dir
<span style="font-size:18px;"><property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>//你的路径
<description>location of default database for the warehouse</description>
</property>
#临时文件目录,这个没有可以添加进去
<property>
<name>hive.exec.scratdir</name>
<value>/usr/local/hadoop/hive/tmp</value>
</property>
#存放hive相关日志的目录
<property>
<name>hive.querylog.location</name>
<value>/usr/local/hadoop/hive/log</value>//你的路径
<description>
Location of Hive run time structured log file
</description>
</property>
</span>
接着修改hive-site.xml这一步将mysql与hive连接
<span style="font-size:18px;"><span style="font-size:18px;"><property> <name>hive.metastore.local</name> <value>true</value> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost: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>hive</value>//与mysql中创建hive用户的密码有关 <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>
</span></span>
8. 添加jdbc的jar包
在mysql的官网上下载jdbc,我使用的版本是5.1.31。
下载时需要
Oracle Web 帐户
密码 ORA11cle
解压,拷贝到HIVE _HOME/lib目录下
leefon@ubuntu:~/Download$ tar -xvzf mysql-connector-java-5.1.31.tar.gz
leefon@ubuntu:~/Download$ cp mysql-connector-java-5.1.25/*.jar /usr/local/hadoop/hive/lib
9.启动hive
hadoop@ubuntu:/usr/local/hadoop/hive$ bin/hive
出现
差不多装好了,别忘了加;一定要试下面的show table
hadoop@ubuntu:/usr/local/hadoop/hive$ hive> show tables;
报错
FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
我是这么解决的
将hive.site.xml文件中的
<property>
<name>hive.metastore.schema.verification</name>
<value><strong><span style="color:#ff0000;">true</span></strong></value>
<description>
</description>
</property>
true改为false
<pre>
改后效果:
<property>
<name>hive.metastore.schema.verification</name>
<value><strong><span style="color:#ff0000;">false</span></strong></value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manully migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description>
</property>
10.再次启动hive
hadoop@ubuntu:/usr/local/hadoop/hive$ bin/hive
出现,进入hive shell
hadoop@ubuntu:/usr/local/hadoop/hive$ hive> show tables;
第一次启动时间比较长,耐心等待
试着插入一个表格
create table table1 (a int, b int);
显示
安装成功
观察传说中的mysql hive数据库是否存在
用hive用户登录mysql
hadoop@ubuntu:/usr/local$ mysql -h localhost -u hive -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 78
Server version: 5.5.37-0ubuntu0.12.10.1 (Ubuntu)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show tables;
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hive |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.14 sec)
mysql> use hive;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_hive |
+---------------------------+
| BUCKETING_COLS |
| CDS |
| COLUMNS_V2 |
| DATABASE_PARAMS |
| DBS |
| PARTITION_KEYS |
| SDS |
| SD_PARAMS |
| SEQUENCE_TABLE |
| SERDES |
| SERDE_PARAMS |
| SKEWED_COL_NAMES |
| SKEWED_COL_VALUE_LOC_MAP |
| SKEWED_STRING_LIST |
| SKEWED_STRING_LIST_VALUES |
| SKEWED_VALUES |
| SORT_COLS |
| TABLE_PARAMS |
| TBLS |
| VERSION |
+---------------------------+
20 rows in set (0.00 sec)
mysql>
可见成功了。
11.安装hive网络接口
退出hive shell,回到命令行
输入
hadoop@ubuntu:/usr/local/hive-0.12.0$ bin/hive --service metastore &
&表示后台
显示
[1] 7710
hadoop@ubuntu:/usr/local/hive-0.12.0$ Starting Hive Metastore Server
不用苦等他结束,直接输入
bin/hive --service metastore &
bin/hive --service hwi &
显示
开始了服务
可以在hive.site.xml中查看一下hive的端口
<span style="font-size:18px;"><property> <name>hive.hwi.listen.host</name> <value>0.0.0.0</value> <description>This is the host address the Hive Web Interface will listen on</description> </property> <property> <name>hive.hwi.listen.port</name> <value>9999</value> <description>This is the port the Hive Web Interface will listen on</description> </property> </span>
发现是9999
12.登录网络接口
需要本机ip地址
命令为
ifconfig -a |grep inet
然后打开浏览器输入地址
http://你的机器ip:9999/hwi
比如
http://100.138.6.123:9999/hwi
显示
这时如果再次尝试
bin/hive --service metastore &
就会抛出许多异常,因为端口已被占用
org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:9083.
at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:93)
at org.apache.thrift.transport.TServerSocket.<init>(TServerSocket.java:75)
主要参考
http://www.cnblogs.com/bjtu-leefon/p/3170044.html
http://blog.csdn.net/yfkiss/article/details/7721329#
http://www.linuxidc.com/Linux/2013-06/86104.htm
http://blog.csdn.net/yonghutwo/article/details/23700749
http://blog.163.com/songyalong1117@126/blog/static/1713918972014124481752/
大功告成!!!!
ubuntu下搭建hive(包括hive的web接口)记录的更多相关文章
- Ubuntu下搭建NodeJS+Express WEB开发框架
Ubuntu下搭建NodeJS+Express WEB开发框架 2012-12-27 15:06 作者: NodeJSNet 来源: 本站 浏览: 2,966 次阅读 我要评论暂无评论 字号: 大 中 ...
- 在Ubuntu下搭建ASP.NET 5开发环境
在Ubuntu下搭建ASP.NET 5开发环境 0x00 写在前面的废话 年底这段时间实在太忙了,各种事情都凑在这个时候,没时间去学习自己感兴趣的东西,所以博客也好就没写了.最近工作上有个小功能要做成 ...
- Ubuntu下搭建ASP.NET 5
在Ubuntu下搭建ASP.NET 5开发环境 0x00 写在前面的废话 年底这段时间实在太忙了,各种事情都凑在这个时候,没时间去学习自己感兴趣的东西,所以博客也好就没写了.最近工作上有个小功能要 ...
- 如何在Ubuntu下搭建tftp服务器
远程桌面连接工具 今天开始调试arm的板子,要通过tftp下载到板子上,所以又要配置tftp服务器,真的烦死了… (本人酷爱装系统,所以经常都要搞配置) 因为之前已经在Ubuntu下搭建过很多次t ...
- 在Linux(Ubuntu)下搭建ASP.NET Core环境并运行 继续跨平台
最新教程:http://www.cnblogs.com/linezero/p/aspnetcoreubuntu.html 无需安装mono,在Linux(Ubuntu)下搭建ASP.NET Core环 ...
- 如何在Ubuntu下搭建Android NDK开发环境
1 搭建Android SDK开发环境 参考在在Ubuntu下搭建Android SDK开发环境(图文)首先在Ubuntu下搭建Android SDK开发环境. 2 下载NDK开发包 打开官网: ht ...
- 在Ubuntu下搭建FTP服务器的方法
由于整个学校相当于一个大型局域网,相互之间传送数据非常快,比如要共享个电影,传点资料什么的. 所以我们可以选择搭建一个FTP服务器来共享文件. 那么问题来了,有的同学会问,我们既然在一个局域网内,直接 ...
- Ubuntu下搭建FTP服务器
Ubuntu下搭建FTP服务器 我装的服务器系统是Ubuntu 12.04 LTS,FTP软件当然是选择大名鼎鼎的vsftpd(very secure FTP daemon), 用系统自带的FTP还好 ...
- deepin/ubuntu下搭建Jekyll环境
title: deepin/ubuntu下搭建Jekyll环境 最近用github搭建了个博客,正好也学习一下markdown语法,由于markdown写完后不是立即可见,所以每次写完文章都要经过在线 ...
- Linux之旅-ubuntu下搭建nodejs环境
.NET Core也开源了,并且可移植到Linux下,而ubuntu作为linux发行版的翘楚,极大的方便了初学者的入门,搭建完ASP.NET Core运行环境后,作为半前半后的开发人员,就继续着搭建 ...
随机推荐
- Netsharp快速入门(之19) 平台常用功能(插件操作)
作者:秋时 暗影 转载须说明出处 6.2 插件操作 6.2.1 停用/启用 1.在平台工具-插件管理,右击对应的插件可以使用启用和停用功能.插件停用后会把所有相关的页签.程序集.服务全部停 ...
- 为什么匿名内部类参数必须为final类型(转载)
为什么匿名内部类参数必须为final类型转自于:http://feiyeguohai.iteye.com/blog/1500108 1) 从程序设计语言的理论上:局部内部类(即:定义在方法中的内部类 ...
- mailx 乱码,sendmail发html邮件,脚本开机启动
echo "yes"|mailx -s "我" -S ttycharset=utf-8 -S sendcharsets=utf-8 -S encoding=ut ...
- lle算法
http://www.pami.sjtu.edu.cn/people/xzj/introducelle.htm
- 简单的表视图UITableView
1.建一个Single View application 2.在故事板中放置一个Table View控件 3.在.h文件中加入协议 <UITableViewDataSource,UITableV ...
- IIS Express 一个网站配置多个 域名
在配置localhost和IP都可以访问: 方法1: applicationhost.config文件配置: <bindings> <binding protocol=& ...
- mvc从xheditor编辑器中获取内容时存在潜在危险
xmfdsh在使用xheditor提交要发布的文章等内容的时候出现了如下的错误: 从客户端(Content="<p style="text-align...")中检 ...
- vi/vim使用指北 ---- Learning the vi and Vim Editors 读书 笔记
vi/vim作为liux系统下最强大,最流行的文本编辑器之一.边看<Learning the vi and vim Editor>边学习vim,顺便做写简单的笔记,供以后查询. 没看这本书 ...
- ASP.NET MVC 应用提速的十种方法
[编者按]本文作者为 DZone 社区的最具价值博主(MVB) Jonathan Danylko,主要介绍为 ASP.NET MVC 应用提速的十种方法.由国内 ITOM 管理平台 OneAPM 编译 ...
- 如何用 Parse 和 Swift 搭建一个像 Instagram 那样的应用?
[编者按]本篇文章作者是Reinder de Vries,既是一名企业家,也是优秀的程序员,发表多篇应用程序的博客.本篇文章中,作者主要介绍了如何基于Parse特点,打造一款类似Instagram的应 ...