溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

clickhouse21.1.2.15使用的命令有哪些

發(fā)布時間:2021-11-11 17:46:45 來源:億速云 閱讀:644 作者:柒染 欄目:大數(shù)據(jù)

這篇文章將為大家詳細(xì)講解有關(guān)clickhouse21.1.2.15使用的命令有哪些,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

clickhouse-client -h ip地址 -d default -m -u default --password 密碼明文

clickhouse-client --help //幫助文檔

登錄權(quán)限認(rèn)證

vim /etc/clickhouse-server/users.xml //添加用戶名密碼訪問

      <lyj> <!--lyj 用戶名-->
            <password>123456</password> <!--密碼-->
            <networks>
                <ip>::/0</ip>  <!--訪問控制ip-->
            </networks>
            <!-- Settings profile for user. -->
            <profile>default</profile>
            <!-- Quota for user. -->
            <quota>default</quota>
        </lyj>

修改完配置重啟 clickhouse restart

這里是springboot訪問clickhouse文檔:

https://www.cnblogs.com/cicada-smile/p/11632251.html

源碼:

GitHub·地址https://github.com/cicadasmile/middle-ware-parent

GitEE·地址https://gitee.com/cicadasmile/middle-ware-parent

1. sudo clickhouse start  //啟動

2. clickhouse stop //關(guān)閉

3. clickhouse  restart //重啟

4.clickhouse -client  //打開客戶端命令行

5. vim /etc/clickhouse-server/config.xml  //修改配置文件

6. 配置允許遠(yuǎn)程連接

進(jìn)入clickhouse配置文件/etc/clickhouse-server/config.xml
<listen_host>::</listen_host>取消注釋;
重啟服務(wù):clickhouse restart

clickhouse local [args]
clickhouse client [args]
clickhouse benchmark [args]
clickhouse server [args]
clickhouse extract-from-config [args]
clickhouse compressor [args]
clickhouse format [args]
clickhouse copier [args]
clickhouse obfuscator [args]
clickhouse git-import [args]
clickhouse install [args]
clickhouse start [args]
clickhouse stop [args]
clickhouse status [args]
clickhouse restart [args]
clickhouse hash-binary [args]

7.建表查詢demo

create database test;//建庫create table if not exists test.tb_test(id Int64,datetime DateTime,content Nullable(String),value Nullable(Float64),date Date)engine = MergeTree                  --使用mergeTree引擎,ch主要引擎
partition by to YYYYMM(datetime)     --按照datetime這個字段的月進(jìn)行分區(qū)
order by id                         --按照id進(jìn)行排序TTL datetime + INTERVAL 3 DAY ;     --三天過期--修改表中數(shù)據(jù)過期時間,到期后數(shù)據(jù)會在merge時被刪除ALTER TABLE test.tb_test MODIFY TTL datetime + INTERVAL 1 DAY;--查詢select * from tb_test order by id;--刪除分區(qū),可用于定時任務(wù)刪除舊數(shù)據(jù)
alter table tb_test drop partition '202005';--插入數(shù)據(jù)
insert into tb_test values (5, '2020-02-29 12:38:37', 'abcde', 12.553, '2020-04-25');--修改數(shù)據(jù),不推薦使用
alter table tb_test update content = 'hello click' where id=52;--刪除數(shù)據(jù),不推薦使用
alter table tb_test delete WHERE id=56;

8.求和引擎SummingMergeTree
這種引擎可以自動聚合非主鍵數(shù)字列,可以用于事件統(tǒng)計

--自動求和聚合表CREATE TABLE IF NOT EXISTS tb_stat(regionId String,    --門店id
    groupId String,     --統(tǒng)計組idin int,             --進(jìn)客流out int,            --出客流
    statDate DateTime   --統(tǒng)計時間)ENGINE = SummingMergeTreepartition by (toYYYYMM(statDate), regionId)ORDER BY (toStartOfHour(statDate), regionId, groupId);insert into tb_stat values ('1232364', '111',  32, 2,  '2020-03-25 12:56:00');insert into tb_stat values ('1232364', '111',  34, 44, '2020-03-25 12:21:00');insert into tb_stat values ('1232364', '111',  54, 12, '2020-03-25 12:20:00');insert into tb_stat values ('1232364', '222',  45, 11, '2020-03-25 12:13:00');insert into tb_stat values ('1232364', '222',  32, 33, '2020-03-25 12:44:00');insert into tb_stat values ('1232364', '222',  12, 23, '2020-03-25 12:22:00');insert into tb_stat values ('1232364', '333',  54, 54, '2020-03-25 12:11:00');insert into tb_stat values ('1232364', '333',  22, 74, '2020-03-25 12:55:00');insert into tb_stat values ('1232364', '333',  12, 15, '2020-03-25 12:34:00');select toStartOfHour(statDate), regionId, groupId, sum(in), sum(out) from tb_stat group by toStartOfHour(statDate), regionId, groupId;

數(shù)據(jù)插入后,大概過1分鐘,在此查詢該表可以發(fā)現(xiàn),只剩下3調(diào)數(shù)據(jù):

ambari-03 :) select * from tb_stat;

┌─regionId─┬─groupId─┬──in─┬─out─┬────────────statDate─┐
│ 1232364  │ 111     │ 120 │  58 │ 2020-03-25 12:56:00 │
│ 1232364  │ 222     │  89 │  67 │ 2020-03-25 12:13:00 │
│ 1232364  │ 333     │  88 │ 143 │ 2020-03-25 12:11:00 │
└──────────┴─────────┴─────┴─────┴─────────────────────┘

關(guān)于clickhouse21.1.2.15使用的命令有哪些就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI