win10安装和使用 Elasticsearch 7.8.0

2020/07/05 大数据

此文首发于我的Jekyll博客:zhang0peter的个人博客


准备工作

Elasticsearch 基于Java,但从 Elasticsearch 7.0开始,程序内置了Java环境,不需要额外配置Java环境。

下载Elasticsearch

Elasticsearch 官网:Download Elasticsearch Free | Get Started Now | Elastic | Elastic

当前最新版本为7.8.0,下载windows版本的二进制包,解压。

启动Elasticsearch单机伪集群

运行bin/elasticsearch.bat

访问网页,查看运行状态http://127.0.0.1:9200/

{
  "name" : "MATEBOOK-X",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "7N2A6dVST_aF61K34rxA1w",
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "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"
}

访问http://127.0.0.1:9200/_cat/nodes查看节点情况:

>127.0.0.1 11 64 18    dilmrt * MATEBOOK-X

安装 Elasticsearch 插件

bin/elasticsearch-plugin.bat install analysis-icu

如果网络不好,可以先下载到本地再安装:

wget https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-7.8.0.zip
bin/elasticsearch-plugin.bat install file:///C:/Users/peter/Downloads/analysis-icu-7.8.0.zip

重启节点,查看插件安装情况:http://127.0.0.1:9200/_cat/plugins

>MATEBOOK-X analysis-icu 7.8.0

单机启动多Elasticsearch实例

关闭之前的运行的脚本,指定节点名和日志路径,运行集群

bin/elasticsearch.bat -E node.name=node1 -E cluster.name=zhang -E path.data=node1_data -d
bin/elasticsearch.bat -E node.name=node2 -E cluster.name=zhang -E path.data=node2_data -d
bin/elasticsearch.bat -E node.name=node3 -E cluster.name=zhang -E path.data=node3_data -d

-d表示后台运行。

访问网页,查看运行状态http://127.0.0.1:9200/

{
  "name" : "node1",
  "cluster_name" : "zhang",
  "cluster_uuid" : "qlvJehatSJmcj9Ug113Jrg",
  "version" : {
    "number" : "7.8.0",
    "build_flavor" : "default",
    "build_type" : "zip",
    "build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
    "build_date" : "2020-06-14T19:35:50.234439Z",
    "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"
}

访问http://127.0.0.1:9200/_cat/nodes查看节点情况:

>127.0.0.1 52 86 25    dilmrt - node3
127.0.0.1 60 86 25    dilmrt * node1
127.0.0.1 60 86 25    dilmrt - node2

需要注意的是默认9200端口是node1节点,后续节点的端口是9201和9202.