zoukankan      html  css  js  c++  java
  • elasticsearch 安装之docker 单机

    一、es7 安装

    1、安装好docker 

      不赘述

    2、搜索镜像

    docker search elasticsearch  

     如果出现以下报错

    Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
    

    执行以下代码

    systemctl daemon-reload
    sudo service docker restart

    3、拉取镜像(我这里拉取的是5.6版本的)

    docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.1

    4、查看镜像

    [root@host1 bin]# docker images
    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    docker.elastic.co/elasticsearch/elasticsearch   7.1.1               96dd1575de0f        2 months agoo 

      

    5、启动镜像(我在这里使用了 -e 限制内存大小  752be83a5396是上面查询的镜像ID)

    docker run -d --name es -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.1.1

      

    6、使用命令查看防火墙端口是否已经开放

    firewall-cmd --list-port 

      如果结果中没有看到9200和9300端口,需要开放这两个端口,使用以下命令

    7、开放相关端口

    firewall-cmd --zone=public --add-port=9200/tcp --permanent 
    firewall-cmd --zone=public --add-port=9300/tcp --permanent 

     重启防火墙

    firewall-cmd --reload

      

    打开谷歌浏览器访问

    服务器IP:9200
    

    出现以下内容

    {
      "name" "bfc29f5a8f8c",
      "cluster_name" "docker-cluster",
      "cluster_uuid" "9dtJwBrNTwCHnbewPETxhw",
      "version" : {
        "number" "7.1.1",
        "build_flavor" "default",
        "build_type" "docker",
        "build_hash" "7a013de",
        "build_date" "2019-05-23T14:04:00.380842Z",
        "build_snapshot" false,
        "lucene_version" "8.0.0",
        "minimum_wire_compatibility_version" "6.8.0",
        "minimum_index_compatibility_version" "6.0.0-beta1"
      },
      "tagline" "You Know, for Search"
    }

    说明安装成功

    二、es界面管理工具elasticHD

    docker run -p 9800:9800 -d --link elasticsearch:demo containerize/elastichd

    三、Docker部署ik中文分词插件

    1、进入es容器内部,/plugins下新建ik文件夹

    [root@iZwz99dhxbd6xwly17tb3bZ ~]# docker exec -it es /bin/bash
    [root@970f612c5cac elasticsearch]# ls
    LICENSE.txt  NOTICE.txt  README.textile  bin  config  data  lib  logs  modules  plugins
    [root@970f612c5cac elasticsearch]# cd plugins/
    [root@970f612c5cac plugins]# mkdir ik
    [root@970f612c5cac plugins]# ls
    ik  ingest-geoip  ingest-user-agent

    2、下载与es对应版本的ik压缩包,并解压

    这一步有的人服务器不支持zip所以解压不了。我是从电脑上解压后弄成tar.gz文件上传到服务器然后cp到容器内部对应文件夹下,命令   docker cp /tmp/elasticsearch-analysis-ik-7.1.1.tar.gz 40aeef081297:/usr/share/elasticsearch/plugins/tk

    下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

    [root@970f612c5cac plugins]# cd ik
    [root@970f612c5cac ik]# wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip
    [root@970f612c5cac ik]# unzip elasticsearch-analysis-ik-7.1.1.zip
    [root@970f612c5cac ik]# ls
    commons-codec-1.9.jar    elasticsearch-analysis-ik-6.3.2.jar  plugin-descriptor.properties
    commons-logging-1.2.jar  httpclient-4.5.2.jar                 plugin-security.policy
    config                   httpcore-4.4.4.jar

    3、退出容器,重启es容器 

    [root@970f612c5cac ik]# exit
    exit
    [root@iZwz99dhxbd6xwly17tb3bZ ~]# docker restart es

    4、测试ik分词插件,postman请求以下参数

     ip:9200/_analyze?pretty=true

    {
    "analyzer": "ik_max_word",
    "text": "这是我拷贝来的,我是不是很厉害"
    }

    注意analyzer这个单词上下是不一样的

    感谢: https://www.cnblogs.com/hahahehexixihoho/p/11613524.html

  • 相关阅读:
    一张图告诉你为什么是服务网关,文末有现金抽奖。
    Java中的宏变量,宏替换详解。
    Java中创建String的两道面试题及详解
    JSON Web Token (JWT),服务端信息传输安全解决方案。
    jdk紧急漏洞,XMLDecoder反序列化攻击
    Java对象引用四个级别(强、软、弱、虚)
    Java7任务并行执行神器:Fork&Join框架
    (2)Django-pycharm部署
    批处理编写
    (1)Django安装
  • 原文地址:https://www.cnblogs.com/fclbky/p/13985791.html
Copyright © 2011-2022 走看看