docker - cassandra 集群是否需要在 docker-compose 文件上进行额外配置才能连接单个集群上的三个节点?
问题描述
我目前正在尝试建立一个具有三个节点的 cassandra 集群,但它的正确功能是随机的,每次我设置 docker-compose 文件时,我使用 nodetool 状态时都不会出现复制节点。我是在文件上做错了什么,还是必须改进 cassandra?
编辑:忘了提我在 Windows 和 Ubuntu LTS 上试过这个 docker compose 文件
这是我正在使用的 docker-compose.yml:
version: '3'
services:
# The first node and config in the first datacenter.
node1:
image: cassandra:latest
container_name: coordinatorNode
hostname: node1
networks:
dc1ring:
ipv4_address: 172.30.0.2
volumes:
- ./musicdb:/opt/dse/musicdb
environment:
# - DS_LICENSE=accept
# - SEEDS=node1
# - START_RPC=false
# - CLUSTER_NAME=dse51_cluster
- CASSANDRA_BROADCAST_ADDRESS=172.30.0.2
# - NUM_TOKENS=3
# - DC=DC1
# - RACK=RAC1
# - MAX_HEAP_SIZE=1000000000
# - HEAP_NEWSIZE= 4096M
expose:
# Intra-node communication
- 7000
# TLS intra-node communication
- 7001
# JMX
- 7199
# CQL
- 9042
# CQL SSL
- 9142
ports:
- 9042:9042
ulimits:
memlock: -1
nproc: 32768
nofile: 100000
restart: always
node2:
image: cassandra:latest
container_name: replicantNode1
hostname: node2
networks:
dc1ring:
ipv4_address: 172.30.0.3
volumes:
- ./musicdb:/opt/dse/musicdb
environment:
# - DS_LICENSE=accept
- SEEDS=node1
# - START_RPC=false
# - CLUSTER_NAME=dse51_cluster
- CASSANDRA_BROADCAST_ADDRESS=172.30.0.3
- CASSANDRA_SEEDS=172.30.0.2,172.30.0.4
# - NUM_TOKENS=3
# - DC=DC1
# - RACK=RAC1
# - MAX_HEAP_SIZE=1000000000
# - HEAP_NEWSIZE= "4G"
expose:
- 7000
- 7001
- 7199
- 9042
- 9142
ports:
- 9043:9042
ulimits:
memlock: -1
nproc: 32768
nofile: 100000
depends_on:
- node1
restart: always
node3:
image: cassandra:latest
container_name: replicantNode2
hostname: node3
networks:
dc1ring:
ipv4_address: 172.30.0.4
volumes:
- ./musicdb:/opt/dse/musicdb
environment:
# - DS_LICENSE=accept
- SEEDS=node1
# - START_RPC=false
# - CLUSTER_NAME=dse51_cluster
- CASSANDRA_BROADCAST_ADDRESS=172.30.0.4
- CASSANDRA_SEEDS=172.30.0.2,172.30.0.3
# - NUM_TOKENS=3
# - DC=DC1
# - RACK=RAC1
# - MAX_HEAP_SIZE=1000000000
# - HEAP_NEWSIZE= "4G"
expose:
- 7000
- 7001
- 7199
- 9042
- 9142
ports:
- 9044:9042
ulimits:
memlock: -1
nproc: 32768
nofile: 100000
depends_on:
- node1
restart: always
networks:
dc1ring:
ipam:
driver: default
config:
- subnet: 172.30.0.0/16
解决方案
在 Docker 上部署多节点集群的部分挑战在于正确连接网络。如果我猜的话,我会说你遇到了两个问题之一:
- 节点之间不能八卦
- 容器遇到端口冲突
您需要确保Cassandra 使用的所有必要端口都在每个节点之间公开。
您还需要确保映射到容器端口的本地端口尚未被另一个容器使用。例如,节点 1 使用 CQL 端口和9041
gossip 端口,节点 2 使用+ ,等等。7001
9042
7002
如果您只想尝试在笔记本电脑上使用 Cassandra,请查看DataStax Desktop(免费使用)。它允许您在 Docker 容器中部署 Cassandra,而无需手动设置。
还有K8ssandra.io——我们使用 cass -operator在 Kubernetes 上部署 Cassandra(完全开源和免费),并且所有管理工具已经捆绑在:
- 用于自动维修的收割机
- 用于备份和恢复的美杜莎
- 使用 Prometheus + Grafana 进行监控的Metrics Collector
- k8s 集群入口的 Traefik 模板
- Stargate.io - 一个使用 REST API、GraphQL API 和 JSON/Doc API 连接到 Cassandra 的数据网关
最后,如果您只想为 Cassandra 构建应用程序,Astra DB有一个不需要信用卡的免费层,您只需单击 5 次即可启动 Cassandra 集群。
推荐阅读
- javascript - 找不到与搜索条件不匹配的表数据的“未找到匹配项”
- node.js - 在oracle中使用序列和绑定变量一起出错
- python - 如何将类的所有实例变量设为只读?
- ios - iOS图表可以围绕除中心以外的不同锚点旋转条形图x轴标签
- python - python请求多层代理
- javascript - 如何从前端从 Cognito 获取新令牌?
- javascript - About DOM elements internal indentifier
- azure - 确定 Microsoft Azure 中的虚拟机状态和活动
- google-chrome - 调试three.js时如何在断点处查看纹理的实际图像?
- solr - Solr 和时间码信息