1. 程式人生 > >elasticsearch叢集搭建

elasticsearch叢集搭建

es叢集搭建網上百度一大堆,有很詳細的步驟,在這裡還是記錄一下自己的搭建過程,分享經驗(主要是我覺得這個搭建比較簡單);

準備材料

叢集主機3臺:192.168.54.16、192.168.54.17、192.168.54.18

es版本:elasticsearch-2.4.0.tar.gz

步驟:

一、解壓elasticsearch-2.4.0.tar.gz到/export/home/tools/elasticsearch-2.4.0

二、修改配置檔案vi elasticsearch.yml,以下幾個主要關注的配置

#叢集名稱
# ---------------------------------- Cluster ----------------------------
cluster.name: gate
-es # ------------------------------------ Node ---------------------------- #節點名稱(自定義),3臺主機分別設定為gate01、gate02、gate03 node.name: gate01 node.master: true node.data: true # ----------------------------------- Paths ---------------------------- #資料存放目錄 path.data: /export/home/data/es/data #日誌目錄 path.logs: /export/home/data/es/
log path.work: /export/home/data/es/work #------------------------- ------Network ----------------------------- #伺服器地址 network.host: 0.0.0.0 --預設 #http訪問埠 http.port: 9200 --預設9200 #tcp服務埠 transport.tcp.port: 9300 --預設9300 http.enabled: true

三、另外2臺主機執行步驟同上,或者將目錄拷貝到2臺主機上並修改節點node.name

scp -r elasticsearch-2.4.0_master/ 
[email protected]
192.168.54.17:/export/home/tools/

四、叢集配置過程完成,分別啟動3個節點

#啟動es ./elasticsearch -d#檢視程序ps -ef|grep elasticsearch

五、通過curl -XPUT 配置模版,在其中一個節點上設定就可以了

curl -XPUT 192.168.54.16:9200/_template/template_s_command_log -d '{"template":"s_command_log_*","order":0,"settings":{"number_of_shards":"3","number_of_replicas":"1","index.refresh_interval":"30s"},"mappings":{"s_command_log": {"properties": {"sigle_account": {"type": "string"},"result": {"type": "string"},"dev_model": {"type": "string"},"host": {"type": "string"},"dev_account": {"type": "string"},"vendor_id": {"type": "string"},"date": {"type": "string"},"login_ip": {"type": "string"},"@version": {"type": "string"},"ip": {"type": "string"},"id": {"type": "string"},"@timestamp": {"format": "strict_date_optional_time||epoch_millis","type": "date"},"command": {"type": "string"},"path": {"type": "string"},"sendtime": {"type": "long"},"dev_type": {"type": "string"}}}}}'

六、檢視模版

curl -XGET 192.168.54.18:9200/_template/template_s_command_log

至此、es叢集就搭建完成了,下面通過頁面訪問一下http://127.0.0.1:9200/_plugin/head

通過sql引擎執行查詢:http://127.0.0.1:9200/_plugin/sql