《Elasticsearch技術解析與實戰》Chapter 1.2 Elasticsearch安裝

莊裡程式猿發表於2019-04-14

1. 下載安裝

1.1 下載

https://www.elastic.co/downloads/elasticsearch
下載 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.0.tar.gz
複製程式碼

1.2 解壓

tar -zxvf elasticsearch-6.7.0.tar.gz
複製程式碼

1.3 執行

cd elasticsearch-6.7.0
bin/elasticsearch
複製程式碼

1.4 檢驗

curl http://localhost:9200  或者瀏覽器訪問
{
    "name": "q9sdES9",
    "cluster_name": "docker-cluster",
    "cluster_uuid": "6klEi4d0Q6y0LC3YNYVXTQ",
    "version": {
        "number": "5.5.0",
        "build_hash": "260387d",
        "build_date": "2017-06-30T23:16:05.735Z",
        "build_snapshot": false,
        "lucene_version": "6.6.0"
    },
    "tagline": "You Know, for Search"
}
複製程式碼

2. Docker部署

官方文件 : www.elastic.co/guide/en/el…

2.1 拉取映象

docker pull docker.elastic.co/elasticsearch/elasticsearch:5.5.1
複製程式碼

2.2 啟動容器

docker run -p 9200:9200 9300:9300 -e "http.host=0.0.0.0" -e “transport.host=0.0.0.0" --name elasticsearch_5.5.0 -d docker.elastic.co/elasticsearch/elasticsearch:5.5.0
複製程式碼

2.3 修改配置

進入到容器中 : docker exec -it elasticsearch_5.5.0 /bin/bash
修改jvm配置 : vi /config/jvm.options
            -Xms2g  —>  -Xms512m
            -Xmx2g  —>  -Xmx512m
    修改小一些,伺服器記憶體有限?
複製程式碼

2.4 重啟容器,檢視是否成功

http://伺服器ip:9200
{
    "name": "q9sdES9",
    "cluster_name": "docker-cluster",
    "cluster_uuid": "6klEi4d0Q6y0LC3YNYVXTQ",
    "version": {
        "number": "5.5.0",
        "build_hash": "260387d",
        "build_date": "2017-06-30T23:16:05.735Z",
        "build_snapshot": false,
        "lucene_version": "6.6.0"
    },
    "tagline": "You Know, for Search"
}
此處叢集的名稱為 docker-cluster, 可以自行修改 : vi /config/elasticsearch.yml
複製程式碼

Tips

本文同步發表在公眾號,歡迎大家關注!? 後續筆記歡迎關注獲取第一時間更新!

《Elasticsearch技術解析與實戰》Chapter 1.2 Elasticsearch安裝

相關文章