关于大数据:华能-Alluxio-数字化浪潮下跨地域数据联邦访问与分析

2次阅读

共计 10385 个字符,预计需要花费 26 分钟才能阅读完成。

1. 数字化转型与国产化过程推动

为了响应国家“十四五”数字经济倒退布局的号召,中国企业推动翻新资源共建共享,促成翻新模式凋谢化演进,在信息化、数字化、智能化的强烈需要下,中国龙头企业兼顾全渠道的技术能力,逐步造成了一套笼罩团体业务倒退、经营治理等外围倒退策略须要的策略方向。

数字化转型初见成效,数据能力一直开掘与翻新;大数据技术新陈代谢,国产化步调日益放慢。无论是互联网企业还是传统行业下的领导企业,有什么数据,如何应用数据,如何更加智能地利用数据这些议题被一直开掘与迭代。

在东数西算的理念下,数据跨平台、跨机房、跨地区的技术问题与挑战逐步浮现进去。这篇文章咱们次要从技术的角度,对跨地区的数据联邦,或者说总公司和分公司不同数据域的互联互通进行探讨,钻研相干技术可行性与分享整个钻研过程。为了放慢国产化软硬件的推动,本次实际采纳国产化硬件 ARM 服务器(鲲鹏 920)以及国产化操作系统统信进行相干的技术验证。

2. 原型指标与设计

通过对跨地区数据联邦的调研,咱们发现中国很多企业面临的业务挑战尽管不同,然而技术难点是类似的,次要有:

挑战一:总公司通过传统的 ETL 作业采集分公司数据(比方通过 Informatica、Kettle、DataX 等),这些作业往往是按需定制,并且定期执行的;当有新的数据合规要求或者总公司数据分析要求时,都须要进行定制开发、测试、部署,这对数据汇总的时效性带来了很大的负面影响。另外通过 ETL 作业采集的分公司数据,在遇到分公司数据更新时,非常容易造成总公司与分公司之间的数据不统一,导致剖析后果有所纰漏。

挑战二:子公司的自助式查问,一方面是对总公司的数据申请,很多时候整个数据拜访链路是断裂的,往往须要通过流程筛查、繁琐的数据同步伎俩进行(比方通过 FTP 传输,甚至是物理介质的长途运输)。思考到数据安全以及国家审计合规的要求,总公司数据是否能够在子公司长久化存储、数据拜访脱敏、权限管控等等也都是以后中国企业面临的具体技术挑战。

因而咱们本次的钻研次要会关注在数据流的双向流动方面。

2.1 钻研原型技术选型

以后大数据技术曾经成为企业外部典型的数据分析伎俩,因而在原型实现的过程中,咱们次要应用开源的大数据技术,从存储、计算(剖析)、编排 3 个维度进行选型。其中每个维度咱们抉择时下最支流的组件,以确保该原型的通用性。

数据存储:

√ HDFS:Hadoop 分布式文件系统(Distributed File System)

数据分析(以 SQL 剖析为主):

√ Hive:构建于 Hadoop 之上的数据仓库,通过一品种 SQL 语言 HiveQL 为用户提供数据的演绎、查问和剖析等性能。

数据编排:

√ lluxio:Alluxio 是一个开源的虚构分布式文件系统 (Virtual Distributed File System, VDFS),位于大数据栈中的计算和存储之间。它为计算框架提供了数据抽象层,使得利用可能通过一个独特的接口连贯底层不同的存储系统。

环境模拟:总公司 / 分公司 -1/ 分公司 -2

√ 每个公司有自建的 HDFS 集群;

√ 每个公司有自建的 Alluxio 集群:用于实现与本公司 HDFS 集群和其余公司 HDFS 集群的数据联邦;

√ 每个公司有自建的 Hive 集群。

备注:
CPU 型号: 鲲鹏 920
HDFS 3.1.1
Hive 3.1.0
Alluxio 2.8

2.2 数据流定义

应用 HDFS、Hive、Alluxio 定义数据长久化与数据拜访链路。在总公司和分公司构建对立的技术栈(技术标准),实现数据共享闭环:
1 在总公司数据域,实现分公司数据联邦,容许总公司实现全域数据拜访与剖析;

2 在分公司数据域,合规拜访总公司数据湖,并联合子公司公有数据进行自助化剖析;

3. Alluxio 在 ARM 环境下的根本测试

3.1 Alluxio 基于 ARM 编译

## 编译 
mvn -T2C -DskipTests -Dmaven.javadoc.skip -Dlicense.skip - 
Dcheckstyle.skip -Dfindbugs.skip clean install

3.2 Alluxio 基于 ARM 服务器的部署与根本测试

## 根本测试 
[root@node1 ~]# alluxio runTests

3.3 Alluxio 分布式高可用性验证(主动切换 + 手动切换)

## 治理命令获取元数据高可用信息
[root@node1 ~]# alluxio fsadmin journal quorum info -domain MASTER
Journal domain  : MASTER
Quorum size     : 3
Quorum leader   : node1:19200
 
STATE       | PRIORITY | SERVER ADDRESS
AVAILABLE   | 0        | node1:19200
AVAILABLE   | 0        | node2:19200
AVAILABLE   | 0        | node3:19200
 
## 敞开主治理节点
[root@node1 ~]# alluxio-stop.sh master
Successfully Killed 1 process(es) successfully on node1
 
## 治理命令获取元数据高可用信息,查看治理节点主动切换状态
[root@node1 ~]# alluxio fsadmin journal quorum info -domain MASTER
Journal domain  : MASTER
Quorum size     : 3
Quorum leader   : node2:19200
 
STATE       | PRIORITY | SERVER ADDRESS
UNAVAILABLE | 0        | node1:19200
AVAILABLE   | 0        | node2:19200
AVAILABLE   | 0        | node3:19200
[root@node1 ~]#
## 治理命令获取元数据高可用信息
[root@node1 ~]# alluxio fsadmin journal quorum info -domain MASTER
Journal domain  : MASTER
Quorum size     : 3
Quorum leader   : node2:19200
 
STATE       | PRIORITY | SERVER ADDRESS
AVAILABLE   | 0        | node1:19200
AVAILABLE   | 0        | node2:19200
AVAILABLE   | 0        | node3:19200
 
## 手动切换主节点
[root@node1 ~]# alluxio fsadmin journal quorum elect -address node3:19200
Initiating transfer of leadership to node3:19200
Successfully elected node3:19200 as the new leader
Resetting priorities of masters after successful transfer of leadership
Quorum priorities were reset to 1
 
## 治理命令获取元数据高可用信息,查看治理节点切换状态
[root@node1 ~]# alluxio fsadmin journal quorum info -domain MASTER
 
Journal domain  : MASTER
Quorum size     : 3
Quorum leader   : node3:19200
 
STATE       | PRIORITY | SERVER ADDRESS
AVAILABLE   | 1        | node1:19200
AVAILABLE   | 1        | node2:19200
AVAILABLE   | 1        | node3:19200
[root@node1 ~]#

3.4 Alluxio 与 HDFS 集成

## HDFS 数据查问
[root@node1 alluxio]# hdfs dfs -ls /test/
Found 1 items
-rw-r--r--   1 root hdfsadmingroup      53136 2022-07-22 16:57 /test/pom.xml
 
## Alluxio 数据挂载映射
[root@node1 alluxio]# alluxio fs mount /test/ hdfs://node1:9000/test
Mounted hdfs://node1:9000/test at /test
 
## Alluxio 数据查问
[root@node1 alluxio]# alluxio fs ls -R /test
-rw-r--r--  root           hdfsadmingroup           53136       PERSISTED 07-22-2022 16:57:23:651   0% /test/pom.xml
[root@node1 alluxio]#

3.5 Alluxio 与 Hive 集成

## 创立 Hive 表
hive> create table test.test(id int) location 'alluxio://node1:19998/test/test';
OK
Time taken: 0.116 seconds
hive>

3.6 Alluxio 基于 ACL 的权限管制

## 默认其余用户能够拜访,禁止其余用户能够拜访
[root@node1 ~]# alluxio fs setfacl -m user::--- /test
[root@node1 ~]# alluxio fs setfacl -m other::--- /test
 
## user1 用户拜访失败
user1@node1 ~]$ alluxio fs ls /test
Permission denied: user=user1, access=r--, path=/test: failed at test, inode owner=root, inode group=root, inode mode=---r-x—
[user1@node1 ~]$
 
## user1 用户受权,拜访胜利
root@node1 ~]# alluxio fs setfacl -m user:user1:rwx /test
[user1@node1 ~]$ alluxio fs ls /test
-rw-r--r--  root           root                      1726       PERSISTED 07-25-2022 14:50:51:180 100% /test/run-presto.pl
[user1@node1 ~]$
 
## user2 用户未受权拜访失败
[user2@node1 ~]$ alluxio fs ls /test
Permission denied: user=user2, access=r--, path=/test: failed at test, inode owner=root, inode group=root, inode mode=---r-x---
[user2@node1 ~]$
 
## 勾销受权 user1,拜访失败
root@node1 ~]# alluxio fs setfacl -b /test
[user1@node1 ~]$ alluxio fs ls /test
Permission denied: user=user1, access=r--, path=/test: failed at test, inode owner=root, inode group=root, inode mode=---r-x---
[user1@node1 ~]$
 
## 查看目录权限
[root@node1 ~]# alluxio fs getfacl /test
# file: /test
# owner: root
# group: root
user::---
group::r-x
other::---
mask::rwx
[root@node1 ~]#

4. 数据域联邦场景钻研

4.1 分公司数据汇总与总公司集中式剖析

数据流验证:在总公司数据域,实现分公司数据联邦,容许总公司实现全域数据拜访与剖析:

√ 构建总公司分公司模仿环境;

√ 总公司基于 Alluxio 创立数据表 T3,建设分区 x, y, z;

√ 分公司 - 1 将 HDFS 目录 X 映射到总公司 Alluxio 分区 x,筹备模仿数据;

√ 分公司 - 2 将 HDFS 目录 Y 映射到总公司 Alluxio 分区 y,筹备模仿数据;

√ 总公司应用 Hive 读取 T3 数据,验证:拜访分公司 - 1 与分公司 - 2 的所有数据失常;

√ 分公司 - 2 将目录 Y 的数据进行更新;

√ 告诉总公司数据表 T3 y 分区数据变更(元数据生效);

√ 总公司应用 Hive 读取 T3 数据,验证:拜访分公司 - 1 与分公司 -2(更新后)的所有数据失常。

## 总公司创立 t3 表
hive> create external table group_company.t3(value string)
    > partitioned by (part string)
    > location 'alluxio://node1:19998/group_company/t3';
OK
Time taken: 0.069 seconds
hive>
## 分公司 1 分区 x 挂载到总公司 alluxio
[root@node1 ~]# hdfs dfs -put part\=x/ hdfs://node3:9000/regional_company_1/t3
[root@node1 ~]# hdfs dfs -put part\=y/ hdfs://node5:9000/regional_company_2/t3
[root@node1 ~]#
 
[root@node1 ~]# alluxio fs mount \
> /group_company/t3/part=x \
> hdfs://node3:9000/regional_company_1/t3/part=x
Mounted hdfs://node3:9000/regional_company_1/t3/part=x at /group_company/t3/part=x
[root@node1 ~]#
 
## 查问数据
hive> MSCK REPAIR TABLE group_company.t3;
OK
Partitions not in metastore:    t3:part=x
Repair: Added partition to metastore t3:part=x
Time taken: 0.169 seconds, Fetched: 2 row(s)
hive> select * from  group_company.t3;
OK
1abc    x
Time taken: 0.108 seconds, Fetched: 1 row(s)
hive>
 
## 分公司 2 分区 y 挂载到总公司 alluxio
[root@node1 ~]# alluxio fs mount \
> /group_company/t3/part=y \
> hdfs://node5:9000/regional_company_2/t3/part=y
Mounted hdfs://node5:9000/regional_company_2/t3/part=y at /group_company/t3/part=y
[root@node1 ~]#
 
## 查问数据
hive> MSCK REPAIR TABLE group_company.t3;
OK
Partitions not in metastore:    t3:part=y
Repair: Added partition to metastore t3:part=y
Time taken: 0.153 seconds, Fetched: 2 row(s)
hive> select * from  group_company.t3;
OK
1abc    x
2def    y
Time taken: 0.137 seconds, Fetched: 2 row(s)
hive>
 
## 更新分区 y 数据
[root@node1 ~]# hdfs dfs -cat hdfs://node5:9000/regional_company_2/t3/part=y/000000_0
2def
[root@node1 ~]# hdfs dfs -get hdfs://node5:9000/regional_company_2/t3/part=y/000000_0
[root@node1 ~]# echo '1111' > 000000_0
[root@node1 ~]# hdfs dfs -rm hdfs://node5:9000/regional_company_2/t3/part=y/000000_0
Deleted hdfs://node5:9000/regional_company_2/t3/part=y/000000_0
[root@node1 ~]# hdfs dfs -put 000000_0 hdfs://node5:9000/regional_company_2/t3/part=y/
[root@node1 ~]# hdfs dfs -cat hdfs://node5:9000/regional_company_2/t3/part=y/000000_0
1111
[root@node1 ~]#
 
## 更新查问数据
hive> select * from  group_company.t3;
OK
1abc    x
2def    y
Time taken: 0.112 seconds, Fetched: 2 row(s)
hive>
 
## 告诉总公司更新数据
[root@node1 ~]# alluxio fs loadMetadata -F /group_company/t3
[root@node1 ~]#
 
## 总更新数据后查问
hive> select * from  group_company.t3;
OK
1abc    x
1111    y
Time taken: 0.1 seconds, Fetched: 2 row(s)
hive>

4.2 总公司数据散发与分公司自助剖析

数据流验证:在分公司数据域,合规拜访总公司数据湖,并联合公有数据进行自助化剖析:

√ 构建总公司分公司模仿环境;

√ 总公司基于 HDFS 创立数据表 T1,建设分区 a, b, c;

√ 分公司 - 1 基于 Alluxio 应用数据表 T1 元数据创立相应表格 T1’;

√ 总公司挂载分区 a 到分公司 - 1 的 Alluxio 相干目录;

√ 分公司 - 1 的 Hive, 拜访 T1’,验证:拜访分区 a 的数据失常;

√ 总公司挂载分区 c 到分公司 - 1 的 Alluxio 相干目录;

√ 通过分公司 - 1 的 Hive, 拜访 T1’,验证:拜访分区 a / c 的数据失常;

√ 总公司将挂载的分区 c 从分公司 1 撤回;

√ 通过分公司 - 1 的 Hive, 拜访 T1’,验证:仅能失常拜访分区 a 的数据;

√ 分公司创立数据表 T2,实现数据表之间的 join 类型 SQL,验证:总公司数据与分公司自有数据联邦拜访失常。

## 总公司创立 t1 表 三个分区 a b c
hive> create database group_company location '/user/hive/group_company.db';
OK
Time taken: 0.017 seconds
hive> create external table group_company.t1(value string) partitioned by (part string);
OK
Time taken: 0.144 seconds
 
hive> insert into table group_company.t1 partition(part='a') values('1abc');
hive> insert into table group_company.t1 partition(part='b') values('2def');
hive> insert into table group_company.t1 partition(part='c') values('3ghi');
 
hive> select * from group_company.t1;
OK
1abc    a
2def    b
3ghi    c
Time taken: 0.142 seconds, Fetched: 3 row(s)
 
## 分公司 1 挂载总表分区 a
[root@node3 alluxio]# bin/alluxio fs mkdir /regional_company_1/t1/
Successfully created directory /regional_company_1/t1
[root@node3 alluxio]#
 
[root@node3 alluxio]# bin/alluxio fs mount \
> /regional_company_1/t1/part=a \
> hdfs://node1:9000/user/hive/group_company.db/t1/part=a
Mounted hdfs://node1:9000/user/hive/group_company.db/t1/part=a at /regional_company_1/t1/part=a
[root@node3 alluxio]#
 
## 创立表查问数据
hive> create external table t1(value string)
    > partitioned by (part string)
    > location 'alluxio://node3:19998/regional_company_1/t1';
OK
Time taken: 0.972 seconds
hive> select * from t1;
OK
Time taken: 1.282 seconds
hive> MSCK REPAIR TABLE t1;
OK
Partitions not in metastore:    t1:part=a
Repair: Added partition to metastore t1:part=a
Time taken: 0.235 seconds, Fetched: 2 row(s)
hive> select * from t1;
OK
1abc    a
Time taken: 0.137 seconds, Fetched: 1 row(s)
hive>
 
## 分公司 1 挂载总表分区 c
[root@node3 alluxio]# bin/alluxio fs mount \
> /regional_company_1/t1/part=c \
> hdfs://node1:9000/user/hive/group_company.db/t1/part=c
Mounted hdfs://node1:9000/user/hive/group_company.db/t1/part=c at /regional_company_1/t1/part=c
[root@node3 alluxio]#
 
## 查问数据
hive> MSCK REPAIR TABLE t1;
OK
Partitions not in metastore:    t1:part=c
Repair: Added partition to metastore t1:part=c
Time taken: 0.244 seconds, Fetched: 2 row(s)
hive> select * from t1;
OK
1abc    a
3ghi    c
Time taken: 0.145 seconds, Fetched: 2 row(s)
hive>
 
## 撤回
[root@node3 alluxio]# bin/alluxio fs unmount /regional_company_1/t1/part=c
Unmounted /regional_company_1/t1/part=c
[root@node3 alluxio]#
 
hive> select * from t1;
OK
1abc    a
Time taken: 2.281 seconds, Fetched: 1 row(s)
hive>
 
## join t2 表
hive> select * from t2;
OK
5678    a
1234    d
Time taken: 0.082 seconds, Fetched: 2 row(s)
hive>
 
hive> select * from (
    > select * from t1
    > ) t1
    > join (
    > select * from t2
    > ) t2
    > on t1.part = t2.part;
Query ID = root_20220720135305_c5730dc3-a46a-478a-a368-2e0343385700
Total jobs = 1
Hadoop job information for Stage-3: number of mappers: 1; number of reducers: 0
2022-07-20 13:53:26,621 Stage-3 map = 0%,  reduce = 0%
2022-07-20 13:53:31,775 Stage-3 map = 100%,  reduce = 0%, Cumulative CPU 2.42 sec
MapReduce Total cumulative CPU time: 2 seconds 420 msec
Ended Job = job_1658118353477_0009
MapReduce Jobs Launched:
Stage-Stage-3: Map: 1   Cumulative CPU: 2.42 sec   HDFS Read: 8876 HDFS Write: 113 SUCCESS
Total MapReduce CPU Time Spent: 2 seconds 420 msec
OK
1abc    a       5678    a
Time taken: 27.333 seconds, Fetched: 1 row(s)
hive>

5. 总结

通过本次钻研发现:

1 咱们在国产化软硬件环境中(ARM+ 统信)对以后支流组件实现了适配和根本验证,Hive+Alluxio+HDFS 的技术栈能够在国产化环境下失常运行;
2 通过 Alluxio 数据编排实现跨地区的数据联邦,实现总公司与分公司之间不同物理数据域的互联互通,提供企业外部残缺的数据链路;
3 通过 Alluxio 本身的 ACL 管制,以及 Alluxio 与底层 UFS(本次验证是 HDFS)的挂载设定进行数据逻辑映射的管制;

在技术可行性方面的验证,也为咱们日后的原型优化提供了更多的思路:

1 思考新的数据合规要求,设定 Alluxio 中数据的 TTL 控制数据拜访生命周期;
2 数据更新的机制,无论是利用 UFS 本身的变更告诉还是外围的音讯机制,更好地保障企业外部跨数据域的数据拜访一致性;
3 更加细粒度的数据访问控制,通过更多的数据语义了解,进步对数据管理的灵便度;

想要获取更多乏味有料的【流动信息】【技术文章】【大咖观点】,请关注 [Alluxio 智库]

正文完
 0