自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

一篇帶給你ClickHouse集群搭建

運維 數(shù)據(jù)庫運維
ClickHouse是一個列導向數(shù)據(jù)庫,它的系統(tǒng)在生產(chǎn)環(huán)境中可以應(yīng)用到比較大的規(guī)模,因為它的線性擴展能力和可靠性保障能夠原生支持shard+replication這種解決方案。它還提供了一些SQL直接接口,有比較豐富的原生client。

[[395205]]

ClickHouse是一個列導向數(shù)據(jù)庫,是原生的向量化執(zhí)行引擎。它在大數(shù)據(jù)領(lǐng)域沒有走Hadoop生態(tài),而是采用Local attached storage作為存儲,這樣整個IO可能就沒有Hadoop那一套的局限。它的系統(tǒng)在生產(chǎn)環(huán)境中可以應(yīng)用到比較大的規(guī)模,因為它的線性擴展能力和可靠性保障能夠原生支持shard+replication這種解決方案。它還提供了一些SQL直接接口,有比較豐富的原生client。

ClickHouse數(shù)據(jù)庫的特點:

  • 速度快ClickHouse性能超過了市面上大部分的列式存儲數(shù)據(jù)庫,相比傳統(tǒng)的數(shù)據(jù)ClickHouse要快100-1000倍,ClickHouse還是有非常大的優(yōu)勢。1億數(shù)據(jù)集:ClickHouse比Vertica約快5倍,比Hive快279倍,比MySQL快801倍。10億數(shù)據(jù)集:ClickHouse比Vertica約快5倍,MySQL和Hive已經(jīng)無法完成任務(wù)了。
  • 功能多1.支持類SQL查詢;2.支持繁多庫函數(shù)(例如IP轉(zhuǎn)化,URL分析等,預估計算/HyperLoglog等);3.支持數(shù)組(Array)和嵌套數(shù)據(jù)結(jié)構(gòu)(Nested Data Structure);4.支持數(shù)據(jù)庫異地復制部署。

要注意,由于ClickHouse的快速查詢還是基于系統(tǒng)資源的,因此在使用的時候要注意每個節(jié)點上的存儲量,以及節(jié)點機器的系統(tǒng)資源要充足。因為查詢時是使用內(nèi)存進行聚合,所以同時并發(fā)查詢的數(shù)量不能太多,否則就會造成資源崩潰。

環(huán)境配置

初始化環(huán)境(所有節(jié)點)

  1. # 修改機器的hostname 
  2. vi /etc/hostname 
  3.  
  4. # 配置hosts 
  5. vi /etc/hosts 
  6.  
  7. 192.168.143.20 node1 
  8. 192.168.143.21 node2 
  9. 192.168.143.22 node3 

 修改完后,執(zhí)行hostname node1...3,不用重啟機器使其生效

下載并安裝ClickHouse(所有節(jié)點)

主要下載四個文件:

  • Clickhouse-client
  • Clickhouse-common-static
  • Clickhouse-server
  • clickhouse-server-common
  1. rpm -ivh *.rpm 

安裝 zookeeper(任意一個節(jié)點)

  1. # 我這里選擇node1 
  2. docker run -d --net host --name zookeeper zookeeper 

 配置集群(所有節(jié)點)

修改/etc/clickhouse-server/config.xml

  1. <!-- 將下面行注釋去掉 --> 
  2. <listen_host>::</listen_host> 
  3.  
  4. <!-- 修改默認數(shù)據(jù)存儲目錄,比如在/home下創(chuàng)建目錄clickhouse --> 
  5. <path>/var/lib/clickhouse/</path> 
  6. <!-- 修改為如下 --> 
  7. <path>/home/clickhouse/</path> 

修改/etc/clickhouse-server/users.xml

  1. <!-- 配置查詢使用的內(nèi)存,根據(jù)機器資源進行配置 --> 
  2. <max_memory_usage>5000000000000</max_memory_usage> 
  3.  
  4. <!-- 在</users>前面增加用戶配置 --> 
  5. <root> 
  6.   <!-- 通過Linux命令計算出密碼的sha256加密值 --> 
  7.   <password_sha256_hex>xxxx...xxxx</password_sha256_hex> 
  8.   <networks> 
  9.     <ip>::/0</ip> 
  10.   </networks> 
  11.   <profile>default</profile> 
  12.   <quota>default</quota> 
  13. </root> 

增加配置文件/etc/metrika.xml

  1. <yandex> 
  2.   <!-- ck集群節(jié)點 --> 
  3.   <clickhouse_remote_servers> 
  4.     <test_cluster> 
  5.       <shard> 
  6.         <internal_replication>true</internal_replication> 
  7.         <replica> 
  8.           <host>node1</host> 
  9.           <port>9000</port> 
  10.           <user>root</user
  11.           <password>123456</password
  12.         </replica> 
  13.       </shard> 
  14.       <shard> 
  15.         <internal_replication>true</internal_replication> 
  16.         <replica> 
  17.           <host>node2</host> 
  18.           <port>9000</port> 
  19.           <user>root</user
  20.           <password>123456</password
  21.         </replica> 
  22.       </shard> 
  23.       <shard> 
  24.         <internal_replication>true</internal_replication> 
  25.         <replica> 
  26.           <host>node3</host> 
  27.           <port>9000</port> 
  28.           <user>root</user
  29.           <password>123456</password
  30.         </replica> 
  31.       </shard> 
  32.     </test_cluster> 
  33.      
  34.     <!-- zookeeper相關(guān)配置--> 
  35.     <zookeeper-servers> 
  36.       <node index="1"
  37.         <host>node1</host> 
  38.         <port>2181</port> 
  39.       </node> 
  40.     </zookeeper-servers> 
  41.      
  42.     <networks> 
  43.       <ip>::/0</ip> 
  44.     </networks> 
  45.      
  46.     <macros> 
  47.       <replica>node1</replica> 
  48.     </macros> 
  49.      
  50.     <!-- 壓縮相關(guān)配置 --> 
  51.     <clickhouse_compression> 
  52.       <case
  53.         <min_part_size>10000000000</min_part_size> 
  54.         <min_part_size_ratio>0.01</min_part_size_ratio> 
  55.         <method>lz4</method> 
  56.       </case
  57.     </clickhouse_compression> 
  58.   </clickhouse_remote_servers> 
  59. </yandex> 

 重啟clickhouse服務(wù)

  1. service clickhouse-server restart 
  2.  
  3. # 如果不成功,則使用以下命令 
  4. nohup /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml $ 

 創(chuàng)建數(shù)據(jù)表(所有節(jié)點)

使用可視化工具連接每個節(jié)點,在上面創(chuàng)建MergeTree

  1. create database test; 
  2.  
  3. create table test.data 
  4.   country String, 
  5.   province String, 
  6.   value String 
  7. engine=MergeTree() 
  8. partition by (country, province) 
  9. order by value; 

 創(chuàng)建分布式表(node1節(jié)點)

  1. create table test.mo as test.data ENGINE = Distributed(test_cluster, test, data, rand()); 

使用Python連接clickhouse

安裝clickhouse-driver

  1. pip install clickhouse-driver 

執(zhí)行命令

  1. from clickhouse_driver import Client 
  2.  
  3. # 在哪個節(jié)點創(chuàng)建了分布式表,就連接哪個節(jié)點 
  4. client = Client('192.168.143.20'user='root'password='123456'database='test'
  5. print(client.execute('select count(*) from mo')) 

 【編輯推薦】

 

責任編輯:姜華 來源: 今日頭條
相關(guān)推薦

2022-02-17 08:53:38

ElasticSea集群部署

2021-01-26 06:58:03

AnsibleCeph集群運維

2021-07-12 06:11:14

SkyWalking 儀表板UI篇

2021-07-21 09:48:20

etcd-wal模塊解析數(shù)據(jù)庫

2021-04-08 11:00:56

CountDownLaJava進階開發(fā)

2021-06-21 14:36:46

Vite 前端工程化工具

2021-01-28 08:55:48

Elasticsear數(shù)據(jù)庫數(shù)據(jù)存儲

2021-04-01 10:51:55

MySQL鎖機制數(shù)據(jù)庫

2021-04-14 14:16:58

HttpHttp協(xié)議網(wǎng)絡(luò)協(xié)議

2022-03-22 09:09:17

HookReact前端

2022-04-29 14:38:49

class文件結(jié)構(gòu)分析

2023-03-29 07:45:58

VS編輯區(qū)編程工具

2021-03-12 09:21:31

MySQL數(shù)據(jù)庫邏輯架構(gòu)

2024-06-13 08:34:48

2021-04-14 07:55:45

Swift 協(xié)議Protocol

2022-02-25 15:50:05

OpenHarmonToggle組件鴻蒙

2021-07-08 07:30:13

Webpack 前端Tree shakin

2023-03-13 09:31:04

2021-10-28 08:51:53

GPIO軟件框架 Linux

2021-05-08 08:36:40

ObjectString前端
點贊
收藏

51CTO技術(shù)棧公眾號