将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]

       <property>

              <name>javax.jdo.option.ConnectionPassword</name>

              <value>root</value>

              <description>password to use against metastore database</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.ConnectionURL</name>

              <value>jdbc:mysql://192.168.231.1:3306/hive2</value>

       </property>

       <property>

              <name>javax.jdo.option.ConnectionDriverName</name>

              <value>com.mysql.jdbc.Driver</value>

              <description>Driver class name for a JDBC metastore</description>

       </property>

配置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

猜你喜欢

转载自blog.csdn.net/Heitao5200/article/details/81544376