Hive metastore三種配置方式
Hive的meta資料支援以下三種儲存方式,其中兩種屬於本地儲存,一種為遠端儲存。遠端儲存比較適合生產環境。Hive官方wiki詳細介紹了這三種方式,連結為:Hive Metastore。
一、本地derby
這種方式是最簡單的儲存方式,只需要在hive-site.xml做如下配置便可
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=metastore_db;create=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
</configuration>
注:使用derby儲存方式時,執行hive會在當前目錄生成一個derby檔案和一個metastore_db目錄。這種儲存方式的弊端是在同一個目錄下同時只能有一個hive客戶端能使用資料庫,否則會提示如下錯誤
[html] view plaincopyprint?
hive> show tables;
FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: Failed to start database 'metastore_db', see the next exception for details.
NestedThrowables:
java.sql.SQLException: Failed to start database 'metastore_db', see the next exception for details.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
二、本地mysql
這種儲存方式需要在本地執行一個mysql伺服器,並作如下配置(下面兩種使用mysql的方式,需要將mysql的jar包拷貝到$HIVE_HOME/lib目錄下)。
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
</configuration>
三、遠端mysql
這種儲存方式需要在遠端伺服器執行一個mysql伺服器,並且需要在Hive伺服器啟動meta服務。
這裡用mysql的測試伺服器,ip位192.168.1.214,新建hive_remote資料庫,字符集位latine1
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.1.214:3306/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.1.188:9083</value>
</property>
</configuration>
注:這裡把hive的服務端和客戶端都放在同一臺伺服器上了。服務端和客戶端可以拆開,將hive-site.xml配置檔案拆為如下兩部分
1)、服務端配置檔案
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.1.214:3306/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>test1234</value>
</property>
</configuration>
2)、客戶端配置檔案
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.1.188:9083</value>
</property>
</configuration>
啟動hive服務端程式
[plain] view plaincopyprint?
$ hive --service metastore
客戶端直接使用hive命令即可
[plain] view plaincopyprint?
root@my188:~$ hive
Hive history file=/tmp/root/hive_job_log_root_201301301416_955801255.txt
hive> show tables;
OK
test_hive
Time taken: 0.736 seconds
hive>
http://blog.csdn.net/reesun/article/details/8556078
一、本地derby
這種方式是最簡單的儲存方式,只需要在hive-site.xml做如下配置便可
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=metastore_db;create=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
</configuration>
注:使用derby儲存方式時,執行hive會在當前目錄生成一個derby檔案和一個metastore_db目錄。這種儲存方式的弊端是在同一個目錄下同時只能有一個hive客戶端能使用資料庫,否則會提示如下錯誤
[html] view plaincopyprint?
hive> show tables;
FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: Failed to start database 'metastore_db', see the next exception for details.
NestedThrowables:
java.sql.SQLException: Failed to start database 'metastore_db', see the next exception for details.
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
二、本地mysql
這種儲存方式需要在本地執行一個mysql伺服器,並作如下配置(下面兩種使用mysql的方式,需要將mysql的jar包拷貝到$HIVE_HOME/lib目錄下)。
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
</configuration>
三、遠端mysql
這種儲存方式需要在遠端伺服器執行一個mysql伺服器,並且需要在Hive伺服器啟動meta服務。
這裡用mysql的測試伺服器,ip位192.168.1.214,新建hive_remote資料庫,字符集位latine1
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.1.214:3306/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.1.188:9083</value>
</property>
</configuration>
注:這裡把hive的服務端和客戶端都放在同一臺伺服器上了。服務端和客戶端可以拆開,將hive-site.xml配置檔案拆為如下兩部分
1)、服務端配置檔案
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.1.214:3306/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>test1234</value>
</property>
</configuration>
2)、客戶端配置檔案
[html] view plaincopyprint?
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.1.188:9083</value>
</property>
</configuration>
啟動hive服務端程式
[plain] view plaincopyprint?
$ hive --service metastore
客戶端直接使用hive命令即可
[plain] view plaincopyprint?
root@my188:~$ hive
Hive history file=/tmp/root/hive_job_log_root_201301301416_955801255.txt
hive> show tables;
OK
test_hive
Time taken: 0.736 seconds
hive>
http://blog.csdn.net/reesun/article/details/8556078
相關文章
- SparkSQL與Hive metastore ParquetSparkSQLHiveAST
- Eclipse中配置tomcat三種方式EclipseTomcat
- MySQL到TiDB:Hive Metastore橫向擴充套件之路MySqlTiDBHiveAST套件
- Spring Boot 讀取配置內容的三種方式Spring Boot
- AUTOCAD——三種修剪方式
- 三種繼承方式繼承
- Nginx 虛擬主機配置的三種方式(基於域名)Nginx
- 簡單介紹apache虛擬主機配置的三種方式Apache
- Mybatis批量更新三種方式MyBatis
- node 除錯三種方式除錯
- HTTP三種快取方式HTTP快取
- selenium-三種等待方式
- mysql 啟停三種方式MySql
- flowable 三種方式部署流程
- Flutter 三種JSON解析方式FlutterJSON
- Flutter 解析JSON 三種方式FlutterJSON
- JavaScript的三種引入方式JavaScript
- 詳解Nginx 虛擬主機配置的三種方式(基於埠)Nginx
- 詳解Nginx 虛擬主機配置的三種方式(基於IP)Nginx
- hive on spark配置HiveSpark
- 【Hive一】Hive安裝及配置Hive
- Python|讀、寫Excel檔案(三種模組三種方式)PythonExcel
- 三種方式本地執行Knative
- springAOP的三種實現方式Spring
- selenium中的三種等待方式
- WiFi攻擊的三種方式WiFi
- Selenium裡的三種等待方式
- 三種 Post 提交資料方式
- flowable 部署流程的三種方式
- linux安裝postgresql三種方式LinuxSQL
- hibernate的三種查詢方式
- Python selenium 三種等待元素方式Python
- Spring事務配置的五種方式Spring
- 兩種方式配置vue全域性方法Vue
- Java中Elasticsearch 實現分頁方式(三種方式)JavaElasticsearch
- Hive安裝配置Hive
- vue 元件的三種使用方式教程Vue元件
- 建立執行緒的三種方式執行緒
- html樣式表三種引入方式HTML