Cassandra 2.1.13启动中途机器重启后cassandra.yaml为空的根因排查
Let me break this down clearly for you: the startup exceptions you're seeing are directly caused by the empty cassandra.yaml file—the reverse (the exception emptying the config) is impossible. Here's the breakdown:
First, look at your error stack trace:
ERROR [main] DatabaseDescriptor.java:147 - Fatal error during configuration loading
java.lang.NullPointerException: null
at java.util.TreeMap.putAll(TreeMap.java:313) ~[na:1.8.0_172]
at java.util.TreeMap.(TreeMap.java:185) ~[na:1.8.0_172]
at org.apache.cassandra.config.YamlConfigurationLoader.logConfig(YamlConfigurationLoader.java:126) ~[apache-cassandra-2.1.13.jar:2.1.13]
When Cassandra tries to load an empty YAML file, the parser returns a null configuration map. The logConfig method then attempts to create a TreeMap by passing this null map to putAll, which immediately triggers the NullPointerException. The subsequent ExceptionInInitializerError is just a secondary failure—since the core DatabaseDescriptor can't initialize without valid config.
Now, why is cassandra.yaml empty? Cassandra never modifies or empties this static config file during normal startup, even if it hits errors later in the process. The empty file is almost certainly a side effect of the unexpected machine reboot:
- The abrupt shutdown might have interrupted a disk write operation (unlikely for the static config, but possible if an unrelated process was touching it)
- File system corruption from the forced reboot could have truncated the file
- Low-level disk/IO errors during the reboot might have corrupted the file's contents
Steps to Validate & Troubleshoot
- Restore a backup config: If you have a
cassandra.yaml.bak(common in Cassandra installs) or a copy from another node, replace the empty file and try starting Cassandra again. It should boot normally if the empty config was the only issue. - Check file system health: Run a file system check (e.g.,
e2fsckfor ext4 systems) to rule out corruption caused by the sudden reboot. - Review system logs: Check your OS logs (like
/var/log/messagesordmesg) for disk errors, OOM kills, or other system-level issues around the time of the reboot—these might explain why the config file was truncated. - Check pre-reboot Cassandra logs: Look at older system logs (e.g.,
system.log.1) to confirm Cassandra wasn't running any config-modifying operations (note: in 2.1.13,nodetooldoesn't edit the static YAML file, so this is unlikely).
内容的提问来源于stack exchange,提问作者Neuron

