设为首页 加入收藏

TOP

Hive 安装-使用HDFS文件系统
2019-01-21 00:11:07 】 浏览:63
Tags:Hive 安装 使用 HDFS 文件 系统
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38038143/article/details/84432998

1.下载、解压Hive

下载网站:http://www.apache.org/dyn/closer.cgi/hive/
百度网盘:链接:https://pan.baidu.com/s/16QzSgxa_VLnJ7ksnLUrtEw
提取码:ef9b

这里下载的是2.3.4 版本。

  1. 解压到 /home/hadoop/目,并修改名称:
tar -zxvf apache-hive-2.3.4-bin.tar.gz -C ~/
mv apache-hive-2.3.4-bin hive-2.3.4
  1. 配置环境变量
    vim ~/.bashrc
export HIVE_HOME=/home/hadoop/hive-2.3.4
export PATH=$PATH:$HIVE_HOME/bin/

执行 source ~/.bashrc

2. 安装MySQL

  1. 不同版本请百度,这里简述Ubuntu版本安装命令:
sudo apt-get install mysql-server
 
sudo apt-get isntall mysql-client
 
sudo apt-get install libmysqlclient-dev
  1. 创建用户
  • 使用root 用户登录
  • 创建数据库
  • 创建普通用户:bee,密码:123456:
  • 授权bee用户拥有刚才创建数据库的所有权限
  • 刷新权限表
mysql -uroot -p

create database hiveDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

create user 'bee' identified by '123456';

grant all privileges on hiveDB.* to 'bee'@'%' identified by '123456';

flush privileges;

登录 bee用户查看数据库:
在这里插入图片描述

重点:
将JDBC驱动文件复制到Hive的lib目录:
在这里插入图片描述

3. 配置Hive

目录:hive-2.3.4/conf

  1. hive-env.sh
    在末尾加入Hadoop安装目录,如博主的目录为:
HADOOP_HOME=/usr/local/hadoop
  1. hive-site.xml
    目录下应该不存在,所以自己创建,在此附上完整配置代码:
<xml version="1.0" encoding="UTF-8">
<xml-stylesheet type="text/xsl" href="configuration.xsl">
<!--
  Licensed 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. See accompanying LICENSE file.
-->

<!-- Put site-specific property overrides in this file. -->

<configuration>

	<property>
		<name>hive.exec.scratchdir</name>
        <value>/tmp/hive</value>
	</property>
	<property>
		<name>hive.metastore.warehouse.dir</name>
        <value>hdfs://master:9000/hive/warehouse</value>
        <description>location to default database for the warehouse</description>
	</property>
	<property>
		<name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://localhost:3306/hiveDBcreateDatabaseIfNotExist=true&amp;characterEncoding=UTF-8&amp;useSSL=false</value>
        <description>Hive access metastore using JDBC connectionURL</description>
	</property>
	<property>
		<name>javax.jdo.option.ConnectionDriverName</name>
		<value>com.mysql.jdbc.Driver</value>
	</property>
	<property>
		<name>javax.jdo.option.ConnectionUserName</name>
		<value>bee</value>
	</property>
	<property>
		<name>javax.jdo.option.ConnectionPassword</name>
		<value>123456</value>
        <description>password to access metastore database</description>
	</property>
	<property>
		<name>javax.jdo.option.Multithreaded</name>
		<value>true</value>
	</property>

    <!-- 分割 -->

	<property>
		<name>hive.metasotre.schema.verification</name>
		<value>true</value>
	</property>

</configuration>
  1. HDFS创建目录
    开启HDFS情况下,创建上述配置中的目录,并赋予权限:
hdfs dfa -mkdir -p /tmp/hive

hdfs dfs -mkdir -p /hive/warehouse

hdfs dfs -chmod -R g+w /tmp

hdfs dfs -chmod -R g+w /hive 
  1. 初始化数据库(可以先跳过这步,因为博主看的书上没有写,如果后面操作时有错误可以返回来再操作,博主是先执行了)
    命令:
hadoop@master:~$ schematool -dbType mysql -initSchema
  1. 启动Hive

在这里插入图片描述

Hive的HQL操作和SQL几乎一样,这里简单示例,default为系统自带数据库:
在这里插入图片描述

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇未完待续   HDFS中使用had.. 下一篇Hadoop-->HDFS原理总结

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目