我爱编程

ElasticSearch单机下集群安装(三)

2018-03-31  本文已影响0人  ggr

由于资源有限,又想学集群,就直接通过端口号不同来做个伪集群了。

#集群名称
cluster.name: my-application
#节点名称
node.name: node-1
#是不是主节点
node.master: true
node.attr.rack: r1
#最大集群节点数
node.max_local_storage_nodes: 3
#网关地址
network.host: 192.168.1.124
#端口
http.port: 9200
#内部节点之间沟通端口
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的节点
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复制两份,分别重命名为elasticsearch-6.2.3-node2,elasticsearch-6.2.3-node3,同时更新配置内容为:

节点2的elasticsearch.yml为:

#集群名称
cluster.name: my-application
#节点名称
node.name: node-2
#是不是主节点
node.master: true
node.attr.rack: r1
#最大集群节点数
node.max_local_storage_nodes: 3
#网关地址
network.host: 192.168.1.124
#端口
http.port: 9201
#内部节点之间沟通端口
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的节点
discovery.zen.ping.unicast.hosts: ["192.168.1.124:9200","192.168.1.124:9201", "192.168.1.124:9202"]

节点3的elasticsearch.yml为:

#集群名称
cluster.name: my-application
#节点名称
node.name: node-3
#是不是主节点
node.master: true
node.attr.rack: r1
#最大集群节点数
node.max_local_storage_nodes: 3
#网关地址
network.host: 192.168.1.124
#端口
http.port: 9203
#内部节点之间沟通端口
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的节点
discovery.zen.ping.unicast.hosts: ["192.168.1.124:9200","192.168.1.124:9201", "192.168.1.124:9202"]

我们挨个启动一下,之后使用Head连接,便可看到如下界面:


image.png

补充:Head插件安装
这里只介绍6.2.3这个版本的安装,由于ES早期对这个插件方向配置和现在的有很大不同,所以这里之说一下我踩过的坑。

#这个意思很简单,就是说elasticsearch-head的package.json版本要求我们不能全部满足,这里不用管,直接忽略脚本版本安装。
npm install phantomjs-prebuilt@2.1.14 --ignore-scripts
 npm run start
image.png

这样就启动了好了。我们浏览器看一下:


image.png

ok,插件安装成功!!!

搞了这么久,还在配环境,下一篇准备来点语法使用和java使用。后期可能会介绍一个es+hbase做大数据实时查询,详细请关注我后面的文章,感谢阅读,祝您生活愉快。

上一篇 下一篇

猜你喜欢

热点阅读