mac OSX 上 brew install hive

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:

本文介绍brew install hive并修改默认的metastore存储方案,改Derby数据库为mysql的方法以及可能遇到的问题的解决方案。

1. 通过homebrew安装hive

1
brew  install  hive

2. 添加hadoop和hive的环境变量

1
2
3
4
5
6
sudo  vim ~/.bash_profile
 
export  HADOOP_HOME= /usr/local/Cellar/hadoop/hadoop .version.no
export  HIVE_HOME= /usr/local/Cellar/hive/hive .version.no /libexec
 
source  ~/.bash_profile

3. 下载mysql connector

1
2
3
 
sudo  cp  mysql-connector-java-5.1.15 /mysql-connector-java-5 .1.22-bin.jar  /usr/local/Cellar/hive/hive .version.no /libexec/lib/

4. 创建mysql metastore

1
2
3
4
mysql>  CREATE  DATABASE  metastore;
mysql> USE metastore;
mysql>  CREATE  USER  'hiveuser' @ 'localhost'  IDENTIFIED  BY  'password' ;
mysql>  GRANT  SELECT , INSERT , UPDATE , DELETE , ALTER , CREATE  ON  metastore.*  TO  'hiveuser' @ 'localhost' ;

5. 配置hive的配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cd  /usr/local/Cellar/hive/hive .version.no /libexec/conf
cp  hive-default.xml.template hive-site.xml
 
#添加或者编辑如下内容
<property>
   <name>javax.jdo.option.ConnectionURL< /name >
   <value>jdbc:mysql: //localhost/metastore < /value >
< /property >
<property>
   <name>javax.jdo.option.ConnectionDriverName< /name >
   <value>com.mysql.jdbc.Driver< /value >
< /property >
<property>
   <name>javax.jdo.option.ConnectionUserName< /name >
   <value>hiveuser< /value >
< /property >
<property>
   <name>javax.jdo.option.ConnectionPassword< /name >
   <value>password< /value >
< /property >
<property>
   <name>datanucleus.fixedDatastore< /name >
   <value> false < /value >
< /property >

6. 测试hive是否工作

1
2
3
$ hive;
hive > show tables;
hive> create table temp_table temp_col string;

7. Revoke few permissions on the mysql metastore

1
2
$ mysql
mysql> REVOKE ALTER,CREATE ON metastore.* FROM  'hiveuser' @ 'localhost' ;

9. Further troubleshooting : 
(a) If you get a bin log error saying statement format is not support. Login to your mysql console as root

$ mysql -uroot
mysql > SET GLOBAL binlog_format = 'ROW';

(b) You could also try reading the logs as follows. Logs can be emitted to the bash prompt while running hive by setting hive.root.logger to INFO,console.

$ hive -hiveconf hive.root.logger=INFO,console

(c)You could also read the raw hive logs which is usually located at /tmp/user_name/hive.log

 
(d)If you still have any errors, feel free to comment.
 
 
在配置完成后,可能遇到的问题解决方案
一,Reference error
解决方案:
        使用sequel pro, 修改hive用户的权限,添加Reference的global权限。
 
二,启动hive时遇到的" Caused by: java.net.URISyntaxException: Relative path in absolute URI:  {system:java.io.tmpdir%7D/{system:java.io.tmpdir%7D/%7Bsystem:user.name%7D "
 
解决方案:
 
修改hive-site.xml 配置中的以下key value即可:
 
<name>hive.exec.scratchdir</name>
<value>/tmp/hive-${user.name}</value>
 
 <name>hive.exec.local.scratchdir</name>
 <value>/tmp/${user.name}</value>
 
<name>hive.downloaded.resources.dir</name>
<value>/tmp/${user.name}_resources</value>
 
<name>hive.scratch.dir.permission</name>
    <value>733</value>
 
restart hive metastore and hiveserver2 


本文转自fandyst 博客园博客,原文链接:http://www.cnblogs.com/ToDoToTry/    ,如需转载请自行联系原作者

相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
SQL 关系型数据库 MySQL
Mac下安装hive
Mac下安装hive
811 0
|
缓存 关系型数据库 MySQL
Mac安装brew
Mac安装brew
1228 6
|
11月前
|
NoSQL Shell MongoDB
Mac OSX 平台安装 MongoDB
10月更文挑战第11天
203 4
|
12月前
|
数据采集 中间件 关系型数据库
Mac系统通过brew安装mysql5.7后,启动报错的解决办法
Mac系统通过brew安装mysql5.7后,启动报错的解决办法
830 2
|
数据安全/隐私保护 iOS开发 MacOS
Mac终端出现 brew command not found 解决
Mac终端出现 brew command not found 解决
659 3
Mac Brew install慢的问题
Mac Brew install慢的问题
243 1
|
iOS开发 MacOS
mac下安装brew下载非常慢解决方法
mac下安装brew下载非常慢解决方法
1186 1
Mac的brew修改国内源
Mac的brew修改国内源
1586 0
|
数据安全/隐私保护
Mac平台出现brew command not found问题解决方法
Mac平台出现brew command not found问题解决方法
2407 1
Mac brew 卡在 ‘Cloning into ‘.../homebrew-core(或 homebrew-cas)‘
Mac brew 卡在 ‘Cloning into ‘.../homebrew-core(或 homebrew-cas)‘
415 0