1. 程式人生 > >將MySQL作為hive的元資料庫時遇到的問題

將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