附录
背景信息
使用云盘组件RAID磁盘阵列
RAID级别 |
简介 |
读写性能 |
安全性能 |
磁盘使用率 |
组建不同RAID阵列所需的最少磁盘数量 |
---|---|---|---|---|---|
RAID0 |
RAID0将数据分条存储在多个磁盘上,可实现并行读写,提供最快的读写速率。 |
多个磁盘并行读写获取更高性能 |
最差 没有冗余能力,一个磁盘损坏,整个RAID阵列数据都不可用 |
100% |
两块 |
RAID1 |
通过构造数据镜像实现数据冗余,阵列中一半的磁盘容量投入使用,另一半磁盘容量用来做镜像,提供数据备份。 |
读性能:与单个磁盘相同 写性能:需要将数据写入是两个磁盘,写性能低于单个磁盘 |
最高 提供磁盘数据的完整备份,当阵列中的一个磁盘失效时,系统可以自动采用镜像磁盘的数据 |
50% |
两块 |
RAID01 |
结合RAID0和RAID1两种磁盘阵列,先将一半磁盘组建成RAID0分条存储数据,再用另一半磁盘做RAID1镜像。 |
读性能:和RAID0相同 写性能:和RAID1相同 |
比RAID10的安全性能低 |
50% |
四块 |
RAID10 |
结合RAID1和RAID0两种磁盘阵列,先将磁盘两两组建成RAID1镜像,再组建RAID0将数据分条存储。 |
读性能:RAID0相同 写性能:RAID1相同 |
和RAID1的安全性能相同 |
50% |
四块 |
RAID5 |
RAID5不需要单独指定数据校验磁盘,而是将每块磁盘生成的校验信息分块存储至阵列中的每块磁盘中。 |
读性能:和RAID0相同 写性能:由于要写入奇偶校验信息,写性能低于单个磁盘 |
比RAID10的安全性能低 |
66.7% |
三块 |
源代码
样例1:DLI Flink SQL脚本
CREATE SOURCE STREAM alarm_info (alarm_id STRING, alarm_type INT) WITH ( type = "dis", region = "cn-east-3", channel = "dis-alarm-input", partition_count = "1", encode = "csv", offset = "0", field_delimiter = "," ); CREATE SINK STREAM over_alarm ( alarm_over STRING /* over speed message */ ) WITH ( type = "smn", region = "cn-east-3", topic_urn = " urn:smn:cn-east-3:0b9553e29c0026f22f3dc007a430e45a:alarm_over ", message_subject = "alarm", message_column = "alarm_over" ); INSERT INTO over_alarm SELECT "your alarm over (" || CAST(alarm_type as CHAR(20)) || ") ." FROM alarm_info WHERE alarm_type > 8; CREATE SINK STREAM alarm_info_output (alarm_id STRING, alarm_type INT) WITH ( type = "dis", region = "cn-east-3", channel = "dis-alarm-output", PARTITION_KEY = "alarm_type", encode = "csv", field_delimiter = "," ); INSERT INTO alarm_info_output SELECT * FROM alarm_info WHERE alarm_type > 0; 附:测试源数据示例 alarm_id alarm_type 60114 3 60121 5 60122 6 60123 7 60124 8 60126 0 60127 9 60128 10 60129 6
样例2:创建数据表alarm_info,alarm_count_info
create table alarm_info( alarm_time string, alarm_id string, alarm_type int ) using csv options(path 's3a://obs-alarm-platform/alarm_info') partitioned by(alarm_time); create table alarm_count_info( alarm_time string, alarm_type int, alarm_count int ) using csv options(path 's3a://obs-alarm-platform/alarm_count_info');
样例3:按告警类别进行统计
insert into alarm_count_info select alarm_time, alarm_type, count(alarm_type) from alarm_info group by alarm_time, alarm_type;