HIVE 二进制安装

HIve安装前提是mysql已经安装成功。安装步骤上个笔记有

切换hadoop用户 :su - hadoop

 

xftp打开目录: /home/hadoop/soft

 

上传hive二进制文件:tar -xvf apache-hive-1.2.2-bin.tar.gz

 

移动解压的文件:mv apache-hive-1.2.2-bin ../install/hive

 

修改环境变量

vim /etc/profile

export HIVE_HOME=/home/hadoop/install/hive

export PATH=$PATH:$HIVE_HOME/bin

 

保存并使环境变量立即生效

source /etc/profile

 

HIVE存放元数据(将HDFS文件,映射为HIVE里面的表结构定义信息--->元数据信息)

数据信息是存储在HDFS上的

 

HIVE--->MYSQL需要JDBC的支持,我们需要把JDBC包拷贝到hive/lib目录下

cp /soft/mysql-connector-java-5.1.38.jar /home/hadoop/install/hive/lib

 

-------------------------------------------------MySQL赋权操作----------------------------------------

创建hive数据库

mysql> create database hive default character set latin1;

Query OK, 1 row affected (0.04 sec)

创建hive用户并赋予权限

mysql> grant all on *.* to 'hive'@'%' identified by 'hive';

Query OK, 0 rows affected (0.04 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.03 sec)

查询 mysql.user信息

mysql> select user,host,password from mysql.user;

+------+-----------+-------------------------------------------+

| user | host | password |

+------+-----------+-------------------------------------------+

| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

| root | % | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

| hive | % | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |

+------+-----------+-------------------------------------------+

3 rows in set (0.00 sec)

创建hive配置文件

vim hive-site.xml

————————————————————————————————————————————

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!--

Licensed to the Apache Software Foundation (ASF) under one or more

contributor license agreements. See the NOTICE file distributed with

this work for additional information regarding copyright ownership.

The ASF licenses this file to You under the Apache License, Version 2.0

(the "License"); you may not use this file except in compliance with

the License. You may obtain a copy of the License at

 

http://www.apache.org/licenses/LICENSE-2.0

 

Unless required by applicable law or agreed to in writing, software

distributed under the License is distributed on an "AS IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and

limitations under the License.

-->

<configuration>

 

<property>

<name>javax.jdo.option.ConnectionURL</name>

<value>jdbc:mysql://192.168.2.10:3306/hive?characterEncoding=UTF-8</value>

</property>

 

<property>

<name>javax.jdo.option.ConnectionDriverName</name>

<value>com.mysql.jdbc.Driver</value>

</property>

 

<property>

<name>javax.jdo.option.ConnectionUserName</name>

<value>hive</value>

</property>

 

<property>

<name>javax.jdo.option.ConnectionPassword</name>

<value>hive</value>

</property>

 

<!-- hdfs hive存储数据的目录 -->

<property>

<name>hive.metastore.warehouse.dir</name>

<value>/usr/hive/warehouse</value>

</property>

 

<!-- 本地元数据服务 -->

<property>

<name>hive.metastore.local</name>

<value>true</value>

</property>

</configuration>

——————————————————————————————————————————

 

显示所有数据库

show databases;

 

可以建立数据库

create database test1;

 

切换数据库

use test1;

 

建立表employee

CREATE TABLE employee (

eid int,

name String,

salary String,

destination String)

ROW FORMAT DELIMITED

FIELDS TERMINATED BY '\t'

LINES TERMINATED BY '\n'

STORED AS TEXTFILE;

 

查看所有表

show tables;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值