android系统定制开发clickhouse集群搭建详细步骤

搭建说明

集群依赖Zookeeper集群。android系统定制开发因此需要先搭建zk集群。
请先参考 完成集群搭建。

如果zookeeper集群已成功搭建完成,下面开始搭建Clickhouse集群。

需要环境:

实例1实例2实例3
IP192.168.11.11192.168.11.12192.168.11.13
OScentos7.9centos7.9centos7.9
zkzookeeper-3.8.0zookeeper-3.8.0zookeeper-3.8.0
clickhouse22.2.2.1-222.2.2.1-222.2.2.1-2
javaJDK8JDK8JDK8

1.rpm安装

# 下载cd /usr/local/clickhousewget https://mirrors.tuna.tsinghua.edu.cn/clickhouse/rpm/stable/x86_64/clickhouse-client-22.2.2.1-2.noarch.rpmwget https://mirrors.tuna.tsinghua.edu.cn/clickhouse/rpm/stable/x86_64/clickhouse-common-static-22.2.2.1-2.x86_64.rpmwget https://mirrors.tuna.tsinghua.edu.cn/clickhouse/rpm/stable/x86_64/clickhouse-server-22.2.2.1-2.noarch.rpm
  • 1
  • 2
  • 3
  • 4
  • 5
# 安装命令rpm -ivh clickhouse-common-static-22.2.2.1-2.x86_64.rpm clickhouse-client-22.2.2.1-2.noarch.rpm clickhouse-server-22.2.2.1-2.noarch.rpm
  • 1
  • 2

在三台实例上重复上述操作

2.配置修改

cd /etc/clickhouse-server
  • 1

config.xml

vim config.xml
  • 1
<listen_host>0.0.0.0</listen_host><remote_servers>        <enic_cluster>            <shard>                <replica>                    <host>192.168.11.11</host>                    <port>9000</port>                </replica>            </shard>            <shard>                <replica>                    <host>192.168.11.12</host>                    <port>9000</port>                </replica>            </shard>            <shard>                <replica>                    <host>192.168.11.13</host>                    <port>9000</port>                </replica>            </shard>        </enic_cluster></remote_servers>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

users.xml

vim users.xml
  • 1
<enic>	<password>12345678</password>    <networks incl="networks" replace="replace">        <ip>::/0</ip>    </networks>    <profile>default</profile>    <quota>default</quota></enic>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

metrika.xml

cd /etc/clickhouse-servervim metrika.xml
  • 1
  • 2
<yandex>    <zookeeper-servers>        <node index="1">            <host>192.168.11.11</host>            <port>2181</port>        </node>        <node index="2">            <host>192.168.11.12</host>            <port>2181</port>        </node>        <node index="3">            <host>192.168.11.13</host>            <port>2181</port>        </node>    </zookeeper-servers></yandex>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

重启clickhouse-server

systemctl restart clickhouse-server
  • 1

查看clickhouse-server状态

systemctl status clickhouse-server
  • 1
● clickhouse-server.service - ClickHouse Server (analytic DBMS for big data)   Loaded: loaded (/etc/systemd/system/clickhouse-server.service; enabled; vendor preset: disabled)   Active: active (running) since Fri 2022-04-29 11:38:43 CST; 2h 49min ago Main PID: 30158 (clckhouse-watch)    Tasks: 203 (limit: 22997)   Memory: 437.8M   CGroup: /system.slice/clickhouse-server.service           ├─30158 clickhouse-watchdog --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid           └─30159 /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-serve>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在三台实例上重复上述操作

其它操作

启动clickhouse-server

systemctl start clickhouse-server
  • 1

关闭clickhouse-server

systemctl stop clickhouse-server
  • 1

查看clickhouse-server状态

systemctl status clickhouse-server
  • 1

3.查看集群状态

clickhouse-client --host="127.0.0.1" --port="9000" --user="enic" --password="12345678"
  • 1
select * from system.clusters where cluster = 'enic_cluster';
  • 1
SELECT *FROM system.clustersWHERE cluster = 'enic_cluster'Query id: eb2064de-92f3-41b0-ac74-6b025d5082a1┌─cluster──────┬─shard_num─┬─shard_weight─┬─replica_num─┬─host_name─────┬─host_address──┬─port─┬─is_local─┬─user────┬─default_database─┬─errors_count─┬─slowdowns_count─┬─estimated_recovery_time─┐│ enic_cluster │         111192.168.11.11192.168.11.1190000default │                  │            000 ││ enic_cluster │         211192.168.11.12192.168.11.1290001default │                  │            000 ││ enic_cluster │         311192.168.11.13192.168.11.1390000default │                  │            000 │└──────────────┴───────────┴──────────────┴─────────────┴───────────────┴───────────────┴──────┴──────────┴─────────┴──────────────────┴──────────────┴─────────────────┴─────────────────────────┘3 rows in set. Elapsed: 0.002 sec. 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

4.集群操作

创建本地表

CREATE TABLE enic_test_local ON CLUSTER enic_cluster (id Int16,name String,birth Date)ENGINE = MergeTree()PARTITION BY toYYYYMM(birth)ORDER BY id;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
insert into enic_test_local values(1, 'test1', '2022-02-01'), (2, 'test2', '2022-03-01'), (3, 'test3', '2022-04-01');
  • 1
select * from enic_test_local;
  • 1

创建分布式表

CREATE TABLE default.enic_test ON CLUSTER enic_cluster as enic_test_local engine = Distributed(enic_cluster, default, enic_test_local,rand());
  • 1
CREATE TABLE default.enic_test ON CLUSTER enic_cluster AS enic_test_localENGINE = Distributed(enic_cluster, default, enic_test_local, rand())Query id: 22bc54a5-a615-4756-9132-a76b65bc5664┌─host──────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐│ 192.168.11.1390000 │       │                   20 ││ 192.168.11.1290000 │       │                   10 ││ 192.168.11.1190000 │       │                   00 │└───────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘3 rows in set. Elapsed: 0.128 sec. 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
insert into enic_test values(1, 'test1', '2022-02-01'), (2, 'test2', '2022-03-01'), (3, 'test3', '2022-04-01');
  • 1
INSERT INTO enic_test FORMAT ValuesQuery id: efd75f9f-c101-4d7f-91ae-448bea1a3aa9Ok.3 rows in set. Elapsed: 0.005 sec.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

其他节点查询

select * from enic_test;
  • 1
SELECT *FROM enic_testQuery id: 2e74c5b6-b16f-41ef-888d-ea2e6047d6a9┌─id─┬─name──┬──────birth─┐│  1 │ test1 │ 2022-02-01 │└────┴───────┴────────────┘┌─id─┬─name──┬──────birth─┐│  2 │ test2 │ 2022-03-01 │└────┴───────┴────────────┘┌─id─┬─name──┬──────birth─┐│  3 │ test3 │ 2022-04-01 │└────┴───────┴────────────┘┌─id─┬─name──┬──────birth─┐│  1 │ test1 │ 2022-02-01 │└────┴───────┴────────────┘┌─id─┬─name──┬──────birth─┐│  3 │ test3 │ 2022-04-01 │└────┴───────┴────────────┘┌─id─┬─name──┬──────birth─┐│  2 │ test2 │ 2022-03-01 │└────┴───────┴────────────┘6 rows in set. Elapsed: 0.007 sec. 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

以上,完成clickhouse 3shard1replica集群部署。

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发