构建现代数据仓库:从Hive到Presto及ETL实践
立即解锁
发布时间: 2025-08-30 00:12:52 阅读量: 6 订阅数: 18 AIGC 

# 构建现代数据仓库:从 Hive 到 Presto 及 ETL 实践
## 1. 创建模式与测试 Apache Hive
要测试自定义 Apache Hive 部署,可在运行的 Pod 中执行 Hive 命令行界面。操作步骤如下:
1. 在 MinIO 中创建名为 `hive` 的存储桶。
2. 获取自定义 Apache Hive Pod 名称:
```bash
$ kubectl get pods -l app=hive -n data
```
3. 执行 Hive 命令:
```bash
$ kubectl exec -it hive-8546649b5b-lbcrn \
/opt/hive/bin/hive -n data
```
4. 在运行的 Hive 命令中,创建名为 `exports` 的数据库:
```sql
hive> CREATE DATABASE exports;
```
5. 创建 `exports.donors` 表:
```sql
hive> CREATE TABLE exports.donors (
> email string,
> name string,
> blood_type string,
> birthday date,
> state string
> )
> row format delimited fields terminated by ','
> lines terminated by "\n"
> location 's3a://exports/donors';
```
此过程使用自定义 Apache Hive 容器将模式投影到分布式对象存储上。虽然单个 Hive 容器可通过 `hive:1000` Kubernetes 服务暴露的 ODBC/thrift 执行查询,但对于直接针对 Hive 执行生产工作负载,更广泛的 Hive 集群是必要的。
## 2. Presto 简介
Presto 是现代数据仓库的重要组件,是一个开源的分布式 SQL 查询引擎,可对从千兆字节到 PB 级的各种大小的数据源运行交互式分析查询。与 Hive 相比,Presto 能连接更广泛的数据源,包括 Apache Hive。它具有以下优势:
- 高性能查询能力。
- 提供数据源的中央目录。
- 减少从多个源检索数据所需的应用逻辑。
- 支持多种客户端库,如 Go、C、Java、Node.js、PHP、Ruby、R 和 Python。
- 有许多基于 Web 的 GUI 客户端、可视化和仪表板应用程序支持,如 Apache Superset。
## 3. Presto 在 Kubernetes 中的配置
### 3.1 创建目录和文件
创建目录 `cluster-apk8s-dev5/003-data/095-presto` 来包含 Presto Helm 配置和文档。创建 `values.yml` 文件,内容如下:
```yaml
presto:
environment: "production"
workers: 2
logLevel: "INFO"
image:
repository: "wiwdata/presto"
tag: "0.217"
pullPolicy: "IfNotPresent"
service:
type: ClusterIP
catalog:
obj.properties: |
connector.name=hive-hadoop2
hive.metastore=file
hive.metastore.catalog.dir=s3://metastore/
hive.allow-drop-table=true
hive.s3.aws-access-key= miniobucketuserid
hive.s3.aws-secret-key= miniobucketuserpassword
hive.s3.endpoint=http://minio:9000
hive.s3.path-style-access=true
hive.s3.ssl.enabled=false
hive.s3select-pushdown.enabled=true
hive.properties: |
connector.name=hive-hadoop2
hive.metastore.uri=thrift://hive:9083
hive.allow-drop-table=true
hive.s3.aws-access-key= miniobucketuserid
hive.s3.aws-secret-key= miniobucketuserpassword
hive.s3.endpoint=http://minio:9000
hive.s3.path-style-access=true
hive.s3.ssl.enabled=false
cassandra.properties: |
connector.name=cassandra
cassandra.contact-points=cassandra-data-r1-0,cassandra-data-r1-1,cassandra-data-r1-2
mysql.properties: |
connector.name=mysql
connection-url=jdbc:mysql://mysql:3306
connection-user= root
connection-password= mysqlrootpassword
coordinatorConfigs: {}
workerConfigs: {}
environmentVariables: {}
coordinatorResources: {}
workerResources: {}
coordinatorNodeSelector: {}
workerNodeSelector: {}
coordinatorTolerations: []
workerTolerations: []
coordinatorAffinity: {}
workerAffinity: {}
```
同时创建 `README.md` 文件来记录后续执行的 Helm 命令。
### 3.2 克隆 Helm 图表仓库
```bash
$ git clone [email protected]:apk8s/presto-chart.git
```
### 3.3 创建 Presto 集群
```bash
$ helm upgrade --install presto-data \
--namespace data \
--values values.yml \
./presto-chart/presto
```
安装完成后,Kubernetes 集群将包含两个 Presto 工作节点和一个 Presto 协调器。
### 3.4 添加 Ingress 配置
创建 `50-ingress.yml` 文件,内容如下:
```yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: presto
namespace: da
```
0
0
复制全文
相关推荐










