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运行环境后,作为半前半后的开发人员,就继续着搭建 ...
随机推荐
- Eclipse+pydev 常用快捷键
多行缩进(减少缩进):tab/shift+tab 复制行: Ctrl+Alt+方向键'↓' 删除行:Ctrl+d 自动完成:Alt+/ 注释:Ctrl+/ 窗口最大小:Ctrl+m 1 几个最重要的 ...
- IE6中布局常见问题
1.众所周知,每个IE的版本都有两种模式,怪异模式(混杂模式)和标准模式.下图附上针对IE的hack. 2.另外有一种引进css的方法,也可以作为调整网站hack的方法:<!—[if IE 6] ...
- Gulp的安装
Gulp 是前端自动化开发工具,我们可以用它提高开发效率. 它有以下用途: 压缩js.压缩css.压缩less.压缩图片等功能 首先我们开始安装Gulp Gulp是基于node来实现的,所以应该先安装 ...
- 【POJ】【3680】Intervals
网络流/费用流 引用下题解: lyd: 首先把区间端点离散化,设原来的数值i离散化后的标号是c[i].这样离散化之后,整个数轴被分成了一段段小区间. 1.建立S和T,从S到离散化后的第一个点连容量K, ...
- EXCEL 跨表比较数据
Public Sub Compare(fullname As String, sheet As String) Dim conn, sql, rows, i, cellContents ,rowInd ...
- 客户端发包 GS端接收
客户端发包,GS接收 bool GameServer::ProcessLoop(packet& rPkt)//GS线程做的 { if(false == m_spDataLayer->Re ...
- map初始化定时器
init_timer(); //各种定时器的初始化 void Map::init_timer() { //auto tf = GetPlug(TimerFactory); auto tf = m_sp ...
- 通过spring.net中的spring.caching CacheResult实现memcached缓存
通过spring.net中的spring.caching CacheResult实现memcached缓存1.SpringMemcachedCache.cs2.APP.config3.Program. ...
- JavaScript之表单验证讲解
JavaScript 可用来在数据被送往服务器前对 HTML 表单中的这些输入数据进行验证. JavaScript 表单验证 JavaScript 可用来在数据被送往服务器前对 HTML 表单中的这些 ...
- 利用URLRewriter.dll 实现ASP.NET实现伪静态
大家一定经常在网络上看到很多网站的地址后缀都是用XX.HTML或者XX.ASPX等类似静态文件的标示来操作的吧,那么大家有怀疑过他真的是一个一个的静态生成的文件么,静态文件的生成的优缺有好有坏,对于访 ...