将MySQL作为hive的元数据库时遇到的问题

 

Mysql版本  Ver 14.14 Distrib 5.6.40, for Linux (x86_64) using  EditLine wrapper

Hive版本      apache-hive-2.1.1-bin.tar.gz

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT' at line 1)

 

这个版本用mysql-connector-java-5.1.46-bin.jar!!!!!

下面详细介绍一下具体的安装流程

在虚拟机上安装mysql。

详情见https://blog.csdn.net/Heitao5200/article/details/80910549

在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'@'master888' identified by 'hive';

flush privileges;

use hive_metadata;

复制mysql驱动程序到hive的lib目录下

这个版本用mysql-connector-java-5.1.46-bin.jar!!!!!

 

配置hive-site.xml

       复制hive-default.xml.template为hive-site.xml

       修改连接信息为mysql链接地址,将${system:...字样替换成具体路径。

       [hive/conf/hive-site.xml]

      

              javax.jdo.option.ConnectionPassword

              root

              password to use against metastore database

      

      

              javax.jdo.option.ConnectionUserName

              root

              Username to use against metastore database

      

      

              javax.jdo.option.ConnectionURL

              jdbc:mysql://192.168.231.1:3306/hive2

      

      

              javax.jdo.option.ConnectionDriverName

              com.mysql.jdbc.Driver

              Driver class name for a JDBC metastore

      

配置hive-env.sh

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

配置hive-config.sh

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

export JAVA_HOME=/usr/java/latest

export HIVE_HOME=/usr/local/hive

export HADOOP_HOME=/usr/local/hadoop

 

验证hive是否安装成功

启动Hadoop

初始化hive的元数据(表结构)到mysql中。

       $>cd /soft/hive/bin

       $>schematool -dbType mysql -initSchema

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

create table users(id int, name string);

load data local inpath '/usr/local/users.txt' into table users;

select name from users;

 

 

hive-2.1.1+mysql-connector-java-5.1.46-bin.jar下载连接

https://download.csdn.net/download/heitao5200/10594301

你可能感兴趣的:(Hadoop,Mysql,Hive)