From cb3fca18388545053f8c65e82e8bbf3c0b133118 Mon Sep 17 00:00:00 2001 From: houjinchuan Date: Tue, 5 Mar 2024 10:44:44 +0800 Subject: [PATCH] =?UTF-8?q?[CN-1568]=20clickhouse=E5=A2=9E=E5=8A=A0Locatio?= =?UTF-8?q?n=20Intelligence=E7=9B=B8=E5=85=B3=E5=BA=93=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2024/CN-24.03/clickhouse/update-24.03-ck.sql | 48 +++++++++++++++++ .../start_gohangout_k2ck_location_subscriber_cn.sh | 51 +++++++++++++++++++ .../gohangout/conf/k2ck_location_subscriber_cn.yml | 28 ++++++++++ .../2024/CN-24.03/gohangout/start_all.sh | 23 +++++++++ .../Clickhouse_CN_建表语句.sql | 49 +++++++++++++++--- .../Clickhouse_CN_校验sql.sql | 4 +- 6 files changed, 196 insertions(+), 7 deletions(-) create mode 100644 CN发布版本更新记录/2024/CN-24.03/clickhouse/update-24.03-ck.sql create mode 100644 CN发布版本更新记录/2024/CN-24.03/gohangout/bin/ghoStart/start_gohangout_k2ck_location_subscriber_cn.sh create mode 100644 CN发布版本更新记录/2024/CN-24.03/gohangout/conf/k2ck_location_subscriber_cn.yml create mode 100644 CN发布版本更新记录/2024/CN-24.03/gohangout/start_all.sh diff --git a/CN发布版本更新记录/2024/CN-24.03/clickhouse/update-24.03-ck.sql b/CN发布版本更新记录/2024/CN-24.03/clickhouse/update-24.03-ck.sql new file mode 100644 index 0000000..c4c97a0 --- /dev/null +++ b/CN发布版本更新记录/2024/CN-24.03/clickhouse/update-24.03-ck.sql @@ -0,0 +1,48 @@ +set distributed_ddl_task_timeout = 180; + +ALTER table cyber_narrator_galaxy.metric_subscriber_app_local on cluster ck_cluster drop column IF EXISTS subscriber_longitude, drop column IF EXISTS subscriber_latitude; +ALTER table cyber_narrator_galaxy.metric_subscriber_app on cluster ck_cluster drop column IF EXISTS subscriber_longitude, drop column IF EXISTS subscriber_latitude; +ALTER table cyber_narrator_galaxy.metric_subscriber_app on cluster ck_query drop column IF EXISTS subscriber_longitude, drop column IF EXISTS subscriber_latitude; + + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.location_subscriber_local ON CLUSTER ck_cluster ( + subscriber_id String, + imei String, + imsi String, + phone_number String, + apn String, + subscriber_longitude Nullable(Float64), + subscriber_latitude Nullable(Float64), + first_location String, + second_location String, + third_location String, + stat_time Int64 +) ENGINE = MergeTree PARTITION BY toYYYYMMDD(toDate(stat_time)) ORDER BY (stat_time,subscriber_id) SETTINGS index_granularity = 8192; + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.location_subscriber ON CLUSTER ck_cluster ( + subscriber_id String, + imei String, + imsi String, + phone_number String, + apn String, + subscriber_longitude Nullable(Float64), + subscriber_latitude Nullable(Float64), + first_location String, + second_location String, + third_location String, + stat_time Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'location_subscriber_local', rand()); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.location_subscriber ON CLUSTER ck_query ( + subscriber_id String, + imei String, + imsi String, + phone_number String, + apn String, + subscriber_longitude Nullable(Float64), + subscriber_latitude Nullable(Float64), + first_location String, + second_location String, + third_location String, + stat_time Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'location_subscriber_local', rand()); diff --git a/CN发布版本更新记录/2024/CN-24.03/gohangout/bin/ghoStart/start_gohangout_k2ck_location_subscriber_cn.sh b/CN发布版本更新记录/2024/CN-24.03/gohangout/bin/ghoStart/start_gohangout_k2ck_location_subscriber_cn.sh new file mode 100644 index 0000000..ef63868 --- /dev/null +++ b/CN发布版本更新记录/2024/CN-24.03/gohangout/bin/ghoStart/start_gohangout_k2ck_location_subscriber_cn.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +#gohangout启动文件 + +#配置文件名称,注意配置文件需要放在$BASE_DIR/conf文件夹下 +YML_NAME=k2ck_location_subscriber_cn +#gohangout的二进制启动文件路径 +BASE_DIR=$(cd $(dirname $0); cd ../../; pwd) +#日志级别,1,5,10,数字越大日志越详细 +LOG_LV=5 +#线程总数,即开启worker数量,每个线程拥有自己的filter, output,占用多份内存,默认1个线程 +THREAD_SUM=3 +#进程总数 +PROCESS_SUM=$1 + +if [ ! -d "$BASE_DIR/logs" ]; then + mkdir -p $BASE_DIR/logs +fi + +echo "###########################$(date +%Y%m%d%H%M%S)###########################" >> $BASE_DIR/bin/start_log/${YML_NAME}_restart.log +id=0 +logid=0 +while true ; do + NUM=`ps -ef | grep -w ${YML_NAME}.yml | grep -v grep |wc -l` + pids=$(ps -ef | grep -w ${YML_NAME}.yml | grep -v grep | awk '{print $2}') + time_stamp=$(date +%Y%m%d%H%M%S) + if [ "${NUM}" -lt ${PROCESS_SUM} ];then + $BASE_DIR/bin/gohangout --config $BASE_DIR/conf/${YML_NAME}.yml --logtostderr --v ${LOG_LV} --worker ${THREAD_SUM} >> $BASE_DIR/logs/${YML_NAME}.log 2>&1 & + echo "${time_stamp} ---> the ${YML_NAME}APP restart ---> $id" >> $BASE_DIR/bin/start_log/${YML_NAME}_restart.log + ((logid++)) + ((id++)) + if [ ${logid} -gt ${PROCESS_SUM} ];then + logid=0 + pids=$(ps -ef | grep -w ${YML_NAME}.yml | grep -v grep | awk '{print $2}') + for pid in $pids + do + kill -9 $pid + done + echo "kafka or clickhouse is error,reset gohangout,sleep 30s... ..." >> $BASE_DIR/bin/start_log/${YML_NAME}_restart.log + sleep 30 + fi + #大于设置进程数,杀掉所有进程,重启 + elif [ "${NUM}" -gt ${PROCESS_SUM} ];then + for pid in $pids + do + kill -9 $pid + done + id=0 + fi + sleep 1 +done diff --git a/CN发布版本更新记录/2024/CN-24.03/gohangout/conf/k2ck_location_subscriber_cn.yml b/CN发布版本更新记录/2024/CN-24.03/gohangout/conf/k2ck_location_subscriber_cn.yml new file mode 100644 index 0000000..0e057ee --- /dev/null +++ b/CN发布版本更新记录/2024/CN-24.03/gohangout/conf/k2ck_location_subscriber_cn.yml @@ -0,0 +1,28 @@ +inputs: + - Kafka: + topic: + LOCATION-SUBSCRIBER: 1 + #assign: + # weblog: [0,9] + codec: json + consumer_settings: + bootstrap.servers: "192.168.44.55:9092" + group.id: location_subscriber_1 + max.partition.fetch.bytes: '10485760' + auto.commit.interval.ms: '5000' + # from.beginning: 'true' + # sasl.mechanism: PLAIN + # sasl.user: admin + # sasl.password: admin-secret + +outputs: + - Clickhouse: + table: 'cyber_narrator_galaxy.location_subscriber_local' + username: 'default' + password: 'ceiec2019' + hosts: + - 'tcp://192.168.44.55:9001' + bulk_actions: 100000 + flush_interval: 30 + concurrent: 2 + conn_max_life_time: 60 diff --git a/CN发布版本更新记录/2024/CN-24.03/gohangout/start_all.sh b/CN发布版本更新记录/2024/CN-24.03/gohangout/start_all.sh new file mode 100644 index 0000000..cca4927 --- /dev/null +++ b/CN发布版本更新记录/2024/CN-24.03/gohangout/start_all.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +STARTDIR=$(cd $(dirname $0); pwd) +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_location_subscriber_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_subscriber_app_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_security_event_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_ip_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_region_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_asn_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_application_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_domain_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_protocol_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_link_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_qname_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_server_ip_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_qtype_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_rcode_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_rr_a_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_rr_aaaa_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_dns_rr_cname_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_relation_cn.sh $1 > /dev/null 2>&1 & +nohup $STARTDIR/bin/ghoStart/start_gohangout_k2ck_metric_ip_dynamic_attribute_cn.sh $1 > /dev/null 2>&1 & +$STARTDIR/bin/ghoStart/start_gohangout_k2ck_cn_record.sh $1 diff --git a/Clickhouse最新全量建表语句/Clickhouse_CN_建表语句.sql b/Clickhouse最新全量建表语句/Clickhouse_CN_建表语句.sql index ee2acff..5b7d244 100644 --- a/Clickhouse最新全量建表语句/Clickhouse_CN_建表语句.sql +++ b/Clickhouse最新全量建表语句/Clickhouse_CN_建表语句.sql @@ -1161,8 +1161,6 @@ CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.metric_subscriber_app_local ON imsi String, phone_number String, apn String, - subscriber_longitude Nullable(Float64), - subscriber_latitude Nullable(Float64), stat_time Int64, sent_pkts Int64, sent_bytes Int64, @@ -1201,8 +1199,6 @@ CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.metric_subscriber_app ON CLUSTE imsi String, phone_number String, apn String, - subscriber_longitude Nullable(Float64), - subscriber_latitude Nullable(Float64), stat_time Int64, sent_pkts Int64, sent_bytes Int64, @@ -1241,8 +1237,6 @@ CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.metric_subscriber_app ON CLUSTE imsi String, phone_number String, apn String, - subscriber_longitude Nullable(Float64), - subscriber_latitude Nullable(Float64), stat_time Int64, sent_pkts Int64, sent_bytes Int64, @@ -1275,6 +1269,49 @@ CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.metric_subscriber_app ON CLUSTE ) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'metric_subscriber_app_local', rand()); +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.location_subscriber_local ON CLUSTER ck_cluster ( + subscriber_id String, + imei String, + imsi String, + phone_number String, + apn String, + subscriber_longitude Nullable(Float64), + subscriber_latitude Nullable(Float64), + first_location String, + second_location String, + third_location String, + stat_time Int64 +) ENGINE = MergeTree PARTITION BY toYYYYMMDD(toDate(stat_time)) ORDER BY (stat_time,subscriber_id) SETTINGS index_granularity = 8192; + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.location_subscriber ON CLUSTER ck_cluster ( + subscriber_id String, + imei String, + imsi String, + phone_number String, + apn String, + subscriber_longitude Nullable(Float64), + subscriber_latitude Nullable(Float64), + first_location String, + second_location String, + third_location String, + stat_time Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'location_subscriber_local', rand()); + +CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.location_subscriber ON CLUSTER ck_query ( + subscriber_id String, + imei String, + imsi String, + phone_number String, + apn String, + subscriber_longitude Nullable(Float64), + subscriber_latitude Nullable(Float64), + first_location String, + second_location String, + third_location String, + stat_time Int64 +) ENGINE = Distributed('ck_cluster', 'cyber_narrator_galaxy', 'location_subscriber_local', rand()); + + CREATE TABLE IF NOT EXISTS cyber_narrator_galaxy.metric_dns_server_ip_local ON CLUSTER ck_cluster ( server_ip String, server_country_region String, diff --git a/Clickhouse最新全量建表语句/Clickhouse_CN_校验sql.sql b/Clickhouse最新全量建表语句/Clickhouse_CN_校验sql.sql index a62d82b..082b2e6 100644 --- a/Clickhouse最新全量建表语句/Clickhouse_CN_校验sql.sql +++ b/Clickhouse最新全量建表语句/Clickhouse_CN_校验sql.sql @@ -43,8 +43,10 @@ SELECT l7_protocol, server_port, stat_time, sent_pkts, sent_bytes, received_pkts FROM cyber_narrator_galaxy.metric_protocol where stat_time >= toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND stat_time = toUnixTimestamp('2030-01-01 00:00:00') AND recv_time