关于elasticsearch:Docker安装ElasticSearch

41次阅读

共计 1335 个字符,预计需要花费 4 分钟才能阅读完成。

1、从 dockerHub 拉取官网 ElasticSearch 镜像

官网仓库:https://hub.docker.com/

docker pull elasticsearch:7.10.1
2、创立容器挂载目录并受权,长久化容器数据和配置

创立三个目录别离挂载配置 config、数据 data、插件 plugins

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

授予读写执行权限

chmod -R 777 /elasticsearch
3、创立 docker-compose.yml 文件,应用 docker-compose 启动容器
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 -Xmx128m"
      - "discovery.type=single-node"
      - "COMPOSE_PROJECT_NAME=elasticsearch-server"
    restart: always
4、应用 docker-compose 在 docker-compose.yml 所在目录启动容器
docker-compose up -d

查看容器是否胜利启动

docker ps -a | grep elasticsearch 

测试拜访
curl http://192.168.0.50:9200/
返回

{
  "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"
}

胜利啦~~~

正文完
 0