Docker installation elasticsearch

Time:2022-1-15
1. Pull the official elasticsearch image from dockerhub

Official warehouse:https://hub.docker.com/

docker pull elasticsearch:7.10.1
2. Create and authorize the container mount directory, and persist the container data and configuration

Create three directories to mount configuration config, data and plug-in plugins respectively

mkdir -p /elasticsearch/data 
mkdir -p /elasticsearch/config 
mkdir -p /elasticsearch/plugins 

Grant read / write execution permission

chmod -R 777 /elasticsearch
3. Create docker compose YML file, using docker compose to start the container

The ES memory usage can be specified in the environment variable

version: '2'
services:
  elasticsearch:
    container_name: elasticsearch
    image: elasticsearch:7.10.1
    ports:
      - "9200:9200"
    volumes:
      - /elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
      - /elasticsearch/data:/usr/share/elasticsearch/data
      - /elasticsearch/plugins:/usr/share/elasticsearch/plugins
    environment:
      - "ES_JAVA_OPTS=-Xms64m -Xmx512m"
      - "discovery.type=single-node"
      - "COMPOSE_PROJECT_NAME=elasticsearch-server"
    restart: always
4. Use docker compose at docker compose Start the container in the directory where YML is located
docker-compose up -d

Check whether the container started successfully

docker ps -a | grep elasticsearch 

Test access
curl http://192.168.0.50:9200/
return

{
  "name" : "37da3258e541",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "pxYI8abQQA-F7wKqP6cG3w",
  "version" : {
    "number" : "7.10.1",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "1c34507e66d7db1211f66f3513706fdf548736aa",
    "build_date" : "2020-12-05T01:00:33.671820Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

It worked~~~

Recommended Today

HTML H5 Vue websocket broken chain heartbeat personal note

let webSocket = null; let mAudio = null; let webSocketStateInterval = null; let heartInterval = null; let number = 3; let _ closeType = false; // True active hang up false passive hang up export default { initWebsocket() { let _that = this; let userInfo = JSON.parse(localStorage.getItem(“userInfo”)); let _url = process.env.VUE_APP_socketURL + userInfo.id; webSocket = […]