翻閱上篇文章:Windows 10 安裝 ElasticSearch
上次寫的是下載Zip包安裝的,在下載頁面 發現有 MSI (BETA) 的下載可選項。了解之后發現MSI安裝也值得嘗試。
MSI安裝ElasticSearch
參考文章:Install Elasticsearch with Windows MSI Installer
與zip包安裝相比,MSI安裝可以將ElasticSearch作為Windows 服務安裝,這樣可以方便設置開機自啟動,就不用看到有一個cmd命令行在任務欄,ElasticSearch服務在后台運行。
當然,使用MSI安裝的最大便利是,有GUI引導方便安裝。
安裝完成之后,手動啟動ElasticSearch服務,如果按照默認配置安裝,驗證是否安裝成功的地址仍然是http://127.0.0.1:9200/
。
命令行安裝ElasticSearch
官方文檔介紹了除GUI安裝的方式,使用命令行安裝ElasticSearch。
msiexec.exe / i elasticsearch-6.6.1.msi / qn
更多了解如何使用msiexec,出了可以使用msiexec.exe / help
查看,也可以查閱微軟官方技術文檔:https://docs.microsoft.com/zh-cn/windows/desktop/Msi/command-line-options
卸載ElasticSearch
不能使用MSI進行卸載,卸載的話,只能通過 “添加/刪除程序” 進行卸載。
安裝Kibana
參考:https://www.elastic.co/guide/cn/kibana/current/windows.html
下載: https://www.elastic.co/downloads/kibana
加載示例數據
參考 :https://www.elastic.co/guide/cn/kibana/current/tutorial-load-dataset.html
下載示例數據之后,有兩個地方需要多說兩句。
提醒1:
使用以下命令在終端(如 bash )建立一個莎士比亞數據集的映射:
可以打開kibana界面,在Dev Tools
的Console下使用PUT創建索引。
或者使用Windows 10 自帶Curl命令,進行操作。
如果沒有自帶curl,可以安裝curl,下載頁面:https://curl.haxx.se/download.html
curl的使用請自行搜索。
提醒2:官方文檔中給出的命令需要做個修正
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json
例如上述語句是無法在cmd下執行成功,需要修正,即修改單引號為雙引號
curl -H "Content-Type: application/x-ndjson" -XPOST "localhost:9200/bank/account/_bulk?pretty" --data-binary @accounts.json
注意事項
Kibana的版本和Elasticsearch的版本要一致,如果升級了Elasticsearch,相應的也要升級Kibana。
如果不一致會怎樣呢?試一下
啟動Elasticsearch版本是7.2.0,Kibana版本是6.6.1,啟動Kibana,將看到如下error提示
This version of Kibana requires Elasticsearch v6.6.1 on all nodes. I found the following incompatible nodes in your cluster: v7.2.0 @ 127.0.0.1:9200 (127.0.0.1)
訪問http://localhost:5601/
,頁面顯示Kibana server is not ready yet
。