洞察探索open banking如何通过小程序容器技术助力金融企业实现数据安全和数字化转型
789
2022-09-15
Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式
文章目录
概述CentOS上部署ES集群
集群组成关键配置信息Master节点搭建Slave1节点搭建Slave2节点搭建
Windows 部署 ES集群
elasticsearch.yml配置修改启动服务
注意事项
概述
Elasticsearch-01CentOS7单节点部署ES5.6.16中我们学习了ES单节点的部署,这里我们来看下ES集群是如何部署的吧
CentOS上部署ES集群
集群组成
节点数量: 3个 (1个Master 2个Slave)OS: CentOS 7IP: 192.168.91.128port : master-9200 slave01-8200 slave02-7200
方便起见,先按照伪集群模式部署吧,在同一台主机上使用不同的端口来区分不同的节点,当然了你也可以使用3台虚机,那是最好不过的了
关键配置信息
必须保证集群名相同,如果节点处于同一局域网同一网段,es会自动去发现其他的节点。
elasticsearch.yml
Master
# 绑定的服务器IP,可设置为本机IPnetwork.host: 192.168.91.128#启动的端口,默认9200 9200 #跨域设置true"*" #集群信息cluster.name: artisannode.name: masternode.master: true
其他配置,也可以按需修改
Slave01:
#host 和 端口network.host: 192.168.91.1288200#集群信息cluster.name: artisannode.name: slave01#默认的通讯接口是9300,用来发现master信息discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]
Slave02:
#host 和 端口network.host: 192.168.91.1287200#集群信息cluster.name: artisannode.name: slave02#默认的通讯接口是9300,用来发现master信息discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]
Master节点搭建
修改elasticsearch.yml中的配置
# ======================== Elasticsearch Configuration =========================## NOTE: Elasticsearch comes with reasonable defaults for most settings.# Before you set out to tweak and tune the configuration, make sure you# understand what are you trying to accomplish and the consequences.## The primary way of configuring a node is via this file. This template lists# the most important settings you may want to configure for a production cluster.## Please consult the documentation for further information on configuration options:# ---------------------------------- Cluster -----------------------------------## Use a descriptive name for your cluster:##cluster.name: my-application## ------------------------------------ Node ------------------------------------## Use a descriptive name for the node:##node.name: node-1## Add custom attributes to the node:##node.attr.rack: r1## ----------------------------------- Paths ------------------------------------## Path to directory where to store the data (separate multiple locations by comma):##path.data: /path/to/data## Path to log files:##path.logs: /path/to/logs## ----------------------------------- Memory -----------------------------------## Lock the memory on startup:##bootstrap.memory_lock: true## Make sure that the heap size is set to about half the memory available# on the system and that the owner of the process is allowed to use this# limit.## Elasticsearch performs poorly when the system is swapping the memory.## ---------------------------------- Network -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):#network.host: 192.168.91.128## Set a custom port for HTTP:#9200## For more information, consult the network module documentation.## --------------------------------- Discovery ----------------------------------## Pass an initial list of hosts to perform discovery when new node is started:# The default list of hosts is ["127.0.0.1", "[::1]"]##discovery.zen.ping.unicast.hosts: ["host1", "host2"]## Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):##discovery.zen.minimum_master_nodes: 3## For more information, consult the zen discovery module documentation.## ---------------------------------- Gateway -----------------------------------## Block initial recovery after a full cluster restart until N nodes are started:##gateway.recover_after_nodes: 3## For more information, consult the gateway module documentation.## ---------------------------------- Various -----------------------------------## Require explicit names when deleting indices:##action.destructive_requires_name: true##跨域设置true"*"#集群信息cluster.name: artisannode.name: masternode.master: true
通过head插件访问集群信息
可以看到 节点名字已经变成了master, 并且前面的五角星表示为master节点(指挥官) 。
Slave1节点搭建
复制一份,然后修改配置文件
[root@localhost ~]# su - elastic Last login: Thu Apr 18 08:47:46 PDT 2019 on pts/1[elastic@localhost ~]$ pwd/home/elastic[elastic@localhost ~]$ lltotal 33108drwxr-xr-x. 9 elastic elastic 4096 Apr 18 03:30 elasticsearch-5.6.16-rw-r--r--. 1 root root 33894983 Apr 18 03:27 elasticsearch-5.6.16.tar.gz[elastic@localhost ~]$ [elastic@localhost ~]$ [elastic@localhost ~]$ mkdir elasticsearch-5.6.16-salve[elastic@localhost ~]$ cp elasticsearch-5.6.16.tar.gz elasticsearch-5.6.16-salve/[elastic@localhost ~]$ cd elasticsearch-5.6.16-salve/[elastic@localhost elasticsearch-5.6.16-salve]$ lltotal 33104-rw-r--r--. 1 elastic elastic 33894983 Apr 18 18:28 elasticsearch-5.6.16.tar.gz[elastic@localhost elasticsearch-5.6.16-salve]$ tar -xvzf elasticsearch-5.6.16.tar.gz [elastic@localhost elasticsearch-5.6.16-salve]$ cp -r elasticsearch-5.6.16 elasticsearch-slave01[elastic@localhost elasticsearch-5.6.16-salve]$ cp -r elasticsearch-5.6.16 elasticsearch-slave02[elastic@localhost elasticsearch-5.6.16-salve]$ cd elasticsearch-slave01[elastic@localhost elasticsearch-slave01]$ vim config/elasticsearch.yml
elasticsearch.yml 追加如下配置
#host 和 端口network.host: 192.168.91.1288200#集群信息cluster.name: artisannode.name: slave01#默认的通讯接口是9300,找到集群的信discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]
Slave2节点搭建
[elastic@localhost elasticsearch-5.6.16-salve]$ cd elasticsearch-slave02
elasticsearch.yml 追加如下配置
#host 和 端口network.host: 192.168.91.1287200#集群信息cluster.name: artisannode.name: slave02#默认的通讯接口是9300,用来发现master信息discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]
我这里用的虚机的内存太小了,无法启动两个及两个以上的节点, 为了验证配置的正确性,windows上部署下吧
Windows 部署 ES集群
三个节点:
elasticsearch.yml配置修改
elasticsearch.yml的配置如下:
和centos中的配置一样,仅仅是IP不同
master:
# 绑定的服务器IP,可设置为本机IPnetwork.host: 127.0.0.1#启动的端口,默认9200 9200 #跨域设置true"*" #集群信息cluster.name: artisannode.name: masternode.master: true
salve01:
#host 和 端口network.host: 127.0.0.18200#集群信息cluster.name: artisannode.name: slave01#默认的通讯接口是9300,用来发现master信息discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]
slave02:
#host 和 端口network.host: 127.0.0.17200#集群信息cluster.name: artisannode.name: slave02#默认的通讯接口是9300,用来发现master信息discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]
启动服务
双击H:\elasticsearch-5.6.16-slave02\bin\elasticsearch.bat
通过head 插件查看 集群信息
配置OK
注意事项
found existing node {master}{xdHjXCdET_e7M0G_MYNiTQ}{WbXaI8HtRDCbFEzS8VtdIg}{127.0.0.1}{127.0.0.1:9300} with the same id but is a different node instance];
如果配到了这种错误,很明显id重复了,如果配置没有问题,看下你是不是直接copy的已经存在的节点data目录中的数据重复导致的。 建议解压一个新的压缩包,重新配置,避免上述错误。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~