一、下載ES
1、訪問 https://www.elastic.co/cn/downloads/elasticsearch
2、選擇適合自己的版本,例如下載Windows的ZIP包
示例代碼:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-windows-x86_64.zip
二、安裝步驟
1、解壓縮下載的ZIP文件到希望數據存儲的目錄
2、創建 “`elasticsearch.yml“` 文件。此文件將告訴 Elasticsearch 在哪裡尋找數據和日誌文件。
3、啟動 Elasticsearch。可以使用CLI命令或者服務的方式啟動Elasticsearch。
示例代碼:
cd elasticsearch-7.14.1 bin/elasticsearch
三、配置文件
1、打開 “`elasticsearch.yml“` 文件
2、添加以下配置:
示例代碼:
cluster.name: my-application node.name: node-1 path.data: /path/to/data path.logs: /path/to/logs network.host: 192.168.0.1 http.port: 9200
四、啟動與關閉
1、啟動: 執行ES安裝文件夾中bin目錄下的elasticsearch.bat文件
2、關閉: 執行下面兩個命令。第一個命令是將請求發送到Elasticsearch已收到的節點;第二個命令是在關閉每個節點之前等待一分鐘:
示例代碼:
curl -X POST "localhost:9200/_shutdown" curl -X POST "localhost:9200/_flush/synced"
五、常見錯誤
1、Incompatible groovy versions:
原因: groovy不兼容
解決方案:
示例代碼:
bin/elasticsearch-plugin install ingest-attachment
2、bind() failed: Cannot assign requested address (BindException)
原因: Elasticsearch不能綁定到本地IP地址。
解決方案:
示例代碼:
network.host: 127.0.0.1 http.port: 9200
3、IllegalArgumentException[Failed to create node environment]
原因: Elasticsearch不能創建自己的數據目錄。
解決方案:
示例代碼:
path.data: /path/to/data
六、總結
ES安裝在Windows上並不難,總結一下:
1、先下載ES文件
2、解壓到自己的文件夾,打開 “`elasticsearch.yml“` 配置文件
3、啟動Elasticsearch。
如果有遇到報錯,請查看常見錯誤章節。祝大家愉快使用ES。
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/184073.html