Hadoop基础教程-第12章 Hive:进阶(12.4 Hive Metastore)(草稿)

第12章 Hive:进阶

12.4 Hive Metastore


12.4.1 三种配置方式

Hive Metastore有三种配置方式,分别是:

Embedded Metastore Database (Derby) 内嵌模式 
Local Metastore Server 本地元存储 
Remote Metastore Server 远程元存储

12.4.2 Metastore作用

metadata即元数据。元数据包含用Hive创建的database、tabel等的元信息。 
元数据存储在关系型数据库中。如Derby、MySQL等。

Metastore的作用是:客户端连接metastore服务,metastore再去连接MySQL数据库来存取元数据。有了metastore服务,就可以有多个客户端同时连接,而且这些客户端不需要知道MySQL数据库的用户名和密码,只需要连接metastore 服务即可。

本地元存储和远程元存储的区别是:本地元存储不需要单独起metastore服务,用的是跟hive在同一个进程里的metastore服务。远程元存储需要单独起metastore服务,然后每个客户端都在配置文件里配置连接到该metastore服务。远程元存储的metastore服务和hive运行在不同的进程里。

在生产环境中,建议用远程元存储来配置Hive Metastore。

12.4.3 Hive服务规划

节点 ip MySQL HiveServer2 Metastore Hive
node1 192.168.80.131   Y   Y
node2 192.168.80.132     Y Y
node3 192.168.80.133 Y      

12.4.4 beenline

HiveServer2提供了一个新的命令行工具Beeline,它是基于SQLLine CLI的JDBC客户端。

Beeline工作模式有两种,即本地嵌入模式和远程模式。嵌入模式情况下,它返回一个嵌入式的Hive(类似于hive CLI)。而远程模式则是通过Thrift协议与某个单独的HiveServer2进程进行连接通信。

(1)本地模式

[root@node1 ~]# /usr/lib/hive/bin/beeline 
Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000/default
Connecting to jdbc:hive2://localhost:10000/default
Enter username for jdbc:hive2://localhost:10000/default: root
Enter password for jdbc:hive2://localhost:10000/default: ******
Connected to: Apache Hive (version 1.2.1000.2.4.3.0-227)
Driver: Hive JDBC (version 1.2.1000.2.4.3.0-227)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000/default> show tables;
+-----------+--+
| tab_name  |
+-----------+--+
| goods     |
+-----------+--+
1 row selected (0.236 seconds)
0: jdbc:hive2://localhost:10000/default> select * from goods;
+-----------+-------------+--+
| goods.id  | goods.name  |
+-----------+-------------+--+
| 1         | Java        |
| 2         | Java EE     |
| 3         | Android     |
| 4         | Hadoop      |
| 5         | Zookeeper   |
| 6         | Hive        |
| 7         | HBase       |
| 8         | Spark       |
+-----------+-------------+--+
8 rows selected (0.314 seconds)
0: jdbc:hive2://localhost:10000/default>

默认用户名、密码不验证,可以随便输入。

(2)远程模式

[root@node2 ~]#/usr/lib/hive/bin# ./beeline
Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive
beeline> !connect jdbc:hive2://192.168.1.158:10000/default
Connecting to jdbc:hive2://192.168.1.158:10000/default
Enter username for jdbc:hive2://192.168.1.158:10000/default: root
Enter password for jdbc:hive2://192.168.1.158:10000/default: ******
Connected to: Apache Hive (version 1.2.1000.2.4.3.0-227)
Driver: Hive JDBC (version 1.2.1000.2.4.3.0-227)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://192.168.1.158:10000/default> show tables;
+-----------+--+
| tab_name  |
+-----------+--+
| goods     |
+-----------+--+
1 row selected (0.265 seconds)
0: jdbc:hive2://192.168.1.158:10000/default> select * from goods;
+-----------+-------------+--+
| goods.id  | goods.name  |
+-----------+-------------+--+
| 1         | Java        |
| 2         | Java EE     |
| 3         | Android     |
| 4         | Hadoop      |
| 5         | Zookeeper   |
| 6         | Hive        |
| 7         | HBase       |
| 8         | Spark       |
+-----------+-------------+--+
8 rows selected (0.53 seconds)
0: jdbc:hive2://192.168.1.158:10000/default> root@tdh02:/usr/lib/hive/bin# ./beeline
Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive
beeline>
灰常灰常感谢原博主的辛苦工作,为防止删博,所以转载,只供学习使用,不做其他任何商业用途。 https://blog.csdn.net/chengyuqiang/article/details/77619033

第12章 Hive:进阶

12.4 Hive Metastore


12.4.1 三种配置方式

Hive Metastore有三种配置方式,分别是:

Embedded Metastore Database (Derby) 内嵌模式 
Local Metastore Server 本地元存储 
Remote Metastore Server 远程元存储

12.4.2 Metastore作用

metadata即元数据。元数据包含用Hive创建的database、tabel等的元信息。 
元数据存储在关系型数据库中。如Derby、MySQL等。

Metastore的作用是:客户端连接metastore服务,metastore再去连接MySQL数据库来存取元数据。有了metastore服务,就可以有多个客户端同时连接,而且这些客户端不需要知道MySQL数据库的用户名和密码,只需要连接metastore 服务即可。

本地元存储和远程元存储的区别是:本地元存储不需要单独起metastore服务,用的是跟hive在同一个进程里的metastore服务。远程元存储需要单独起metastore服务,然后每个客户端都在配置文件里配置连接到该metastore服务。远程元存储的metastore服务和hive运行在不同的进程里。

在生产环境中,建议用远程元存储来配置Hive Metastore。

12.4.3 Hive服务规划

节点 ip MySQL HiveServer2 Metastore Hive
node1 192.168.80.131   Y   Y
node2 192.168.80.132     Y Y
node3 192.168.80.133 Y      

12.4.4 beenline

HiveServer2提供了一个新的命令行工具Beeline,它是基于SQLLine CLI的JDBC客户端。

Beeline工作模式有两种,即本地嵌入模式和远程模式。嵌入模式情况下,它返回一个嵌入式的Hive(类似于hive CLI)。而远程模式则是通过Thrift协议与某个单独的HiveServer2进程进行连接通信。

(1)本地模式

[root@node1 ~]# /usr/lib/hive/bin/beeline 
Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000/default
Connecting to jdbc:hive2://localhost:10000/default
Enter username for jdbc:hive2://localhost:10000/default: root
Enter password for jdbc:hive2://localhost:10000/default: ******
Connected to: Apache Hive (version 1.2.1000.2.4.3.0-227)
Driver: Hive JDBC (version 1.2.1000.2.4.3.0-227)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000/default> show tables;
+-----------+--+
| tab_name  |
+-----------+--+
| goods     |
+-----------+--+
1 row selected (0.236 seconds)
0: jdbc:hive2://localhost:10000/default> select * from goods;
+-----------+-------------+--+
| goods.id  | goods.name  |
+-----------+-------------+--+
| 1         | Java        |
| 2         | Java EE     |
| 3         | Android     |
| 4         | Hadoop      |
| 5         | Zookeeper   |
| 6         | Hive        |
| 7         | HBase       |
| 8         | Spark       |
+-----------+-------------+--+
8 rows selected (0.314 seconds)
0: jdbc:hive2://localhost:10000/default>

默认用户名、密码不验证,可以随便输入。

(2)远程模式

[root@node2 ~]#/usr/lib/hive/bin# ./beeline
Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive
beeline> !connect jdbc:hive2://192.168.1.158:10000/default
Connecting to jdbc:hive2://192.168.1.158:10000/default
Enter username for jdbc:hive2://192.168.1.158:10000/default: root
Enter password for jdbc:hive2://192.168.1.158:10000/default: ******
Connected to: Apache Hive (version 1.2.1000.2.4.3.0-227)
Driver: Hive JDBC (version 1.2.1000.2.4.3.0-227)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://192.168.1.158:10000/default> show tables;
+-----------+--+
| tab_name  |
+-----------+--+
| goods     |
+-----------+--+
1 row selected (0.265 seconds)
0: jdbc:hive2://192.168.1.158:10000/default> select * from goods;
+-----------+-------------+--+
| goods.id  | goods.name  |
+-----------+-------------+--+
| 1         | Java        |
| 2         | Java EE     |
| 3         | Android     |
| 4         | Hadoop      |
| 5         | Zookeeper   |
| 6         | Hive        |
| 7         | HBase       |
| 8         | Spark       |
+-----------+-------------+--+
8 rows selected (0.53 seconds)
0: jdbc:hive2://192.168.1.158:10000/default> root@tdh02:/usr/lib/hive/bin# ./beeline
Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive
beeline>

猜你喜欢

转载自blog.csdn.net/airufengye/article/details/81065811