由于資源有限瞪浸,又想學集群毡琉,就直接通過端口號不同來做個偽集群了九府。
- 首先將之前的解壓包重命名為
elasticsearch-6.2.3-node1
,作為集群的第一個節(jié)點羡洁,并修改其內(nèi)部config
文件夾下面的elasticsearch.yml
,同時更新內(nèi)容為:
#集群名稱
cluster.name: my-application
#節(jié)點名稱
node.name: node-1
#是不是主節(jié)點
node.master: true
node.attr.rack: r1
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#網(wǎng)關(guān)地址
network.host: 192.168.1.124
#端口
http.port: 9200
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 9301
# 開啟安全防護
http.cors.enabled: true
http.cors.allow-origin: "*"
#時間放長文狱,防止腦裂
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
#配置有機會參與選舉為master的節(jié)點
discovery.zen.ping.unicast.hosts: ["192.168.1.124:9200","192.168.1.124:9201", "192.168.1.124:9202"]
然后將elasticsearch-6.2.3-node1復(fù)制兩份圆仔,分別重命名為elasticsearch-6.2.3-node2枯饿,elasticsearch-6.2.3-node3憨颠,同時更新配置內(nèi)容為:
節(jié)點2的elasticsearch.yml
為:
#集群名稱
cluster.name: my-application
#節(jié)點名稱
node.name: node-2
#是不是主節(jié)點
node.master: true
node.attr.rack: r1
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#網(wǎng)關(guān)地址
network.host: 192.168.1.124
#端口
http.port: 9201
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 9302
# 開啟安全防護
http.cors.enabled: true
http.cors.allow-origin: "*"
#時間放長,防止腦裂
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
#配置有機會參與選舉為master的節(jié)點
discovery.zen.ping.unicast.hosts: ["192.168.1.124:9200","192.168.1.124:9201", "192.168.1.124:9202"]
節(jié)點3的elasticsearch.yml
為:
#集群名稱
cluster.name: my-application
#節(jié)點名稱
node.name: node-3
#是不是主節(jié)點
node.master: true
node.attr.rack: r1
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#網(wǎng)關(guān)地址
network.host: 192.168.1.124
#端口
http.port: 9203
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 9303
# 開啟安全防護
http.cors.enabled: true
http.cors.allow-origin: "*"
#時間放長婿屹,防止腦裂
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
#配置有機會參與選舉為master的節(jié)點
discovery.zen.ping.unicast.hosts: ["192.168.1.124:9200","192.168.1.124:9201", "192.168.1.124:9202"]
我們挨個啟動一下,之后使用Head連接推溃,便可看到如下界面:
image.png
-
注意:
image.png
補充:Head插件安裝
這里只介紹6.2.3這個版本的安裝昂利,由于ES早期對這個插件方向配置和現(xiàn)在的有很大不同届腐,所以這里之說一下我踩過的坑。
開始準備
elasticsearch-head的zip包蜂奸,github網(wǎng)址如下:https://github.com/mobz/elasticsearch-head檢查node.js,這個版本要求node要9.0.0以上犁苏。很坑,之前更新了node沒更npm扩所,裝了半天沒反應(yīng)围详。詳細請自行百度。
將下載好的elasticsearch-head.zip解壓并進入到elasticsearch-head主目錄執(zhí)行:
npm install
祖屏,慢慢等助赞。。袁勺。雹食。-
很遺憾,這里80%會報錯
image.png
解決方案:
#這個意思很簡單期丰,就是說elasticsearch-head的package.json版本要求我們不能全部滿足群叶,這里不用管,直接忽略腳本版本安裝钝荡。
npm install phantomjs-prebuilt@2.1.14 --ignore-scripts
- 切回到head的主目錄下,執(zhí)行如下命令
npm run start
image.png
這樣就啟動了好了街立。我們?yōu)g覽器看一下:
image.png
ok,插件安裝成功2和āJ昀搿!
搞了這么久植阴,還在配環(huán)境蟹瘾,下一篇準備來點語法使用和java使用。后期可能會介紹一個es+hbase做大數(shù)據(jù)實時查詢掠手,詳細請關(guān)注我后面的文章憾朴,感謝閱讀,祝您生活愉快喷鸽。