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

Cassandra nodetool连接失败求助:无法连接127.0.0.1:7199

Troubleshooting Cassandra Active (Exited) State & Nodetool Connection Refusal

Hey there, let's work through this Cassandra issue step by step—since you're new, we'll start with the most common culprits for this exact scenario. Your cassandra.service showing active (exited) means the service started up but immediately shut down, which explains why nodetool can't connect to the JMX port (7199). Here's what to check:

1. First, Check Cassandra's Startup Logs

The first place to look for clues is Cassandra's system log—it will tell you exactly why the service exited prematurely. Run this command to pull the latest 50 lines of the log:

tail -n 50 /var/log/cassandra/system.log

Look for error messages like port conflicts, invalid configuration, permission issues, or Java-related errors. This is the most critical step to pinpoint the root cause.

2. Verify Cassandra Configuration Files

a. Check JMX Port Settings

Nodetool uses JMX (port 7199) to communicate with Cassandra. Open the cassandra-env.sh file (usually at /etc/cassandra/cassandra-env.sh) and confirm the JMX port is set correctly:

nano /etc/cassandra/cassandra-env.sh

Look for a line like:

JMX_PORT="7199"

If it's commented out (starts with #), uncomment it. If the port is changed, you'll need to specify it when running nodetool: nodetool -p <new-port> status.

b. Validate Network Configurations

Open cassandra.yaml (at /etc/cassandra/cassandra.yaml) and check these settings:

  • listen_address: Should be set to 127.0.0.1 (for single-node setup on your VM) or the VM's private IP.
  • rpc_address: Same as above, or 0.0.0.0 to allow connections from localhost.
  • start_native_transport: Should be set to true.

3. Check if Port 7199 is Occupied

Another process might be using the JMX port. Run this command to check:

ss -tulpn | grep 7199

If you see another process listed, you can either kill that process (with kill <PID>) or change Cassandra's JMX port in cassandra-env.sh.

4. Confirm Java Environment is Correct

While you're using Java 1.8.0_161 (which is compatible with Cassandra 3.11.2), make sure Cassandra is using the right Java installation:

  • Check your JAVA_HOME variable:
    echo $JAVA_HOME
    
    It should point to your Java 8 installation (e.g., /usr/lib/jvm/java-8-openjdk-amd64).
  • Verify the active Java version matches:
    java -version
    
    If there are multiple Java versions on your system, ensure Cassandra is configured to use Java 8 (you can set this in cassandra-env.sh if needed).

5. Start Cassandra in Foreground to See Real-Time Errors

Instead of using the service manager, start Cassandra directly in the foreground to see immediate error output:

/usr/sbin/cassandra -f

This will print all startup logs to your terminal, making it easier to catch issues that might be hidden in the log file. Press Ctrl+C to stop it once you've identified the problem.

6. Fix File Permissions

Cassandra runs under the cassandra user, so ensure it has access to its data and log directories:

sudo chown -R cassandra:cassandra /var/lib/cassandra /var/log/cassandra

Incorrect permissions can prevent Cassandra from writing logs or data, causing it to exit immediately.

Once you've worked through these steps, restart the service with sudo systemctl restart cassandra and run nodetool status again. If you hit a specific error in the logs, feel free to share those details for more targeted help!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:47:04