簡介
Elasticsearch 是一個實(shí)時的分布式搜索分析引擎脱柱, 它能讓你以一個之前從未有過的速度和規(guī)模榨为,去探索你的數(shù)據(jù)。 它被用作全文檢索日川、結(jié)構(gòu)化搜索板壮、分析以及這三個功能的組合绰精。
下載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批處理文件硫椰。
解壓縮以后執(zhí)行bin目錄里面的批處理文件就可以運(yùn)行了
啟動ElasticSearch
進(jìn)入bin目錄執(zhí)行elasticsearch.bat
$ cd D:\elasticsearch-8.2.3\bin
$ elasticsearch.bat
第一次訪問的時候注意看一下默認(rèn)的賬號和密碼
--------------------------------------------------------------------------------------------------
-> 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
訪問測試繁调,看到提示需要密碼萨蚕。
設(shè)置賬號和密碼
先不要關(guān)閉elasticsearch,然后新開一個CMD窗口蹄胰,執(zhí)行命令
$ 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版本對應(yīng)的插件:
https://github.com/medcl/elasticsearch-analysis-ik/releases
大概4.3m左右岳遥,然后復(fù)制到bin目錄。
D:\elasticsearch-8.2.3\bin
$ elasticsearch-plugin install elasticsearch-analysis-ik-8.2.3.zip
運(yùn)行過程
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.2
和elasticsearch.version=8.3.2
提示:
我用的最新的ElasticSearch8.3.2版本裕寨,ik分詞器最新的版本8.2.3,版本沒有跟上,最好es-ik分詞插件版本要和es安裝的版本對應(yīng)宾袜。