一、目的
經(jīng)過6個月的奮斗,項目的離線數(shù)倉部分終于可以上線了,因此整理一下離線數(shù)倉的整個流程,既是大家提供一個案例經(jīng)驗,也是對自己近半年的工作進行一個總結。
二、數(shù)倉實施步驟
(六)步驟六、在ClickHouse的ADS層建表并用Kettle同步Hive中DWS層的結果數(shù)據(jù)
1、ClickHouse的ADS層建庫建表語句
--如果不存在則創(chuàng)建hurys_dc_ads數(shù)據(jù)庫
create database if not exists hurys_dc_ads;
--使用hurys_dc_ads數(shù)據(jù)庫
use hurys_dc_ads;
--1.1轉向比數(shù)據(jù)表——5分鐘周期
create ?table ?if not exists hurys_dc_ads.ads_turnratio_volume_5min(
? ? device_no ? ? ? ?String ? ? ? ? ? ? ? ?comment '設備編號',
? ? create_time ? ? ?DateTime ? ? ? ? ? ? ?comment '創(chuàng)建時間',
? ? start_time ? ? ? DateTime ? ? ? ? ? ? ?comment '開始時間',
? ? name ? ? ? ? ? ? Nullable(String) ? ? ?comment '場景',
? ? direction ? ? ? ?Nullable(String) ? ? ?comment '雷達朝向',
? ? volume_sum ? ? ? Nullable(int) ? ? ? ? comment '指定時間段內(nèi)通過路口的車輛總數(shù)',
? ? volume_left ? ? ?Nullable(int) ? ? ? ? comment '指定時間段內(nèi)通過路口的左轉車輛總數(shù)',
? ? volume_straight ?Nullable(int) ? ? ? ? comment '指定時間段內(nèi)通過路口的直行車輛總數(shù)',
? ? volume_right ? ? Nullable(int) ? ? ? ? comment '指定時間段內(nèi)通過路口的右轉車輛總數(shù)',
? ? volume_turn ? ? ?Nullable(int) ? ? ? ? comment '指定時間段內(nèi)通過路口的掉頭車輛總數(shù)',
? ? day ? ? ? ? ? ? ?Date ? ? ? ? ? ? ? ? ?comment '日期'
)
ENGINE = MergeTree
PARTITION BY (day)
PRIMARY KEY day
order by day
TTL day + toIntervalMonth(12)
SETTINGS index_granularity = 8192;
2、海豚執(zhí)行ADS層建表語句工作流
對于剛部署的服務器,由于Hive沒有建庫建表、而且手動建表效率低,因此通過海豚調(diào)度器直接執(zhí)行建庫建表的.sql文件
(1)海豚的資源中心加建庫建表的SQL文件
(2)海豚配置DWS層建表語句的工作流(不需要定時,一次就行)
#! /bin/bash
source /etc/profile
clickhouse-client --user default --password hurys@123 -d default --multiquery <ads.sql
注意:default是clickhouse創(chuàng)建時自帶的數(shù)據(jù)庫
3、Kettle轉換任務配置
注意:從Hive到ClickHouse,每次是增量導入,而不是全量導入
4、海豚調(diào)度器調(diào)度kettle轉換任務
(1)海豚配置ADS層每日執(zhí)行Kettle任務的工作流(需要定時,每日一次)
#!/bin/bash
source /etc/profile
/usr/local/hurys/dc_env/kettle/data-integration/pan.sh -rep=hurys_linux_kettle_repository -user=admin -pass=admin -dir=/hive_to_clickhouse/ -trans=02_Hive_to_ClickHouse_dws_evaluation_1hour level=Basic >>/home/log/kettle/02_Hive_to_ClickHouse_dws_evaluation_1hour_`date +%Y%m%d`.log?
(2)工作流定時任務設置(注意與其他工作流的時間間隔)
(3)注意點
3.3.1 由于每次kettle任務是增量導入數(shù)據(jù),因此在腳本里添加kettle運行的日志
level=Basic >>/home/log/kettle/02_Hive_to_ClickHouse_dws_evaluation_1hour_`date +%Y%m%d`.log?
可以查看一下kettle運行的日志文件
文章來源:http://www.zghlxwxcb.cn/news/detail-729982.html
離線數(shù)倉從Kafka到ClickHouse的全流程大致就是如此,當然很多細節(jié)需要優(yōu)化完善!文章來源地址http://www.zghlxwxcb.cn/news/detail-729982.html
到了這里,關于一百八十七、大數(shù)據(jù)離線數(shù)倉完整流程——步驟六、在ClickHouse的ADS層建表并用Kettle同步Hive中DWS層的結果數(shù)據(jù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!