美文网首页
工作日记:Windows下部署ES

工作日记:Windows下部署ES

作者: stramt | 来源:发表于2019-10-10 11:19 被阅读0次

    项目背景:

    项目中本来是用MySQL已经足够是用了,但是前几天客户提出需要能够在他们的稿件库中的文章中搜索出需要的内容,考虑到这里是用MySQL的全文检索效率比较低下,就准备使用ES来解决这个问题,因为客户的服务器都是Windows2012,因此这里暂时只记录Windows环境下ES的部署。

    开始部署:

    ES:

    1.前提:这里部署的ES版本是5.6.9(为什么使用5.6.9而不使用7.x,后续有说明),需要先安装jdk1.8
    2.下载ES:
    https://www.elastic.co/downloads/elasticsearch

    image.png
    3.安装:
    下载解压即可,进入安装文件夹bin目录,cmd 输入elasticsearch.bat启动
    image.png
    es目录结构:
    image.png

    4.访问:
    http://localhost:9200

    image.png
    name:节点名称
    cluster_name:集群名称
    version:版本信息
    5.配置文件:
    es目录下config文件夹里的elasticsearch.yml
    image.png
    这里是单机部署下,对yml修改不大
    #
    # NOTE: Elasticsearch comes with reasonable defaults for most settings.
    #       Before you set out to tweak and tune the configuration, make sure you
    #       understand what are you trying to accomplish and the consequences.
    #
    # The primary way of configuring a node is via this file. This template lists
    # the most important settings you may want to configure for a production cluster.
    #
    # Please consult the documentation for further information on configuration options:
    # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
    #
    # ---------------------------------- Cluster -----------------------------------
    #
    # Use a descriptive name for your cluster:
    #
    cluster.name: my-application
    #
    # ------------------------------------ Node ------------------------------------
    #
    # Use a descriptive name for the node:
    #
    node.name: node-1
    #
    # Add custom attributes to the node:
    #
    #node.attr.rack: r1
    #
    # ----------------------------------- Paths ------------------------------------
    #
    # Path to directory where to store the data (separate multiple locations by comma):
    #
    #path.data: /path/to/data
    #
    # Path to log files:
    #
    #path.logs: /path/to/logs
    #
    # ----------------------------------- Memory -----------------------------------
    #
    # Lock the memory on startup:
    #
    #bootstrap.memory_lock: true
    #
    # Make sure that the heap size is set to about half the memory available
    # on the system and that the owner of the process is allowed to use this
    # limit.
    #
    # Elasticsearch performs poorly when the system is swapping the memory.
    #
    # ---------------------------------- Network -----------------------------------
    #
    # Set the bind address to a specific IP (IPv4 or IPv6):
    #
    network.host: 0.0.0.0
    #
    # Set a custom port for HTTP:
    #
    http.port: 9200
    #
    # For more information, consult the network module documentation.
    #
    # --------------------------------- Discovery ----------------------------------
    #
    # Pass an initial list of hosts to perform discovery when new node is started:
    # The default list of hosts is ["127.0.0.1", "[::1]"]
    #
    #discovery.zen.ping.unicast.hosts: ["host1", "host2"]
    #
    # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
    #
    #discovery.zen.minimum_master_nodes: 3
    #
    # For more information, consult the zen discovery module documentation.
    #
    # ---------------------------------- Gateway -----------------------------------
    #
    # Block initial recovery after a full cluster restart until N nodes are started:
    #
    #gateway.recover_after_nodes: 3
    #
    # For more information, consult the gateway module documentation.
    #
    # ---------------------------------- Various -----------------------------------
    #
    # Require explicit names when deleting indices:
    #
    #action.destructive_requires_name: true
    #开启跨域访问
    http.cors.enabled: true 
    #allow-origin设置应该是一个正则表达式,它与托管站点插件的Web服务器的地址相匹配。
    http.cors.allow-origin: "*"
    #master角色和数据角色设置
    node.master: true
    node.data: true
    

    6.将es添加到服务中


    image.png

    安装 elasticsearch-service.bat install
    删除 elasticsearch-service.bat remove
    启动 elasticsearch-service.bat start
    停止 elasticsearch-service.bat stop

    Kibana

    1.下载:
    选择和ES相同的版本
    https://www.elastic.co/cn/downloads/kibana
    2.安装:
    在解压文件bin目录下 cmd kibana.bat

    image.png
    访问地址:http://localhost:5601
    image.png
    image.png

    ES-head

    1.下载:
    node-js:https://nodejs.org/en/download/
    es-head:https://github.com/mobz/elasticsearch-head
    2.安装:
    node-js安装之后,在es的根目录 cmd 输入 node -v 和 npm -v

    image.png
    将es-head克隆到es根目录下:
    image.png
    cd es-head
    cmd npm install -g grunt-cli
    npm install
    3.修改配置文件:
    image.png
    image.png
    image.png
    image.png
    image.png
    最后 npm run start
    访问地址:http://localhost:9100
    image.png

    IK分词器

    1.下载:
    https://github.com/medcl/elasticsearch-analysis-ik/releases
    选择与ES相同的版本
    在es plugins文件夹下新建ik文件夹 然后将解压后的文件复制进去

    image.png
    image.png
    重启ES即可

    相关文章

      网友评论

          本文标题:工作日记:Windows下部署ES

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