zoukankan      html  css  js  c++  java
  • Docker(五):Docker安装Elasticsearch

    查找ElasticSearch镜像

    镜像仓库

    https://hub.docker.com/
    

    下拉镜像

    docker pull elasticsearch:7.7.0
    

    查看镜像

    docker images
    

    创建Elasticsearch容器

    创建所需文件

    mkdir -p /mydata/elasticsearch/config
    
    mkdir -p /mydata/elasticsearch/data
    
    echo "http.host: 0.0.0.0">>/mydata/elasticsearch/config/elasticsearch.yml
    

    注意:http.host: 0.0.0.0 冒号后有一空格。

    文件夹赋权

    chmod -R 777 elasticsearch/
    

    命令启动

    docker run --name elasticsearch -p 9200:9200 
     -p 9300:9300 
     -e "discovery.type=single-node" 
     -e ES_JAVA_OPTS="-Xms64m -Xmx128m" 
      -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 
     -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data 
     -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins 
     -d elasticsearch:7.7.0
    

    参数说明

    --name elasticsearch:将容器命名为 elasticsearch
    -p 9200:9200:将容器的9200端口映射到宿主机9200端口
    -p 9300:9300:将容器的9300端口映射到宿主机9300端口,目的是集群互相通信
    -e "discovery.type=single-node":单例模式
    -e ES_JAVA_OPTS="-Xms64m -Xmx128m":配置内存大小
    -v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:将配置文件挂载到宿主机
    -v /mydata/elasticsearch/data:/usr/share/elasticsearch/data:将数据文件夹挂载到宿主机
    -v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins:将插件目录挂载到宿主机(需重启)
    -d elasticsearch:7.7.0:后台运行容器,并返回容器ID
    

    docker-compose启动

    version: '2'
    services:
      elasticsearch:
        container_name: elasticsearch
        image: elasticsearch:7.7.0
        ports:
          - "9200:9200"
        volumes:
          - /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
          - /mydata/elasticsearch/data:/usr/share/elasticsearch/data
          - /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins
        environment:
          - "ES_JAVA_OPTS=-Xms64m -Xmx128m"
          - "discovery.type=single-node"
          - "COMPOSE_PROJECT_NAME=elasticsearch-server"
        restart: always
    

    查看容器

    docker ps -a
    

    验证是否成功

    curl http://192.168.0.50:9200/
    
    {
      "name" : "550eca5cf3b2",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "1mP9IJU3TUy_C2DZMfKGBg",
      "version" : {
        "number" : "7.7.0",
        "build_flavor" : "default",
        "build_type" : "docker",
        "build_hash" : "81a1e9eda8e6183f5237786246f6dced26a10eaf",
        "build_date" : "2020-05-12T02:01:37.602180Z",
        "build_snapshot" : false,
        "lucene_version" : "8.5.1",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    

    Docker启动容器自启

    docker update elasticsearch --restart=always
    
  • 相关阅读:
    root用户javac可以执行sudo后command not found问题
    机器学习 KNN算法实现 (鸢尾花)
    机器学习 KNN分类算法简单介绍+数据集拆分
    机器学习的一般流程
    机器学习算法的性能评价
    Opencv 自带函数(Haar)的人脸检测
    Opencv 的基础认识
    labelme 的学习
    天梯赛总结CCCC
    VScode配置c,c++编译环境
  • 原文地址:https://www.cnblogs.com/chinda/p/13125625.html
Copyright © 2011-2022 走看看