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运行环境后,作为半前半后的开发人员,就继续着搭建 ...
随机推荐
- 2. ProGit-Git基础
(1) 取得项目的Git仓库 从工作目录中初始化新仓库 git init 从现有仓库克隆 git clone ssh协议 http协议 (2) 检查当前文件状态 git status (3) ...
- GBDT(MART)
转自:http://blog.csdn.net/w28971023/article/details/8240756 在网上看到一篇对从代码层面理解gbdt比较好的文章,转载记录一下: GBDT(Gra ...
- 小技巧---查doc文档的index.html怎么用的和chm一样
看包里面是否有E:\Java\hibernate3.3.2\hibernate-annotations-3.4.0.GA\hibernate-annotations-3.4.0.GA\doc\refe ...
- UML序列图总结
转载请注明出处:htt://blog.csdn.net/tianhai110 序列图主要用于展示对象之间交互的顺序. 序列图将交互关系表示为一个二维图.纵向是时间轴,时间沿竖线向下延伸.横向轴代表了在 ...
- Combox 实现百度收索框效果
标题中所谓百度收缩框效果,就是在输入数据的时候,自动提示,来张图就明白了: 用Combox来实现这个功能只是需要设置三个A开头的属性就OK了:AutoCompleteSource.AutoComple ...
- dancing link
http://www.cnblogs.com/grenet/p/3145800.html 链接给的博客写的很好,比较好懂. 可惜不是c语言... 于是决定自己要建一个模板. 一道裸题:hustoj 1 ...
- add some template for ec-final
二维rmq 离线 init O( n*n*logn*logn ) query O(1) http://www.cnblogs.com/kuangbin/p/3227420.html 求1-n有多少个 ...
- javascript 字符串和json的互转
FROM:http://www.cnblogs.com/mizzle/archive/2012/02/10/2345891.html 在数据传输过程中,json是以文本,即字符串的形式传递的,而JS操 ...
- ios 环境配置网址
http://blog.csdn.net/cwb1128/article/details/18019751
- Extjs中自定义事件
//Ext中所谓的响应事件,响应的主要是组件中已经定义的事件(通过看api各组件的events可以找到) //主要作用就是利用on调用各组件的事件处理函数,然后在函数中作用户想要的操作 ...