1. 程式人生 > 其它 >Elasticsearch 7.x windows快速安裝部署

Elasticsearch 7.x 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,無需再下載安裝。

設定路徑: 計算機=》屬性=》高階=》環境變數=》系統變數=》新建

變數名:ES_JAVA_HOME 或 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: 0.0.0.0
discovery.seed_hosts: ["172.17.0.3"]

//重啟生效

3、設定密碼

https://www.elastic.co/guide/en/elasticsearch/reference/7.16/security-minimal-setup.html

這裡需要為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
//如果是單節點,新增以下設定可確保您的節點不會無意中連線到可能在您的網路上執行的其他叢集
discovery.type: single-node

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" }'

 

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安裝

下載kibana並解壓,進入根目錄,執行命令啟動

1 2 啟動命令 .\bin\kibana //Ctrl-C 停止 Kibana

 文件地址:https://www.elastic.co/guide/cn/kibana/current/windows.html

  如果es開戶了許可權,kibana需要設定對應的金鑰 

elasticsearch.username: "kibana"
elasticsearch.password: "pass"

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

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,無需再下載安裝。

設定路徑: 計算機=》屬性=》高階=》環境變數=》系統變數=》新建

變數名:ES_JAVA_HOME 或 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: 0.0.0.0
discovery.seed_hosts: ["172.17.0.3"]

//重啟生效

3、設定密碼

https://www.elastic.co/guide/en/elasticsearch/reference/7.16/security-minimal-setup.html

這裡需要為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
//如果是單節點,新增以下設定可確保您的節點不會無意中連線到可能在您的網路上執行的其他叢集
discovery.type: single-node

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" }'

 

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安裝

下載kibana並解壓,進入根目錄,執行命令啟動

1 2 啟動命令 .\bin\kibana //Ctrl-C 停止 Kibana

 文件地址:https://www.elastic.co/guide/cn/kibana/current/windows.html

  如果es開戶了許可權,kibana需要設定對應的金鑰 

elasticsearch.username: "kibana"
elasticsearch.password: "pass"

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