概述
對(duì)于任何一種數(shù)據(jù)庫類軟件來說,無論其基于傳統(tǒng)數(shù)據(jù)庫模型還是基于分布式結(jié)構(gòu),作為核心的永遠(yuǎn)是數(shù)據(jù)本身。而數(shù)據(jù)的生命周期,則體現(xiàn)在CRUD操作(創(chuàng)建、查詢、更新、刪除)上。任何一條數(shù)據(jù)從其生成的時(shí)刻開始,數(shù)據(jù)價(jià)值隨著時(shí)間的推移而逐漸降低,直至成為無用數(shù)據(jù),最終刪除。
作為使用數(shù)據(jù)的主體用戶,對(duì)于各種數(shù)據(jù)的需求程度是不同的,人們往往對(duì)重要的數(shù)據(jù)有更高效、穩(wěn)定的訪問需求;而對(duì)于不重要的數(shù)據(jù)則沒有這么高的要求,而前者存儲(chǔ)的代價(jià)往往是遠(yuǎn)高于后者的。用戶在滿足了自身對(duì)于數(shù)據(jù)使用要求的情況下,自然會(huì)開始考慮數(shù)據(jù)存儲(chǔ)成本等方面的問題,對(duì)于那些很少訪問甚至基本不訪問的數(shù)據(jù),使用成本更低的存儲(chǔ)方式將是一種更好的選擇。
針對(duì)這樣的使用場景,我們將數(shù)據(jù)根據(jù)用戶需求分為“熱數(shù)據(jù)”與“冷數(shù)據(jù)”。顧名思義,“熱數(shù)據(jù)”代表著用戶對(duì)其有著更頻繁的訪問需求,“冷數(shù)據(jù)”則很少訪問。一般數(shù)據(jù)在新創(chuàng)建的時(shí)候往往都是“熱數(shù)據(jù)”,而隨著時(shí)間的推移逐步變成“冷數(shù)據(jù)”。
對(duì)于熱數(shù)據(jù),其訪問的頻率很高,且往往是用戶非常關(guān)心的數(shù)據(jù),其實(shí)時(shí)性要求一般都很高,并且讀寫的頻率也會(huì)更高,這正是DORIS本地存儲(chǔ)重點(diǎn)解決的問題。
對(duì)于冷數(shù)據(jù),其數(shù)據(jù)量往往遠(yuǎn)大于熱數(shù)據(jù),并且很少被訪問,使用本地存儲(chǔ)的代價(jià)就很高,這時(shí)使用存算分離模型,將其存儲(chǔ)到代價(jià)更低的存儲(chǔ)載體將大大降低成本。
未來一個(gè)很大的使用場景是類似于es日志存儲(chǔ),日志場景下數(shù)據(jù)會(huì)按照日期來切割數(shù)據(jù),很多數(shù)據(jù)是冷數(shù)據(jù),查詢很少,需要降低這類數(shù)據(jù)的存儲(chǔ)成本。從節(jié)約存儲(chǔ)成本角度考慮
- 各云廠商普通云盤的價(jià)格都比對(duì)象存儲(chǔ)貴
- 在doris集群實(shí)際線上使用中,普通云盤的利用率無法達(dá)到100%
- 云盤不是按需付費(fèi),而對(duì)象存儲(chǔ)可以做到按需付費(fèi)
- 基于普通云盤做高可用,需要實(shí)現(xiàn)多副本,某副本異常要做副本遷移。而將數(shù)據(jù)放到對(duì)象存儲(chǔ)上則不存在此類問題,因?yàn)閷?duì)象存儲(chǔ)是共享的。
使用體驗(yàn)
下面我們 Minio 為例來演示怎么使用 Doris 基于對(duì)象存儲(chǔ)的冷熱分離功能。
我是在 MacOS 上來進(jìn)行安裝演示的
MacOS Doris 的編譯安裝
編譯具體可以參照官方文檔:在macOS平臺(tái)上編譯 - Apache Doris
本地安裝單節(jié)點(diǎn):快速開始 - Apache Doris
如果你是 Linux 系統(tǒng),可以下載官方編譯好的2.0.0 alpha 版本進(jìn)行快速體驗(yàn):下載 - Apache Doris
curl https://doris.apache.org/download-scripts/2.0.0-alpha1/download_x64_tsinghua.sh | sh
Minio 安裝
本文是brew方式,Mac需安裝brew支持,本文不再贅述, Linux 系統(tǒng)下的 Minio 網(wǎng)上很多教程,請自行百度
brew install minio/stable/minio
然后可以看到安裝成功的信息
Command-line Access: https://docs.min.io/docs/minio-client-quickstart-guide
?
Object API (Amazon S3 compatible):
Go: https://docs.min.io/docs/golang-client-quickstart-guide
Java: https://docs.min.io/docs/java-client-quickstart-guide
Python: https://docs.min.io/docs/python-client-quickstart-guide
JavaScript: https://docs.min.io/docs/javascript-client-quickstart-guide
.NET: https://docs.min.io/docs/dotnet-client-quickstart-guide
?
Talk to the community: https://slack.min.io
==> Get started:
NAME:
minio server - start object storage server
?
USAGE:
minio server [FLAGS] DIR1 [DIR2..]
minio server [FLAGS] DIR{1...64}
minio server [FLAGS] DIR{1...64} DIR{65...128}
?
DIR:
DIR points to a directory on a filesystem. When you want to combine
multiple drives into a single large system, pass one directory per
filesystem separated by space. You may also use a '...' convention
to abbreviate the directory arguments. Remote directories in a
distributed setup are encoded as HTTP(s) URIs.
?
FLAGS:
--address value bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname (default: ":9000") [$MINIO_ADDRESS]
--console-address value bind to a specific ADDRESS:PORT for embedded Console UI, ADDRESS can be an IP or hostname [$MINIO_CONSOLE_ADDRESS]
--ftp value enable and configure an FTP(Secure) server
--sftp value enable and configure an SFTP server
--certs-dir value, -S value path to certs directory (default: "/Users/zhangfeng/.minio/certs")
--quiet disable startup and info messages
--anonymous hide sensitive information from logging
--json output logs in JSON format
--help, -h show help
?
EXAMPLES:
1. Start MinIO server on "/home/shared" directory.
$ minio server /home/shared
?
2. Start single node server with 64 local drives "/mnt/data1" to "/mnt/data64".
$ minio server /mnt/data{1...64}
?
3. Start distributed MinIO server on an 32 node setup with 32 drives each, run following command on all the nodes
$ minio server http://node{1...32}.example.com/mnt/export{1...32}
?
4. Start distributed MinIO server in an expanded setup, run the following command on all the nodes
$ minio server http://node{1...16}.example.com/mnt/export{1...32} \
http://node{17...64}.example.com/mnt/export{1...64}
?
5. Start distributed MinIO server, with FTP and SFTP servers on all interfaces via port 8021, 8022 respectively
$ minio server http://node{1...4}.example.com/mnt/export{1...4} \
--ftp="address=:8021" --ftp="passive-port-range=30000-40000" \
--sftp="address=:8022" --sftp="ssh-private-key=${HOME}/.ssh/id_rsa"
/opt/homebrew/Cellar/minio/RELEASE.2023-05-04T21-44-30Z_1: 3 files, 100.9MB, built in 3 seconds
==> Running `brew cleanup minio`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
啟動(dòng)服務(wù)
設(shè)置 MINIO_REGION 、MINIO_ACCESS_KEY 、MINIO_SECRET_KEY
export MINIO_REGION=xian
export MINIO_ACCESS_KEY=minioadmin
export MINIO_SECRET_KEY=minioadmin
將 minio 服務(wù)放到后臺(tái)運(yùn)行
nohup minio server /Users/zhangfeng/minio_data > /Users/zhangfeng/minio_data/log/minio.log 2>&1 &
然后可以看見登錄界面:
登錄進(jìn)去創(chuàng)建 bucket 下面我們就可以進(jìn)行Doris的冷熱分離操作了
Doris 冷熱分離體驗(yàn)
首先我們在 fe/fe.conf 里打開冷熱分離這個(gè)功能,因?yàn)樾碌墓δ茉诘谝粋€(gè)版本默認(rèn)是關(guān)閉的,所以我們要手動(dòng)打開,添加下面的內(nèi)容
enable_storage_policy=true
然后重啟 FE。
首先我們創(chuàng)建一個(gè) Resource
創(chuàng)建S3 RESOURCE的時(shí)候,會(huì)進(jìn)行S3遠(yuǎn)端的鏈接校驗(yàn),以保證RESOURCE創(chuàng)建的正確
CREATE RESOURCE "remote_s3"
PROPERTIES
(
"type" = "s3",
"AWS_ENDPOINT" = "localhost:9000",
"AWS_REGION" = "xian",
"AWS_BUCKET" = "test",
"AWS_ROOT_PATH" = "/test/test001",
"AWS_ACCESS_KEY" = "minioadmin",
"AWS_SECRET_KEY" = "minioadmin",
"AWS_MAX_CONNECTIONS" = "50",
"AWS_REQUEST_TIMEOUT_MS" = "3000",
"AWS_CONNECTION_TIMEOUT_MS" = "1000"
);
然后我們創(chuàng)建數(shù)據(jù)遷移策略(STORAGE POLICY),用于冷熱數(shù)據(jù)轉(zhuǎn)換
CREATE STORAGE POLICY test_policy
PROPERTIES(
"storage_resource" = "remote_s3",
"cooldown_ttl" = "1h"
);
- cooldown_datetime:熱數(shù)據(jù)轉(zhuǎn)為冷數(shù)據(jù)時(shí)間,不能與cooldown_ttl同時(shí)存在。
- cooldown_ttl:熱數(shù)據(jù)持續(xù)時(shí)間。從數(shù)據(jù)分片生成時(shí)開始計(jì)算,經(jīng)過指定時(shí)間后轉(zhuǎn)為冷數(shù)據(jù)。支持的格式: 1d:1天 1h:1小時(shí) 50000: 50000秒
我們后面也可以根據(jù)自己的策略來修改這個(gè) ttl 時(shí)間,修改命令示例:
ALTER STORAGE POLICY test_policy PROPERTIES("cooldown_ttl" = "5h");
我們創(chuàng)建一張表,并將這個(gè)數(shù)據(jù)遷移策略應(yīng)用到這個(gè)表上
CREATE TABLE IF NOT EXISTS create_table_use_created_policy
(
k1 BIGINT,
k2 LARGEINT,
v1 VARCHAR(2048)
)
UNIQUE KEY(k1)
DISTRIBUTED BY HASH (k1) BUCKETS 1
PROPERTIES(
"storage_policy" = "test_policy",
"replication_num" = "1"
);
我們插入幾條數(shù)據(jù):
insert into create_table_use_created_policy values (10001,100001,'11');
insert into create_table_use_created_policy values (10002,100001,'11');
insert into create_table_use_created_policy values (10003,100001,'11');
這里我設(shè)置了1個(gè)小時(shí)后進(jìn)行冷熱遷移,一個(gè)小時(shí)后我們可以在對(duì)象存儲(chǔ)上看到數(shù)據(jù)已經(jīng)遷移過來
同時(shí)我們也可以通過 Doris 提供的命令來查看
show tablets from tbl
從這個(gè)圖上我們也可以看到,已經(jīng)將部分?jǐn)?shù)據(jù)遷移到對(duì)象存儲(chǔ)上了
還可以通過show proc '/backends'可以查看到每個(gè)be上傳到對(duì)象的大小,RemoteUsedCapacity項(xiàng)
我們后面也會(huì)在?show data
這個(gè)命令加上RemoteDataSize這個(gè)屬性,這樣更方便用戶查看表的對(duì)象存儲(chǔ)使用情況文章來源:http://www.zghlxwxcb.cn/news/detail-488846.html
是不是非常簡單方便呢,快點(diǎn)動(dòng)手體驗(yàn)提來吧文章來源地址http://www.zghlxwxcb.cn/news/detail-488846.html
到了這里,關(guān)于Apache Doris 2.0 冷熱分離快速體驗(yàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!