• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Docker安装ElasticSearch

互联网 diligentman 6天前 5次浏览
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启动容器

环境变量中可以指定ES内存占用

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、使用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"
}

成功啦~~~


程序员灯塔
转载请注明原文链接:Docker安装ElasticSearch
喜欢 (0)