Install Elasticsearch and Kibana via Docker
1. Pull Docker Images
Pull the specified version (7.12.0 here, adjust as needed) of Elasticsearch and Kibana images:
sudo docker pull elasticsearch:7.12.0
sudo docker pull kibana:7.12.0
2. Create Mount Directories
Create directories for Elasticsearch configuration, data, and plugins:
sudo mkdir -p /opt/es/config
sudo mkdir -p /opt/es/data
sudo mkdir -p /opt/es/plugins
3. Configure Elasticsearch
Add network access configuration to elasticsearch.yml:
echo "http.host: 0.0.0.0" >> /opt/es/config/elasticsearch.yml
4. Start Elasticsearch Container
Run the Elasticsearch container with port mapping, memory limits, and volume mounts:
sudo docker run --name es -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms128m -Xmx1024m" \
-v /opt/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /opt/es/data:/usr/share/elasticsearch/data \
-v /opt/es/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.12.0
Parameter Explanation:
-p:Map container ports too host (9200 for HTTP, 9300 for TCP).-e discovery.type=single-node:Start in single-node mode (no cluster).-e ES_JAVA_OPTS:Set JVM memory (example: 128M initial, 1G max; adjust as needed).-v:Mount host directories to the container for persistent config, data, and plugins.-d:Run the container in detached (background) mode.
Cotnainer Management Commands
- Check running status:
docker ps - View startup logs:
docker logs es - Restart the container:
docker restart es - Enter container terminal:
docker exec -it es bash
Common Installation Issues
- Permission Denied:If mount directories lack permissions, run:
sudo chmod -R 777 /opt/es/
2. **Config Format Error**:Ensure a space after `http.host` in `elasticsearch.yml` (e.g., `http.host: 0.0.0.0`).
3. **Insufficient Virtual Memory**:Adjust system parameters:
```bash
sudo sysctl -w vm.max_map_count=262144
Install Kibana
Start the Kibana container and specify the Elasticsearch address (replace with your ES host IP):
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.232.109:9200 -p 5601:5601 \
-d kibana:7.12.0
Troubleshoot Access Issues (e.g., Unable to revive connection)
If logs show connection failures too ES, fix the ES address in Kibana:
- Enter the Kibana container (replace
d1dwith the actual container ID):
docker exec -it d1d /bin/bash
2. Modify the Kibana config file (e.g., `/usr/share/kibana/config/kibana.yml`) to set the correct `elasticsearch.hosts`.