Elasticsearch的学习和理解:环境安装配置

Posted 默慊$

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Elasticsearch的学习和理解:环境安装配置相关的知识,希望对你有一定的参考价值。

因为博主自己进行的是Windows操作系统的安装和学习,所以本文只讲下Windows操作系统下Elasticsearch的环境安装配置,需要其他环境的可以查看官方文档,下载对于的安装包。

安装Elasticsearch的步骤如下 -

第1步 - 查看安装在计算机上的java的最低版本,它要求java 7或以上或最新的版本。可以通过执行以下操作进行检查 -

在Windows操作系统(OS)(使用命令提示符) -

java -version

第2步 - 从 www.elastic.co 下载最新的 Elasticsearch,注意选择对应版本 -

  • 对于Windows操作系统,请下载ZIP文件。

第3步 - Elasticsearch的安装过程非常容易,下面介绍在不同的操作系统如何安装 -

  • Windows操作系统 − 解压缩zip包,并安装Elasticsearch

第4步 - 进入到Elasticsearch主目录和bin文件夹。在Windows系统下可运行elasticsearch.bat文件

点击启动 ElasticSearch -

[2021-10-09T17:10:46,832][INFO ][o.e.n.Node               ] [] initializing ...
[2021-10-09T17:10:46,928][INFO ][o.e.e.NodeEnvironment    ] [ugCU7Fv] using [1] data paths, mounts [[(D:)]], net usable_space [256.4gb], net total_space [365gb], spins? [unknown], types [NTFS]
[2021-10-09T17:10:46,929][INFO ][o.e.e.NodeEnvironment    ] [ugCU7Fv] heap size [1.9gb], compressed ordinary object pointers [true]
[2021-10-09T17:10:46,991][INFO ][o.e.n.Node               ] node name [ugCU7Fv] derived from node ID [ugCU7FvTRxGH4c-OHDqYEg]; set [node.name] to override
[2021-10-09T17:10:46,993][INFO ][o.e.n.Node               ] version[5.2.0], pid[10340], build[24e05b9/2017-01-24T19:52:35.800Z], OS[Windows 10/10.0/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2021-10-09T17:10:47,498][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [aggs-matrix-stats]
[2021-10-09T17:10:47,499][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [ingest-common]
[2021-10-09T17:10:47,499][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [lang-expression]
[2021-10-09T17:10:47,499][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [lang-groovy]
[2021-10-09T17:10:47,499][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [lang-mustache]
[2021-10-09T17:10:47,499][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [lang-painless]
[2021-10-09T17:10:47,500][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [percolator]
[2021-10-09T17:10:47,500][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [reindex]
[2021-10-09T17:10:47,500][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [transport-netty3]
[2021-10-09T17:10:47,500][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] loaded module [transport-netty4]
[2021-10-09T17:10:47,501][INFO ][o.e.p.PluginsService     ] [ugCU7Fv] no plugins loaded
[2021-10-09T17:10:49,483][INFO ][o.e.n.Node               ] initialized
[2021-10-09T17:10:49,483][INFO ][o.e.n.Node               ] [ugCU7Fv] starting ...
[2021-10-09T17:10:51,105][INFO ][o.e.t.TransportService   ] [ugCU7Fv] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2021-10-09T17:10:54,176][INFO ][o.e.c.s.ClusterService   ] [ugCU7Fv] new_master {ugCU7Fv}{ugCU7FvTRxGH4c-OHDqYEg}{v3MaCtsIRTqZFtZuo2BDhg}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined)
[2021-10-09T17:10:54,344][INFO ][o.e.g.GatewayService     ] [ugCU7Fv] recovered [2] indices into cluster_state
[2021-10-09T17:10:54,602][INFO ][o.e.c.r.a.AllocationService] [ugCU7Fv] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[movies][1]] ...]).
[2021-10-09T17:10:55,324][INFO ][o.e.h.HttpServer         ] [ugCU7Fv] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2021-10-09T17:10:55,324][INFO ][o.e.n.Node               ] [ugCU7Fv] started

在启动过程中,ElasticSearch的实例运行会占用大量的内存,所以在这一过程中,电脑会变得比较慢,需要耐心等待,启动加载完成后电脑就可以正常使用了。

如果您没有安装Java运行时或没有正确配置,应该不会看到像上面的输出,而是一个消息说“JAVA_HOME环境变量必须设置!“ 要解决这个问题,首先下载并安装Java,其次,确保已正确配置JAVA_HOME环境变量(或参考 - Java JDK安装和配置)。

第5步 - Elasticsearch Web界面的默认端口是9200,或者可以通过更改bin目录中的elasticsearch.yml文件中的http.port字段值来更改。可以通过浏览http://localhost:9200来检查服务器是否已启动并正在运行。如果没有问题,它将返回一个JSON对象,其中包含有关安装的Elasticsearch信息有以下方式 -

{
   "name" : "Brain-Child",
   "cluster_name" : "elasticsearch", "version" : {
      "number" : "5.1.0",
      "build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",
      "build_timestamp" : "2015-11-18T22:40:03Z",
      "build_snapshot" : false,
      "lucene_version" : "5.3.1"
   },
   "tagline" : "You Know, for Search"
}

这样基本的环境就搞定了,下一篇再说下我学习使用的Sense插件,专门用于使用ElasticSearch的REST API的简单用户界面!
 

以上是关于Elasticsearch的学习和理解:环境安装配置的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch学习-----第二章 windows环境下Elasticsearch同步mysql数据库

Elasticsearch源码解析:环境搭建

Elasticsearch - 尚硅谷(5. Elasticsearch 环境)学习笔记

elasticsearch系列windows安装和配置elasticSearch7.8.0

elasticsearch学习安装和配置

ElasticSearch学习笔记--1安装以及运行