ELK實時日誌分析平臺搭建(二) ElasticSearch集羣的搭建

ElasticSearch是一個基於Lucene的搜索服務器。它提供了一個分佈式多用戶能力的全文搜索引擎,基於RESTful web接口。Elasticsearch是用Java開發的,並作爲Apache許可條款下的開放源碼發佈,是當前流行的企業級搜索引擎。設計用於雲計算中,能夠達到實時搜索,穩定,可靠,快速,安裝使用方便。

我們建立一個網站或應用程序,並要添加搜索功能,但是想要完成搜索工作的創建是非常困難的。我們希望搜索解決方案要運行速度快,我們希望能有一個零配置和一個完全免費的搜索模式,我們希望能夠簡單地使用JSON通過HTTP來索引數據,我們希望我們的搜索服務器始終可用,我們希望能夠從一臺開始並擴展到數百臺,我們要實時搜索,我們要簡單的多租戶,我們希望建立一個雲的解決方案。因此我們利用Elasticsearch來解決所有這些問題以及可能出現的更多其它問題。

集羣搭建過程

集羣模擬

官網下載elasticsearch,解壓後,複製2分,模擬集羣搭建。
分別爲elasticsearch-6.5.3、elasticsearch-6.5.3-1、elasticsearch-6.5.3-2,其中以elasticsearch-6.5.3作爲主節點。
在這裏插入圖片描述

配置文件

三個節點模擬完成之後,分別修改配置文件
主節點文件:
elasticsearch-6.5.3的配置文件

cluster.name: my-application
node.name: node-0
network.host: 127.0.0.1
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: [“127.0.0.1:9300”]
http.cors.enabled: true
http.cors.allow-origin: “*”
node.master: true
node.data: true

elasticsearch-6.5.3-1的配置文件

cluster.name: my-application
node.name: node-1
network.host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: [“127.0.0.1:9300”]
http.cors.enabled: true
http.cors.allow-origin: “*”
node.master: true
node.data: true

elasticsearch-6.5.3-2的配置文件

cluster.name: my-application
node.name: node-2
network.host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: [“127.0.0.1:9300”]
http.cors.enabled: true
http.cors.allow-origin: “*”
node.master: true
node.data: true

啓動

配置文件配置好了之後,就可以直接啓動了
D:\install\elastic\ElasticSearch\elasticsearch-6.5.3\bin> .\elasticsearch.bat
在這裏插入圖片描述
啓動完成之後,訪問http://127.0.0.1:9200/,出現如下界面,表示啓動成功
在這裏插入圖片描述
同理,分別啓動第二個節點和第三個節點

安裝head插件

1、地址: https://github.com/mobz/elasticsearch-head
在這裏插入圖片描述
打開後直接克隆到本地。
2、克隆完成之後,在elasticsearch主節點的安裝目錄下新建elasticsearch-head-master目錄,並把剛剛克隆的插件複製進去。進入elasticsearch-head-master目錄,打開powershell,執行命令npm run start,出現下圖表示啓動成功
在這裏插入圖片描述
此時可以看到,插件佔用的是9100端口,我們訪問http://127.0.0.1:9100/,可以看到如圖:
在這裏插入圖片描述
上面node-0,node-1,node-2就是我們啓動的三個幾點。(我這裏的索引是先前建好的,可以忽略)

至此,我們所有的節點以及各節點的索引和文檔都能很清晰的從head插件上看到。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章