前言
Elasticsearch 是一个分布式、高扩展、高实时的搜索与数据分析引擎,本身是使用Java语言开发,基于 Lucense 实现所有的索引和搜索功能,能处理PB级别的数据,采用 RESTful 风格进行访问。
安装 Elasticsearch
前提条件: 操作系统已安装对应版本 JDK
注意事项:
如果安装的版本比较旧,有可能遇到无法启动的问题,但 Elasticsearch 后面集成了内部JDK,启动时如果版本不匹配,就会使用内部JDK版本
1、访问 Elasticsearch 官网下载地址, 我选用 windows 版本
下载完成直接解压到您的安装目录即可 【D:\software\elasticsearch】
启动 Elasticsearch
命令 cmd 进入安装目录【D:\software\elasticsearch\elasticsearch-8.4.3】,执行命令或双击bin目录下的 elasticsearch.bat
start bin\elasticsearch.bat
启动成功!!!
浏览器访问 http://localhost:9200 ,可以看到 Elasticsearch 具体信息。
问题汇总
Elasticsearch 启动闪退
我当前操作系统是 windows 哈!,按 win 直接 cmd,进入 ES 安装目录的 bin 文件夹
问题:
Exception in thread “main” java.lang.UnsupportedOperationException: The Security Manager is deprecated and will be removed in a future release
at java.base/java.lang.System.setSecurityManager(System.java:416)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82)
解决方案:
更换 JDK 的版本!!!
所以,我升级 JDK的版本,更改系统环境变量 JAVA_HOME,具体可以您使用哪个JDK版本,可以参考ES下面的对照表哈!最后,重启执行 elasticsearch.bat
参考文档:Elasticsearch Issue#85665 ,Elasticsearch和JVM的版本对照表
其它可能问题:
- 跨域问题,在ES 安装目录的 conf 文件夹下 jvm.options 增加设置
http.cors.enabled: true
http.cors.allow-origin: "*"
network.host: 0.0.0.0
- 空间不足,在ES 安装目录的 conf 文件夹下 jvm.options 设置大小
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms2g
-Xmx2g
重启 Elasticsearch 即可!