Elasticsearch下載地址:https://www.elastic.co/cn/downloads/elasticsearch
elasticsearch-analysis-ik下載地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
elasticsearch-head下載:https://github.com/mobz/elasticsearch-head
Elasticsearch.Net和NEST文檔:https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html
1、安裝
下載完成后,先把文件解壓放到自己喜歡的目錄下,建議不要放在Program Files里,因為在添加ik分詞的時候,如果所在目錄路徑里有空格出現會報錯。
配置jdk環境,Elasticsearch文件自帶了jdk,無需再下載安裝。
設置路徑: 計算機=》屬性=》高級=》環境變量=》系統變量=》新建
變量名:JAVA_HOME 變量值:D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\jdk
變量名:ES_HOME 變量值:D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0
設置完成后即可啟動。
啟動方式1:設置完成后雙擊D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin下的elasticsearch.bat啟動,如果雙擊啟動后窗口一閃而過,一般是因為環境變量設置有問題,可通過第二種方式來啟動查看日志;
啟動方式2:通過dos啟動,這樣在啟動失敗的時候可以看到錯誤日志(推薦);
D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin>elasticsearch.bat //回車
2、開啟遠程訪問
//打開配置文件進行修改 D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config\elasticsearch.yml
#network.host: 192.168.0.1 修改為:network.host: 0.0.0.0 #cluster.initial_master_nodes 修改為:cluster.initial_master_nodes
重新啟動Elasticsearch,設置生效。
3、設置密碼
這里需要為4個用戶分別設置密碼,elastic, kibana, logstash_system,beats_system
//打開配置文件進行修改 D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config\elasticsearch.yml
在末尾追加以下設置並保存:
"xpack.security.enabled": true, "xpack.license.self_generated.type": "basic", "xpack.security.transport.ssl.enabled": true
回到D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin目錄下執行命令:
D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin>elasticsearch-setup-passwords interactive //回車
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]
//修改密碼 curl -H "Content-Type:application/json" -XPOST -u elastic 'http://localhost:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'
重新啟動Elasticsearch,設置生效。
4、安裝ik分詞
根據文章開頭給出的地址下載到本地,並進行解壓。把解壓后的整個文件夾復制到elasticsearch的plugins目錄下。
//這是我自己的ik安裝目錄 D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\plugins D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\plugins\elasticsearch-analysis-ik-7.8.0\config
重新啟動Elasticsearch,設置生效。 如果報錯,一般是你的目錄里有格式導致,上邊已經說過了。
//分詞效果 //發送:post localhost:9200/_analyze //默認分詞器分詞效果 {"text":"測試分詞器,后邊是測試內容:spring cloud實戰"} //ik分詞器分詞效果 {"text":"測試分詞器,后邊是測試內容:spring cloud實戰","analyzer":"ik_max_word" }
5、google瀏覽器插件 elasticsearch-head安裝
根據文章開頭給出的地址下載到本地,並進行解壓,解壓后會有一個 es-head.crx文件,將其更名為es-head.rar 后再解壓,然后通過google瀏覽器=》更多工具=》擴展程序=》打開開發者模式=》加載已解壓的擴展程序 添加已解析的es-head文件夾即可。
6、kibana安裝
7、常用命令
elasticsearch-service.bat install //安裝Elasticsearch服務 elasticsearch-service.bat remove // 刪除已安裝的Elasticsearch服務 elasticsearch-service.bat start: //啟動Elasticsearch服務(如果已安裝) elasticsearch-service.bat stop: //停止服務(如果啟動) elasticsearch-service.bat manager //啟動GUI來管理已安裝的服務