Elasticsearch 7.8 windows快速安裝部署

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來管理已安裝的服務

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章