hive元資料庫配置、metadata
阿新 • • 發佈:2019-01-10
QQ交流群:335671559,歡迎交流
一、什麼是hive元資料?
hive元資料就是hive的一些基本的元素,主要包括hive表的基本屬性,如下 (1)hive表的資料庫名、表名、欄位名稱與型別、分割槽欄位與型別 (2)表的分割槽,分割槽的屬性location等 (3)serdeproperties, tblproperties等等 可以通過 desc formatted tablename 查看錶有哪些屬性 二、hive預設元資料庫Derby(嵌入模式) hive-default.xml通過如下配置設定- <name>javax.jdo.option.ConnectionURL</
- <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
- <description>JDBC connect string for a JDBC metastore</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>org.apache.derby.jdbc.EmbeddedDriver</
- <description>Driver class name for a JDBC metastore</description>
- </property>
(2)mysql部署在其他機器,hive伺服器開啟metadata服務,在hive伺服器上操作hive
(3)mysql部署在其他機器,hive伺服器開啟metadata服務,在hive客戶端訪問hive的metadata服務
配置mysql: 配置mysql時,首先要把mysql-jdbc-driver.jar拷貝到$HIVE_HOME/lib目錄下,修改hive-default.xml名字為hive-site.xml 第一種情況,hive-site.xml配置如下
- <property>
- <name>hive.metastore.local</name>
- <value>true</value>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://localhost/hive?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>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://192.168.0.1:3306/hive?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.0.101:9083</value>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://192.168.1.214:3306/hive?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.0.101:9083</value>
- </property>
- $ hive --service metastore
客戶端使用hive命令即可
- [email protected]:~$ hive
- hive> show tables;
- OK
- Time taken: 0.7 seconds
- hive>