一、Hive是什么
hive是基于hadoop的数据仓库。
二、Hive安装
安装Hive的前提是安装了hadoop和Mysql,这里不再赘述 。很简单的,网上教程很多。本文仅演示单机安装。
1、下载
下载地址:http://hive.apache.org/,下载完了之后上传到/usr/local中
2、解压缩
[root@shengyu]# cd /usr/local
[root@shengyu local]# tar -zxvf apache-hive-2.1.1-bin.tar.gz -C /usr/local/
3、添加环境变量
[root@shengyu local]# vim /etc/profile
#hive
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
[root@shengyu local]# source /etc.profile
[root@shengyu local]# hive --version
4、配置
首先复制几个template文件
[root@shengyu conf]# cp hive-default.xml.template hive-site.xml
[root@shengyu conf]# cp hive-env.sh.template hive-env.sh
[root@shengyu conf]# cp hive-log4j.properties.template hive-log4j.properties
[root@shengyu conf]# cp hive-exec-log4j.properties.template hive-exec-log4j.properties
然后配置对应的配置文件
主要是配置hive-site.xml中的数据库连接
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.76.100: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>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123</value>
<description>password to use against metastore database</description>
</property>
</configuration>
复制mysql的驱动程序到hive/lib下面
[root@sehngyu lib]# ll mysql-connector-java-5.1.18-bin.jar
-rw-r--r-- 1 root root 789885 1月 4 01:43 mysql-connector-java-5.1.18-bin.jar
初始化mysql中hive的schema(在此之前需要创建mysql下的hive数据库)
[root@shengyu bin]# pwd
/usr/local/hive/bin
[root@shengyu bin]# schematool -dbType mysql -initSchema
启动hive命令
[root@shengyu hive]# hive
5、测试
看一下hadoop中的HDFS存了什么
[root@shengyu conf]# hadoop fs -lsr /
进入hive并创建一个测试库和测试表
[root@shengyu conf]# hive
创建表
hive> create database hive_1;
OK
显示库
hive> show databases;
OK
default
hive_1
再查询一下HDFS有什么变化?当然是多了一个一个库hive_1
最后修改:2019-02-22 18:12:05
© 著作权归作者所有
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
