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

elasticsearch集群搭建

名稱 code 9.png 2.4 tran ans pla 主機 修改配置

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/ linkage@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

技術分享圖片

elasticsearch集群搭建