clickhouse入门

2018-07-02  本文已影响35人  liamu

clickhouse使用

clickhouse介绍

clickhouse-server --daemon --pid-file=/var/run/clickhouse-server/clickhouse-server.pid --config-file=/etc/clickhouse-server/config.xml

ps -aux | grep clickhouse

clickhouse-client --port=9008

show tables;
select now();
ps -aux | grep clickhouse-server
kill -9 $pid
nohup clickhouse-server --config-file=/etc/clickhouse-server/config.xml >null 2>&1 &

库和表格的创建

CREATE DATABASE [IF NOT EXISTS] db_firewall_log

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db.]name [ON CLUSTER cluster]
(
    name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
    name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
    ...
) ENGINE = engine


CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits)


CREATE TABLE code_province( \
    state_province        String, \
    province_name         String, \
    create_date           date \
) ENGINE = MergeTree(create_date, (state_province), 8192);



CREATE TABLE m_tb_alert_http_url_log_20180403 ENGINE = MergeTree
ORDER BY id AS SELECT * FROM mysql('127.0.0.1:3307','db_firewall_log','m_tb_alert_http_url_log_20180403', 'root', 'bd_123456')



CREATE TABLE `m_tb_alert_http_url_log_20180403` (`id` UInt64,`sAppProto` String,`sSrcMac` String,`sSrcIP` String,`iSrcPort` UInt64,`sDstMac` String,`sDstIP` String,`iDstPort` UInt64,`sType` String,`sSiteName` String,`sHost` String,`sUri` String,`sMethod` String,`sField` String,`sUser` String,`sDept` String,`sScc` String,`sSccFlag` String,`sURL` String,`sTitle` String,`sCategory` String,`sAlertDetail` String,`sAlertStatus` String,`sAlertKeyword` String,`sDeviceID` String,`iAlertFlag` String,`sAlertLevel` String) ENGINE = MergeTree(id, (sSiteName), 8192);



CREATE TABLE m_tb_alert_http_url_log_20180403 ENGINE = MergeTree AS SELECT * FROM mysql('127.0.0.1:3306', 'db_firewall_log', 'm_tb_alert_http_url_log_20180403', 'root', 'bd_123456') 
上一篇 下一篇

猜你喜欢

热点阅读