当前位置:网站首页>Clickhouse learning (V) cluster operation
Clickhouse learning (V) cluster operation
2022-07-29 05:33:00 【Crying dogs in the sun】
copy
zookeeper To configure
Internal direct modification
Just change it to your own
External file form
stay /etc/clickhouse-server/config.d Create metrika.xml file
<?xml version="1.0"?>
<yandex>
<zookeeper-servers>
<node index="1">
<host>spark01</host>
<port>2181</port>
</node>
<node index="2">
<host>spark02</host>
<port>2181</port>
</node>
<node index="3">
<host>spark03</host>
<port>2181</port>
</node>
</zookeeper-servers>
</yandex>
To other machines
stay /etc/clickhouse-server/config.xml Add the following information to :
<zookeeper incl="zookeeper-servers" optional="true" />
<include_from>/etc/clickhouse-server/config.d/metrika.xml</include_from>
Distributed cluster
This completes the configuration
test
Replicas can only synchronize data, but cannot synchronize table structure data
/clickhouse/table/01/t_order_rep It means that zookeeper Path information in among 01 Represents a fragment
rep_102 Indicates the name of the copy
Create table structures on three machines respectively
spark01 To create a :
create table t_order_rep2 (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/table/01/t_order_rep','rep_101')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
spark02 To create a :
create table t_order_rep2 (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/table/01/t_order_rep','rep_102')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
spark03 To create a :
create table t_order_rep2 (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/table/01/t_order_rep','rep_103')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
towards spark01 Insert data
insert into t_order_rep2 values
(101,'sku_001',1000.00,'2020-06-01 12:00:00'),
(102,'sku_002',2000.00,'2020-06-01 12:00:00'),
(103,'sku_004',2500.00,'2020-06-01 12:00:00'),
(104,'sku_002',2000.00,'2020-06-01 12:00:00'),
(105,'sku_003',600.00,'2020-06-02 12:00:00');
Can be in spark02,03 It's on the Internet
Fragmentation cluster
Sharding is to distribute the data of a table on different nodes , Re pass Distributed The table engine splices data together for use .
Distributed The table engine itself does not store data, but is only used to manage other partitions
build
Create two tiles , The first fragment has a copy
stay config.d Create metrika-shard.xml file
<?xml version="1.0"?>
<yandex>
<remote_servers>
<clusters> <!-- Cluster name -->
<shard> <!-- The first slice of the cluster -->
<internal_replication>true</internal_replication>
<replica> <!-- The first copy of the slice -->
<host>spark01</host>
<port>9000</port>
</replica>
<replica> <!-- The second copy of the slice -->
<host>spark02</host>
<port>9000</port>
</replica>
</shard>
<shard> <!-- The second slice of the cluster -->
<internal_replication>true</internal_replication>
<replica> <!-- The first copy of the slice -->
<host>spark03</host>
<port>9000</port>
</replica>
</shard>
</clusters>
</remote_servers>
<zookeeper-servers>
<node index="1">
<host>spark01</host>
<port>2181</port>
</node>
<node index="2">
<host>spark02</host>
<port>2181</port>
</node>
<node index="3">
<host>spark03</host>
<port>2181</port>
</node>
</zookeeper-servers>
<macros>
<shard>01</shard> <!-- Different machines put different pieces -->
<replica>rep_1_1</replica> <!-- The number of copies placed on different machines is different -->
</macros>
</yandex>
Distribute to other clusters
take spark02 Modify the file on
take spark03 Modify the file on
stay config.xml Change the file name under the file
Distributed cluster
After each configuration config.xml The service must be restarted
test
First create a shard table
create table st_order_mt on cluster clusters (
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
) engine =ReplicatedMergeTree('/clickhouse/tables/{shard}/st_order_mt','{replica}')
partition by toYYYYMMDD(create_time)
primary key (id)
order by (id,sku_id);
To create a Distribute Distributed table
create table test2 on cluster clusters
(
id UInt32,
sku_id String,
total_amount Decimal(16,2),
create_time Datetime
)engine = Distributed(clusters,default, st_order_mt,hiveHash(sku_id));
Insert data into a distributed table
insert into test2 values
(201,'sku_001',1000.00,'2020-06-03 12:00:00') ;
(202,'sku_002',2000.00,'2020-06-01 12:00:00'),
(203,'sku_004',2500.00,'2020-06-01 12:00:00'),
(204,'sku_002',2000.00,'2020-06-01 12:00:00'),
(205,'sku_003',600.00,'2020-06-02 12:00:00');
The first partition table
A copy of the first shard table
The second partition table
边栏推荐
- Container security open source detection tool - veinmind (mirror backdoor, malicious samples, sensitive information, weak password, etc.)
- ClickHouse学习(五)集群操作
- 【剑指offer】— 详解库函数atoi以及模拟实现atoi函数
- Integer overflow and printing
- 【C语言系列】—深度解剖数据在内存中的存储(一) 暑假开篇
- Occt learning 003 - MFC single document project
- Time complexity and space complexity
- Come on! See how Clickhouse, which has risen 16 places a year, can be implemented in jd.com
- Terminal shell common commands
- 整数溢出和打印
猜你喜欢
365 day challenge leetcode1000 question - distance between bus stops on day 038 + time-based key value storage + array closest to the target value after transforming the array and + maximum value at t
365 day challenge leetcode 1000 questions - day 042 array sequence number conversion + relative ranking discretization processing
携手数字人、数字空间、XR平台,阿里云与伙伴共同建设“新视界”
ClickHouse学习(十一)clickhouseAPI操作
Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
Container security open source detection tool - veinmind (mirror backdoor, malicious samples, sensitive information, weak password, etc.)
GPIO的输入输出详解
C language first level pointer
Best practices for elastic computing in the game industry
Yangyonglin, vice president of Rushi Technology: when traditional industries encounter "digital space"
随机推荐
Summary of the first week
携手数字人、数字空间、XR平台,阿里云与伙伴共同建设“新视界”
Cryengine3 debugging shader method
时间复杂度和空间复杂度
Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
ClickHouse学习(十)监控运行指标
365天挑战LeetCode1000题——Day 035 每日一题 + 二分查找 13
Detailed explanation of exit interrupt
Best practices for elastic computing in the game industry
Helm chart for Kubernetes
重定向和文件
365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array
Live broadcast preview | how to improve enterprise immunity through "intelligent edge security"?
365 day challenge leetcode1000 question - distance between bus stops on day 038 + time-based key value storage + array closest to the target value after transforming the array and + maximum value at t
C语言 一级指针
ClickHouse学习(八)物化视图
B - identify floating point constant problems
Alibaba cloud architect Liang Xu: MES on cloud box helps customers quickly build digital factories
Day 1
【C语言系列】—深度解剖数据在内存中的存储(二)-浮点型