使用MySQL作為Hive的Metastore

來源:互聯網
上載者:User

先確保你已經成功安裝了HIVE和MYSQL

在hive-site.xml中添加如下內容,指定METASTORE的地址以及串連方式

<property>    
<name>javax.jdo.option.ConnectionURL</name>    
<value>jdbc:mysql://10.20.151.10:3306/hive?characterEncoding=UTF-8</value>    
<description>JDBC connect string for a JDBC metastore</description> 
</property> 
<property>    
<name>javax.jdo.option.ConnectionDriverName</name>    
<value>com.mysql.jdbc.Driver</value>    
<description>Driver class name for a JDBC metastore</description> 
</property> 
<property>    
<name>javax.jdo.option.ConnectionUserName</name>    
<value>hive_user</value>    
<description>username to use against metastore database</description> 
</property> 
<property>    
<name>javax.jdo.option.ConnectionPassword</name>    
<value>123</value>    
<description>password to use against metastore database</description> 
</property>

然後登陸到HIVE用戶端,建立一個表試試

[gpadmin1@Hadoop5 hive-0.6.0]$ bin/hive
Hive history file=/tmp/gpadmin1/hive_job_log_gpadmin1_201106081130_1156785421.txt
hive> show tables;
FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: Unknown database 'hive'
NestedThrowables:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'hive'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

報錯了,提示很明顯,識別不到名稱為hive的database,難道要自己建立?試試

[Intranet root@www.bkjia.com /var/lib/mysql]
#mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41
Server version: 5.5.12 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database hive;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive               |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

再登陸到HIVE裡看看

[gpadmin1@hadoop5 hive-0.6.0]$ bin/hive
Hive history file=/tmp/gpadmin1/hive_job_log_gpadmin1_201106081130_544334815.txt
hive> show table;                      
FAILED: Parse Error: line 0:-1 mismatched input '<EOF>' expecting EXTENDED in show statement

hive> show tables;
OK
Time taken: 5.173 seconds
hive>         CREATE TABLE u_tmp1 (id1 INT,
    >            id2 int
    >            )
    >          ROW FORMAT DELIMITED
    >          FIELDS TERMINATED BY ',';
OK
Time taken: 0.266 seconds
hive> show tables;                        
OK
u_tmp1
Time taken: 0.197 seconds
hive>

OK了,果然是這個問題

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.