Ubuntu14.04下Elasticsearch 5.6.5无法启动求助
Hey there, let’s work through this Elasticsearch startup issue step by step. I’ve debugged similar problems with ES 5.x on Ubuntu 14.04 before, so let’s break down the most likely fixes:
1. Verify Directory Permissions First
Elasticsearch runs as the elasticsearch user, so we need to make sure all critical directories are owned by this user/group. Run this command to check:
ls -ld /var/log/elasticsearch /var/lib/elasticsearch /usr/share/elasticsearch
If any directory shows ownership other than elasticsearch:elasticsearch, fix it with:
sudo chown -R elasticsearch:elasticsearch /var/log/elasticsearch /var/lib/elasticsearch /usr/share/elasticsearch
This is a super common cause of silent failures—if the user can’t write logs or data, ES will die without a trace.
2. Disable Daemon Mode to See Real-Time Errors
You’re using the -d flag to run ES in the background, which hides all startup output. Let’s run it in the foreground to capture errors directly:
sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch -Edefault.path.logs=/var/log/elasticsearch -Edefault.path.data=/var/lib/elasticsearch -Edefault.path.conf=/etc/elasticsearch
This will print any startup errors (like JVM issues, invalid configs, or missing dependencies) right to your terminal—this is the fastest way to pinpoint the root cause.
3. Fix System Limits for Elasticsearch
Ubuntu 14.04 has strict default limits that can block ES from starting. Edit /etc/security/limits.conf and add these lines at the bottom:
elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited elasticsearch soft nofile 65536 elasticsearch hard nofile 65536
Then edit /etc/pam.d/common-session and add this line to ensure limits are applied:
session required pam_limits.so
Reboot your system or log out and back in for these changes to take effect. ES needs high file descriptor limits and memory locking to run properly.
4. Adjust Kernel Virtual Memory Setting
ES 5.x requires a minimum vm.max_map_count of 262144 (Ubuntu’s default is too low). Run this to set it temporarily:
sudo sysctl -w vm.max_map_count=262144
To make it permanent, add this line to /etc/sysctl.conf:
vm.max_map_count=262144
Then run sudo sysctl -p to apply the change immediately.
5. Validate Java Version
Elasticsearch 5.6 only works with Java 8 (Oracle JDK or OpenJDK 8). Check your current Java version with:
java -version
If you’re running Java 9 or later, you’ll need to install OpenJDK 8:
sudo apt-get install openjdk-8-jdk sudo update-alternatives --config java
Select OpenJDK 8 from the menu that appears.
6. Double-Check elasticsearch.yml Config
A typo or invalid setting in your config file can cause silent failures. Key things to verify:
network.host: Set this tolocalhostor a valid IP for your server (ES 5.x binds tolocalhostby default, but if you changed it incorrectly, it can fail)cluster.nameandnode.name: Ensure these don’t contain special characters or spacespath.dataandpath.logs: Confirm these match the paths you’re passing via command line (they should already be set correctly from your apt install, but it’s worth checking)
Start with step 2 first—running ES in the foreground will almost certainly show you exactly what’s wrong. Once you fix that, the other steps will help ensure it runs reliably long-term.
内容的提问来源于stack exchange,提问作者Jimmy Stone

