简单的Clickhouse群集通过Docker中的Clickhouse-keeper
我正在尝试通过 clickhouse-keeper 进行设置和测试复制。
这是我的docker.compose.yaml
version: "3.7"
services:
clickhouse01:
image: yandex/clickhouse-server
container_name: clickhouse01
hostname: clickhouse01
ports:
- 8811:8123
- 9011:9000
volumes:
- "D:/clichhouse-data/volume1:/var/lib/clickhouse"
clickhouse02:
image: yandex/clickhouse-server
hostname: clickhouse02
container_name: clickhouse02
ports:
- 8812:8123
- 9012:9000
volumes:
- "D:/clichhouse-data/volume2:/var/lib/clickhouse"
是我在 /etc/clickhouse-server/config.xml 的 remote_servers 部分
<remote_servers>
<test_cluster_two_shards_localhost>
<shard>
<replica>
<host>clickhouse01</host>
<port>9000</port>
</replica>
<replica>
<host>clickhouse02</host>
<port>9000</port>
</replica>
</shard>
</test_cluster_two_shards_localhost>
</remote_servers>
这 我在 1st Node ,路径 - /etc/clickhouse-server/config.d/上使用的Keeper.xml 文件:
<clickhouse_keeper>
<keeper_server>
<tcp_port>9181</tcp_port>
<server_id>1</server_id>
<log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
<snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>
<coordination_settings>
<operation_timeout_ms>10000</operation_timeout_ms>
<session_timeout_ms>30000</session_timeout_ms>
<raft_logs_level>trace</raft_logs_level>
</coordination_settings>
<raft_configuration>
<server>
<id>1</id>
<hostname>clickhouse01</hostname>
<port>9234</port>
</server>
<server>
<id>2</id>
<hostname>clickhouse02</hostname>
<port>9234</port>
</server>
</raft_configuration>
</keeper_server>
</clickhouse_keeper>
这是 keeper.xml 我在第二个节点,路径 - /etc/clickhouse-server/config.d/:
<clickhouse_keeper>
<keeper_server>
<tcp_port>9181</tcp_port>
<server_id>2</server_id>
<log_storage_path>/var/lib/clickhouse/coordination/log</log_storage_path>
<snapshot_storage_path>/var/lib/clickhouse/coordination/snapshots</snapshot_storage_path>
<coordination_settings>
<operation_timeout_ms>10000</operation_timeout_ms>
<session_timeout_ms>30000</session_timeout_ms>
<raft_logs_level>trace</raft_logs_level>
</coordination_settings>
<raft_configuration>
<server>
<id>1</id>
<hostname>clickhouse01</hostname>
<port>9234</port>
</server>
<server>
<id>2</id>
<hostname>clickhouse02</hostname>
<port>9234</port>
</server>
</raft_configuration>
</keeper_server>
</clickhouse_keeper>
这是< strong> macros.xml 我在 1st节点,路径 - /etc/clickhouse-server/config.d/:
<clickhouse>
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
<macros>
<cluster>test_cluster_two_shards_localhost</cluster>
<replica>replica1</replica>
<shard>1</shard>
</macros>
</clickhouse>
这是 macros.xml 我在第二个节点,路径 - /etc/clickhouse-server/config.d/:
<clickhouse>
<distributed_ddl>
<path>/clickhouse/task_queue/ddl</path>
</distributed_ddl>
<macros>
<cluster>test_cluster_two_shards_localhost</cluster>
<replica>replica2</replica>
<shard>1</shard>
</macros>
</clickhouse>
此IS use-keeper.xml 我在每个节点上使用的文件,路径 - /etc/clickhouse-server/config.d/:
<clickhouse>
<zookeeper>
<node index="1">
<host>clickhouse01</host>
<port>9181</port>
</node>
<node index="2">
<host>clickhouse02</host>
<port>9181</port>
</node>
</zookeeper>
</clickhouse>
我可以看到预期的群集 system.clusters 表 system.clusers.clusters询问
但我没有具有 system.zookeeper 表 system.zookeeper Query
我也试图尝试检查守护者是否正在运行 Echo Ruok | NC 127.0.0.1 9181 - 没有答案。
参考:
- =“ nofollow noreferrer”> https://mrkaran.dev/posts/clickhouse-replication/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决。
我的错误是,我在运行容器后通过以下方式使用 cp 命令复制了整个配置:
docker cp'C:\ users \ {user} \ desktop \ ch cluster \ ch cluster \ node-1 \ config.xml'clickhouse01:/etc/clickhouse-server
我认为我需要运行使用默认配置,请单击“ server” ,然后在应用新配置后重新启动 clickhouse-server 内部容器。
因此,这是我理解如何应用和更改配置的问题。
更改:
因此,在启动上更新了配置。
Resolved.
My mistake was that I copied the entire configuration after running the containers by using cp command in the following way:
docker cp 'C:\Users\{user}\Desktop\CH cluster\node-1\config.xml' clickhouse01:/etc/clickhouse-server
I thought that I need to run clickhouse-server with default configuration and then restart the clickhouse-server inside container after applying new configuration.
So that, it was the issue with my understanding how I should apply and change configuration.
Changes:
And as a result configuration updated on the startup.