如何快速運行一個elasticsearch, 當然是用Docker來跑了. 不需要復雜的編譯安裝,只需要在linux下面,執行一個命令,就可以讓elasticsearch跑起來.
準備
Linux x64 系統, 如 centos 7和 ubuntu 18.04
15GB 或更多磁盤空間
1GB或更多內存
網絡連接
根據docker 官方教程安裝好docker,并已經啟動docker
開始
開啟一個命令行shell,執行命令啟動 elasticsearch
docker run -d --restart=always --name es -p 9200:9200 -p 9300:9300 elasticsearch:6.7.0
等待片刻,然后檢查 日志是否正常
docker logs -f es
如果沒有錯誤,那么你可以開始用curl測試
$ curl -v http://127.0.0.1:9200/ * Trying 127.0.0.1:9200... * TCP_NODELAY set * Connected to 127.0.0.1 (127.0.0.1) port 9200 (#0) > GET / HTTP/1.1 > Host: 127.0.0.1:9200 > User-Agent: curl/7.66.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < content-type: Application/json; charset=UTF-8 < content-length: 496 < { "name" : "BKoY3qr", "cluster_name" : "elasticsearch", "cluster_uuid" : "eGIfGYBFQB2495AGXxFyHg", "version" : { "number" : "6.7.0", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "8453f77", "build_date" : "2019-03-21T15:32:29.844721Z", "build_snapshot" : false, "lucene_version" : "7.7.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" } * Connection #0 to host 127.0.0.1 left intact
到這里,你的elasticsearch就跑起來了,可以開始寫程序查詢elasticsearch了