Mac上Hive安装配置
Posted taojietaoge
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac上Hive安装配置相关的知识,希望对你有一定的参考价值。
Mac上Hive安装配置
1、安装
下载hive,地址:http://mirror.bit.edu.cn/apache/hive/
之前我配置了集群,tjt01、tjt02、tjt03,这里hive安装在tjt01机器上。
我下载的是“apache-hive-3.0.0-bin.tar.gz”,将hive 3.0版本上传到/opt目录,并解压到/usr/local下:
[[email protected] ~]# cd /opt
[[email protected] opt]# tar -zxvf apache-hive-3.0.0-bin.tar.gz -C /usr/local/
将目录重命名为hive目录:
[[email protected] opt]# cd /usr/local/
[[email protected] local]# mv apache-hive-3.0.0-bin hive
[[email protected] local]#
修改环境变量/etc/profile:
[[email protected] local]# vi /etc/profile
在profile文件中添加如下内容:
export HIVE_HOME=/usr/local/hive
export PATH=$PATH:$HIVE_HOME/bin
生效profile:
[[email protected] local]# vi /etc/profile
[[email protected] local]# source /etc/profile
执行 hive --version查看hive版本
[[email protected] local]# hive --version
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.6/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Hive 3.0.0
Git git://vgargwork.local/Users/vgarg/repos/hive.apache.master.latest -r ce61711a5fa54ab34fc74d86d521ecaeea6b072a
Compiled by vgarg on Fri May 18 11:38:33 PDT 2018
From source with checksum 81fcb93b608965ed7ac968bae1187fab
[[email protected] local]#
2、安装mysql
我之前安装过了,Mysql安装参考:https://www.cnblogs.com/taojietaoge/p/10692557.html
启动Mysql服务:
[[email protected] ~]# sudo service mysqld start
启动过程报错了下,简单解决如下:
[[email protected] ~]# /etc/init.d/mysqld start
Starting mysqld (via systemctl): Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[FAILED]
[[email protected] ~]# mkdir /var/run/mysqld/
[[email protected] ~]# chown mysql.mysql /var/run/mysqld/
[[email protected] ~]# sudo service mysqld start
Starting mysqld (via systemctl): [ OK ]
[[email protected] ~]#
设置Mysql开机启动:
[[email protected] ~]# systemctl enable mysqld
mysqld.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig mysqld on
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]#
3、配置
3.1 修改hive-site.xml
[[email protected] conf]# cd ~
[[email protected] ~]# cd /usr/local/hive/conf/
[[email protected] conf]# cp hive-default.xml.template hive-site.xml
[[email protected] conf]# vim hive-site.xml
xml内容如下:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://172.16.114.132:3306/hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>[email protected]</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
3.2 复制Mysql的程序程序到hive/lib下
mysql-connector-java.jar
3.3 创建Mysql下的hive数据库
mysql> create database hive;
Query OK, 1 row affected (0.01 sec)
mysql>
3.4 在Mysql中hive的schema创建
[[email protected] bin]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.7.6/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL: jdbc:mysql://172.16.114.132:3306/hive
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
Starting metastore schema initialization to 3.0.0
Initialization script hive-schema-3.0.0.mysql.sql
Initialization script completed
schemaTool completed
[[email protected] bin]#
4、测试
进入hive之前,开启hadoop,键入hive进入hive:
[[email protected] bin]# start-dfs.sh
Starting namenodes on [tjt01]
tjt01: starting namenode, logging to /opt/hadoop-2.7.6/logs/hadoop-root-namenode-tjt01.out
tjt03: starting datanode, logging to /opt/hadoop-2.7.6/logs/hadoop-root-datanode-tjt03.out
tjt02: starting datanode, logging to /opt/hadoop-2.7.6/logs/hadoop-root-datanode-tjt02.out
tjt01: starting datanode, logging to /opt/hadoop-2.7.6/logs/hadoop-root-datanode-tjt01.out
Starting secondary namenodes [tjt02]
tjt02: starting secondarynamenode, logging to /opt/hadoop-2.7.6/logs/hadoop-root-secondarynamenode-tjt02.out
[[email protected] bin]#hive
创建hive数据库:
hive> create database hive_1;
OK
Time taken: 0.709 seconds
hive> show databases;
OK
default
hive_1
Time taken: 0.238 seconds, Fetched: 2 row(s)
hive>
观察Mysql下hive数据库的变化:
mysql> select * from DBS;
在hive_1下创建一个hive_01:
hive> use hive_1;
OK
Time taken: 0.066 seconds
hive> create table hive_01 (id int, name string);
OK
Time taken: 1.235 seconds
hive>
再次观察Mysql下hive数据库的变化:
mysql> select * from TBLS;
到此为止,Mac安装Hive完美收官!
以上是关于Mac上Hive安装配置的主要内容,如果未能解决你的问题,请参考以下文章