美文网首页
docker 安装Elasticsearch

docker 安装Elasticsearch

作者: 一切归零_e7be | 来源:发表于2020-08-07 10:04 被阅读0次

    docker镜像搜索:

    [root@master-1 ~]# docker search elasticsearch

    [root@master-1 ~]# docker pull elasticsearch:7.7.0

    运行docker镜像:

    -p 隐射端口

    -e 设置参数,discovery.type=single-node,设置单节点,ES_JAVA_OPTS="-Xms256m -Xmx256m",设置JVM参数

    -d 后台运行

    --name 节点名称

    [root@master-1 ~]# docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d --name ES01 elasticsearch:7.7.0

    访问http://192.168.1.217:9200

    进入docker 容器中:

    [root@master-1 ~]# docker exec -it 0bf67ecae8d0 /bin/bash

    config 目录下是集群配置文件

    data 目录是数据文件存储的地方

    进入容器后插件安装:

    [root@0bf67ecae8d0 elasticsearch]# cd plugins/

    [root@0bf67ecae8d0 plugins]# elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip

    [root@0bf67ecae8d0 plugins]# exit

    [root@master-1 ~]# docker restart 0bf67ecae8d0

    elasticsearch-head监控插件安装:

    [root@master-1 ~]# docker pull mobz/elasticsearch-head:5

    [root@master-1 ~]# docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5

    解决跨域问题:

    [root@master-1 ~]# docker exec -it 0bf67ecae8d0 /bin/bash

    [root@0bf67ecae8d0 elasticsearch]# ls

    LICENSE.txt  NOTICE.txt  README.asciidoc  bin  config  data  jdk  lib  logs  modules  plugins

    [root@0bf67ecae8d0 elasticsearch]# cd config/

    [root@0bf67ecae8d0 config]# ls

    analysis-ik  elasticsearch.keystore  elasticsearch.yml  jvm.options  jvm.options.d  log4j2.properties  role_mapping.yml  roles.yml  users  users_roles

    [root@0bf67ecae8d0 config]# vi elasticsearch.yml

    添加下面两句

    http.cors.enabled:true

    http.cors.allow-origin:"*"

    保存后重启容器

    [root@0bf67ecae8d0 config]# exit

    exit

    [root@master-1 ~]# docker restart 0bf67ecae8d0

    安装kibana:

    [root@master-1 ~]# docker pull kibana:7.7.0

    安装完成以后需要启动kibana容器,使用--link连接到elasticsearch容器

    [root@master-1 ~]# docker run --name kibana --link=ES01 -p 5601:5601 -d kibana:7.7.0

    [root@master-1 ~]# docker start kibana

    docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \

      -e  "discovery.type=single-node" \

      -e ES_JAVA_OPTS="-Xms256m -Xmx256m" \

    --restart=always \

    -v /home/liwu/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \

    -v /home/liwu/elasticsearch/data:/usr/share/elasticsearch/data \

    -v /home/liwu/elasticsearch/plugins:/usr/share/elasticsearch/plugins \

    -d elasticsearch:7.10.1

    相关文章

      网友评论

          本文标题:docker 安装Elasticsearch

          本文链接:https://www.haomeiwen.com/subject/osoxdktx.html