Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Install Elasticsearch and Kibana via Docker

Tech 1

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

  1. 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:

  1. Enter the Kibana container (replace d1d with 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`.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.