mac hive mysql 配置_Mac上Hive安装配置

[root@tjt01 ~]# cd /opt

[root@tjt01 opt]#tar -zxvf apache-hive-3.0.0-bin.tar.gz -C /usr/local/

9055c9d55d8b480f52f4ad6bdaf81b5e.png

将目录重命名为hive目录:

[root@tjt01 opt]# cd /usr/local/[root@tjt01 local]#mv apache-hive-3.0.0-bin hive

[root@tjt01 local]#

修改环境变量/etc/profile:

[root@tjt01 local]# vi /etc/profile

在profile文件中添加如下内容:

export HIVE_HOME=/usr/local/hive

export PATH=$PATH:$HIVE_HOME/bin

生效profile:

[root@tjt01 local]# vi /etc/profile

[root@tjt01 local]# source/etc/profile

执行 hive --version查看hive版本

[root@tjt01 local]# hive --version

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found bindingin [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found bindingin [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]

Hive3.0.0Git git://vgargwork.local/Users/vgarg/repos/hive.apache.master.latest -r ce61711a5fa54ab34fc74d86d521ecaeea6b072a

Compiled by vgarg on Fri May 18 11:38:33 PDT 2018From source with checksum 81fcb93b608965ed7ac968bae1187fab

[root@tjt01 local]#

29a6e7acc431869c698a3952246e3a67.png

2、安装Mysql

启动Mysql服务:

[root@tjt03 ~]# sudo service mysqld start

启动过程报错了下,简单解决如下:

[root@tjt03 ~]# /etc/init.d/mysqld start

Starting mysqld (via systemctl): Jobfor mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" fordetails.

[FAILED]

[root@tjt03~]# mkdir /var/run/mysqld/[root@tjt03~]# chown mysql.mysql /var/run/mysqld/[root@tjt03~]# sudoservice mysqld start

Starting mysqld (via systemctl): [ OK ]

[root@tjt03~]#

设置Mysql开机启动:

[root@tjt03 ~]# systemctl enable mysqld

mysqld.serviceis not a native service, redirecting to /sbin/chkconfig.

Executing/sbin/chkconfig mysqld on

[root@tjt03 ~]# systemctl daemon-reload[root@tjt03 ~]#

68b6f7dacf8d505dfdb3e51b3de17ede.png

3、配置

3.1 修改hive-site.xml

[root@tjt01 conf]# cd ~[root@tjt01~]# cd /usr/local/hive/conf/[root@tjt01 conf]#cp hive-default.xml.template hive-site.xml

[root@tjt01 conf]# vim hive-site.xml

xml内容如下:

javax.jdo.option.ConnectionURL

jdbc:mysql://172.16.114.132:3306/hive

javax.jdo.option.ConnectionDriverName

com.mysql.jdbc.Driver

javax.jdo.option.ConnectionUserName

root

javax.jdo.option.ConnectionPassword

TANjintao@520

hive.metastore.schema.verification

false

3.2 复制Mysql的程序程序到hive/lib下

mysql-connector-java.jar

03c2b529df16ecb0848e276c50d7f46d.png

3.3 创建Mysql下的hive数据库

mysql> create database hive;

Query OK, 1 row affected (0.01 sec)

mysql>

3.4 在Mysql中hive的schema创建

[root@tjt01 bin]# schematool -dbType mysql -initSchema

SLF4J: Class pathcontainsmultiple SLF4J bindings.

SLF4J: Found bindingin [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found bindingin [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 foran explanation.

SLF4J: Actual bindingis 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 connectionUser: root

Starting metastoreschema initialization to 3.0.0Initialization script hive-schema-3.0.0.mysql.sql

Initialization script completed

schemaTool completed[root@tjt01 bin]#

4、测试

进入hive之前,开启hadoop,键入hive进入hive:

[root@tjt01 bin]# start-dfs.sh

Starting namenodeson [tjt01]tjt01: starting namenode, loggingto /opt/hadoop-2.7.6/logs/hadoop-root-namenode-tjt01.out

tjt03: starting datanode, loggingto /opt/hadoop-2.7.6/logs/hadoop-root-datanode-tjt03.out

tjt02: starting datanode, loggingto /opt/hadoop-2.7.6/logs/hadoop-root-datanode-tjt02.out

tjt01: starting datanode, loggingto /opt/hadoop-2.7.6/logs/hadoop-root-datanode-tjt01.out

Starting secondary namenodes[tjt02]tjt02: starting secondarynamenode, loggingto /opt/hadoop-2.7.6/logs/hadoop-root-secondarynamenode-tjt02.out[root@tjt01 bin]#hive

3bdd598237ead0e9cb01e545a8ba334f.png

创建hive数据库:

hive> create databasehive_1;

OK

Time taken:0.709seconds

hive>show databases;

OKdefaulthive_1

Time taken:0.238 seconds, Fetched: 2row(s)

hive>

观察Mysql下hive数据库的变化:

mysql> select * from DBS;

891c02f48f30858d254f47a450b2c65d.png

在hive_1下创建一个hive_01:

hive> usehive_1;

OK

Time taken:0.066seconds

hive> create table hive_01 (id int, name string);

OK

Time taken:1.235seconds

hive>

再次观察Mysql下hive数据库的变化:

mysql> select * from TBLS;

aa7ce7b92fb36f309691b83badf426bf.png

到此为止,Mac安装Hive完美收官!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值