You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker部署Cassandra节点无法显示UJ/UN状态求助

Alright, let's troubleshoot why your second Cassandra node isn't joining the cluster—no UJ (Up-Joining) or UN (Up-Normal) status is definitely a head-scratcher. Let's walk through the most common issues step by step, since you're running this on Ubuntu VMs with Docker:

1. Verify Cross-VM Network Connectivity

First, rule out network issues—this is the #1 culprit for cluster join failures:

  • Test basic reachability between VMs using their private IPs (avoid localhost or public IPs for cluster communication):
    • From the seed node VM: ping <second-node-private-ip>
    • From the second node VM: ping <seed-node-private-ip>
  • Validate that Cassandra's critical ports are open and accessible:
    • Required ports: 7000 (Gossip), 9042 (CQL), 7199 (JMX)
    • Use netcat to test port access from the second node: nc -zv <seed-node-private-ip> 7000
  • Check Ubuntu's UFW firewall: Run sudo ufw status on both VMs. If active, either disable it temporarily (sudo ufw disable) or add rules to allow the above ports.

2. Double-Check Cassandra.yaml Configurations

Mismatched or incorrect configs will break cluster formation—pay close attention to these settings:

On the Seed Node Container:

  • Ensure seed_provider lists only its own private IP (keep it simple for initial setup):
    seed_provider:
      - class_name: org.apache.cassandra.locator.SimpleSeedProvider
        parameters:
            - seeds: "<seed-node-private-ip>"
    
  • Set listen_address to the seed node's private IP (not 0.0.0.0 for clarity):
    listen_address: <seed-node-private-ip>
    
  • Confirm cluster_name is set to a consistent value (e.g., "MyCassandraCluster").

On the Second Node Container:

  • Critical: seed_provider must point to the seed node's private IP (not its own):
    seed_provider:
      - class_name: org.apache.cassandra.locator.SimpleSeedProvider
        parameters:
            - seeds: "<seed-node-private-ip>"
    
  • listen_address should be set to the second node's private IP.
  • cluster_name must be exactly identical to the seed node's—even a case typo (e.g., "mycluster" vs "MyCluster") will prevent joining.
  • Ensure endpoint_snitch matches the seed node (default is SimpleSnitch, which works for single-data-center setups).

3. Validate Docker Runtime Settings

Since you're using Docker, incorrect network or environment variable settings can isolate the node:

  • Use --network host when starting containers to leverage the VM's network stack (this avoids Docker bridge network restrictions for cross-VM communication):
    Seed node run command:
    docker run -d --name cassandra-seed --network host \
      -e CASSANDRA_SEEDS="<seed-node-private-ip>" \
      -e CASSANDRA_LISTEN_ADDRESS="<seed-node-private-ip>" \
      -e CASSANDRA_CLUSTER_NAME="MyCassandraCluster" \
      cassandra:<your-exact-version>
    
    Second node run command:
    docker run -d --name cassandra-node2 --network host \
      -e CASSANDRA_SEEDS="<seed-node-private-ip>" \
      -e CASSANDRA_LISTEN_ADDRESS="<second-node-private-ip>" \
      -e CASSANDRA_CLUSTER_NAME="MyCassandraCluster" \
      cassandra:<your-exact-version>
    
  • Never mix Cassandra versions: Ensure both containers use the same image tag (e.g., cassandra:4.1.3—no mixing 4.x and 3.x versions).

4. Dig Into Cassandra Logs for Clues

Logs will tell you exactly what's going wrong. On the second node, tail the system log:

docker exec -it cassandra-node2 tail -f /var/log/cassandra/system.log

Look for these common error messages:

  • Unable to gossip with any seeds: Points to network or seed IP misconfiguration.
  • Cluster name mismatch: Exact typo or value difference between nodes.
  • Gossip stage has pending tasks: Network latency or firewall blocking gossip traffic.
  • Invalid token range: Manual token configuration errors (auto-token generation is recommended for small clusters).

5. Check Node Status Properly

  • Wait 2-3 minutes for gossip to propagate before checking status—Cassandra doesn't sync instantaneously.
  • Run nodetool status on both nodes: The second node might show itself as UN even if the seed node hasn't updated yet (and vice versa).
  • If the second node shows DN (Down-Normal), it's unreachable from the seed node—circle back to network/firewall checks.

6. Final Checks: Time Sync & Resource Limits

  • Cassandra relies on accurate system time. Ensure both VMs have synced clocks using ntp or chrony: Run timedatectl to verify NTP is active and times are within 1-2 seconds of each other.
  • Check container resource limits: Ensure both containers have enough memory (Cassandra needs at least 2GB of RAM to run reliably). Use docker stats to verify resource usage.

内容的提问来源于stack exchange,提问作者user9371612

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:00:33