spark mysql 环境搭建_Hive搭建

  • Post author:
  • Post category:mysql


仅仅在spark1上搭建

下载安装HIVE下载hive,下载bin版本,不要下载src版本

将下载的hive包解压缩到/usr/local文件夹下

修改夹名字为hive

配置环境变量

下载安装mysql

安装mysql serveryum install -y mysql-server

service mysqld start

chkconfig mysqld on

安装mysql connectoryum install -y mysql-connector-java

将mysql connector拷贝到hive的lib包中cp /usr/share/java/mysql-connector-java-5.1.17.jar /usr/local/hive/lib

在mysql上创建hive元数据库,并对hive进行授权create database if not exists hive_metadata;

grant all privileges on hive_metadata.* to ‘hive’@’%’ identified by ‘hive’;

grant all privileges on hive_metadata.* to ‘hive’@’localhost’ identified by ‘hive’;

grant all privileges on hive_metadata.* to ‘hive’@’spark1’ identified by ‘hive’;

flush privileges;

use hive_metadata;

配置hive-site.xmlcd /hive/conf

mv hive-default.xml.template hive-site.xml

vi hive-site.xml

修改hive-site.xml相应内容javax.jdo.option.ConnectionURL  jdbc:mysql://spark1:3306/hive_metadata?createDatabaseIfNotExist=true  javax.jdo.option.ConnectionDriverName  com.mysql.jdbc.Driver  javax.jdo.option.ConnectionUserName  hive  javax.jdo.option.ConnectionPassword  hive  hive.metastore.warehouse.dir  /user/hive/warehouse

配置hive-env.sh和hive-config.shcd /hive/conf

mv hive-env.sh.template hive-env.sh

vi /usr/local/hive/bin/hive-config.sh

修改hive-config.shexport JAVA_HOME=/usr/java/latest

export HIVE_HOME=/usr/local/hive

export HADOOP_HOME=/usr/local/hadoop

验证hive是否安装成功

直接输入hive命令,可以进入hive命令行

如果出现以下错误:[Fatal Error] hive-site.xml:2787:3: The element type “configuration” must be terminated by the matching end-tag “”.

原因是hive-site.xml文件2783行少了一个

测试hive[root@spark1 conf]# hive

18/11/18 08:00:06 WARN conf.HiveConf: DEPRECATED: hive.metastore.ds.retry.* no longer has any effect.  Use hive.hmshandler.retry.* instead

Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.13.1-cdh5.3.6.jar!/hive-log4j.properties

hive> show databases;

OK

default

Time taken: 0.413 seconds, Fetched: 1 row(s)

hive> create table t1(id int);

OK

Time taken: 0.786 seconds

hive> drop table t1;

OK

Time taken: 0.559 seconds



版权声明:本文为weixin_35450735原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。