美文网首页Java软件开发技术
windows10安装elasticsearch搜索引擎

windows10安装elasticsearch搜索引擎

作者: 编程永无止境 | 来源:发表于2022-08-16 15:50 被阅读0次

简介

Elasticsearch 是一个实时的分布式搜索分析引擎, 它能让你以一个之前从未有过的速度和规模,去探索你的数据。 它被用作全文检索、结构化搜索、分析以及这三个功能的组合。

下载ElasticSearch

最新版下载地址:https://www.elastic.co/downloads/elasticsearch

为了配合中文分词插件的版本,这里我下载的是elasticsearch-8.2.3

https://www.elastic.co/cn/downloads/past-releases/elasticsearch-8-2-3

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.2.3-windows-x86_64.zip

安装ElasticSearch

在windows下的ElasticSearch是一个压缩包,所有的命令都是bat批处理文件。

解压缩以后执行bin目录里面的批处理文件就可以运行了

启动ElasticSearch

进入bin目录执行elasticsearch.bat

    $ cd D:\elasticsearch-8.2.3\bin
    $ elasticsearch.bat

第一次访问的时候注意看一下默认的账号和密码

    --------------------------------------------------------------------------------------------------
    
    -> Elasticsearch security features have been automatically configured!
    -> Authentication is enabled and cluster connections are encrypted.
    
    ->  Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
      SigIYaxY7vzARk5MqJ6p
    
    ->  HTTP CA certificate SHA-256 fingerprint:
      fe6c8aa23f21b1bf32ad564d12c0bddff6d55f4e152e467079aa9aa57c16daed
    
    ->  Configure Kibana to use this cluster:
    * Run Kibana and click the configuration link in the terminal when Kibana starts.
    * Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
      eyJ2ZXIiOiI4LjIuMyIsImFkciI6WyIxOTIuMTY4LjguMTo5MjAwIl0sImZnciI6ImZlNmM4YWEyM2YyMWIxYmYzMmFkNTY0ZDEyYzBiZGRmZjZkNTVmNGUxNTJlNDY3MDc5YWE5YWE1N2MxNmRhZWQiLCJrZXkiOiJfNGRXUG9JQnBRZExibW9IbFBuVzpWbmhjYmdqVlM2Q2VwMlNRZ0NIMVBnIn0=
    
    ->  Configure other nodes to join this cluster:
    * On this node:
      - Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
      - Uncomment the transport.host setting at the end of config/elasticsearch.yml.
      - Restart Elasticsearch.
    * On other nodes:
      - Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated.
    -----------------------------------------------------------------------------------

访问测试

https://localhost:9200
访问测试,看到提示需要密码。

image-20220727133013259.png

设置账号和密码

先不要关闭elasticsearch,然后新开一个CMD窗口,执行命令

$ elasticsearch-setup-passwords.bat interactive
warning: ignoring JAVA_HOME=C:\Program Files\Java\jdk-11.0.2; using bundled JDK
******************************************************************************
Note: The 'elasticsearch-setup-passwords' tool has been deprecated. This       command will be removed in a future release.
******************************************************************************

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

D:\elasticsearch-8.2.3\bin</pre>

查看帮助

D:\elasticsearch-8.2.3\bin
$ elasticsearch-setup-passwords.bat -h
warning: ignoring JAVA_HOME=C:\Program Files\Java\jdk-11.0.2; using bundled JDK
Sets the passwords for reserved users

Commands
--------
auto - Uses randomly generated passwords
interactive - Uses passwords entered by a user

Non-option arguments:
command

Option             Description
------             -----------
-E <KeyValuePair>  Configure a setting
-h, --help         Show help
-s, --silent       Show minimal output
-v, --verbose      Show verbose output</pre>

安装中文分词插件-方式1

首先下载和elasticsearch版本对应的插件:

https://github.com/medcl/elasticsearch-analysis-ik/releases

https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.2.3/elasticsearch-analysis-ik-8.2.3.zip

大概4.3m左右,然后复制到bin目录。

D:\elasticsearch-8.2.3\bin
$ elasticsearch-plugin install elasticsearch-analysis-ik-8.2.3.zip

运行过程

D:\elasticsearch-8.2.3\bin
$ elasticsearch-plugin install elasticsearch-analysis-ik-8.2.3.zip
warning: ignoring JAVA_HOME=C:\Program Files\Java\jdk-11.0.2; using bundled JDK
-> Installing elasticsearch-analysis-ik-8.2.3.zip
-> Failed installing elasticsearch-analysis-ik-8.2.3.zip
-> Rolling back elasticsearch-analysis-ik-8.2.3.zip
-> Rolled back elasticsearch-analysis-ik-8.2.3.zip
A tool for managing installed elasticsearch plugins

Non-option arguments:
command

Option             Description
------             -----------
-E <KeyValuePair>  Configure a setting
-h, --help         Show help
-s, --silent       Show minimal output
-v, --verbose      Show verbose output

ERROR: Unknown plugin elasticsearch-analysis-ik-8.2.3.zip

安装中文分词插件-方式2

1.直接解压缩到\plugins目录中

$ cd D:\elasticsearch-8.3.2\plugins

D:\elasticsearch-8.3.2\plugins
$ ls
elasticsearch-analysis-ik-8.2.3/

2.ik分词器的plugin-descriptor.properties

# 'description': simple summary of the plugin
description=IK Analyzer for Elasticsearch
#
# 'version': plugin's version
version=8.3.2
#
# 'name': the plugin name
name=analysis-ik
#
# 'classname': the name of the class to load, fully-qualified.
classname=org.elasticsearch.plugin.analysis.ik.AnalysisIkPlugin
#
# 'java.version' version of java the code is built against
# use the system property java.specification.version
# version string must be a sequence of nonnegative decimal integers
# separated by "."'s and may have leading zeros
java.version=1.8
#
# 'elasticsearch.version' version of elasticsearch compiled against
# You will have to release a new version of the plugin for each new
# elasticsearch release. This version is checked when the plugin
# is loaded so Elasticsearch will refuse to start in the presence of
# plugins with the incorrect elasticsearch.version.
elasticsearch.version=8.3.2

主要修改version=8.3.2elasticsearch.version=8.3.2

提示:
我用的最新的ElasticSearch8.3.2版本,ik分词器最新的版本8.2.3,版本没有跟上,最好es-ik分词插件版本要和es安装的版本对应。

相关文章

网友评论

    本文标题:windows10安装elasticsearch搜索引擎

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