Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式

20190806092132811.jpg

概述


Elasticsearch-01CentOS7单节点部署ES5.6.16中我们学习了ES单节点的部署,这里我们来看下ES集群是如何部署的吧


CentOS上部署ES集群

集群组成


  • 节点数量: 3个 (1个Master 2个Slave)
  • OS: CentOS 7
  • IP: 192.168.91.128
  • port : master-9200 slave01-8200 slave02-7200

方便起见,先按照伪集群模式部署吧,在同一台主机上使用不同的端口来区分不同的节点,当然了你也可以使用3台虚机,那是最好不过的了


关键配置信息

必须保证集群名相同,如果节点处于同一局域网同一网段,es会自动去发现其他的节点。

elasticsearch.yml

Master

# 绑定的服务器IP,可设置为本机IP
network.host: 192.168.91.128
#启动的端口,默认9200  
http.port: 9200
#跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"
#集群信息
cluster.name: artisan
node.name: master
node.master: true


其他配置,也可以按需修改


Slave01:

#host 和 端口
network.host: 192.168.91.128
http.port: 8200
#集群信息
cluster.name: artisan
node.name: slave01
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]


Slave02:

#host 和 端口
network.host: 192.168.91.128
http.port: 7200
#集群信息
cluster.name: artisan
node.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:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- 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:
#
http.port: 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
#
#跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"
#集群信息
cluster.name: artisan
node.name: master
node.master: true



通过head插件访问集群信息


20190419093339310.png

可以看到 节点名字已经变成了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 ~]$ ll
total 33108
drwxr-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]$ ll
total 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.128
http.port: 8200
#集群信息
cluster.name: artisan
node.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.128
http.port: 7200
#集群信息
cluster.name: artisan
node.name: slave02
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]


我这里用的虚机的内存太小了,无法启动两个及两个以上的节点, 为了验证配置的正确性,windows上部署下吧


Windows 部署 ES集群


三个节点:


20190419103903254.png


elasticsearch.yml配置修改


elasticsearch.yml的配置如下:

和centos中的配置一样,仅仅是IP不同

master:

# 绑定的服务器IP,可设置为本机IP
network.host: 127.0.0.1
#启动的端口,默认9200  
http.port: 9200
#跨域设置
http.cors.enabled: true
http.cors.allow-origin: "*"
#集群信息
cluster.name: artisan
node.name: master
node.master: true

20190419103935467.png


salve01:

#host 和 端口
network.host: 127.0.0.1
http.port: 8200
#集群信息
cluster.name: artisan
node.name: slave01
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


20190419104001844.png


slave02:

#host 和 端口
network.host: 127.0.0.1
http.port: 7200
#集群信息
cluster.name: artisan
node.name: slave02
#默认的通讯接口是9300,用来发现master信息
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


20190419104029115.png


启动服务


双击H:\elasticsearch-5.6.16-slave02\bin\elasticsearch.bat


20190419104256942.png

通过head 插件查看 集群信息


20190419104359914.png

配置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目录中的数据重复导致的。 建议解压一个新的压缩包,重新配置,避免上述错误。


相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
2月前
|
索引
elasticsearch集群健康状态查看
elasticsearch集群健康状态查看
11 2
|
1月前
|
Java Windows
windows下 安装 Elasticsearch报错warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
windows下 安装 Elasticsearch报错warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
43 0
|
6天前
|
存储 监控 安全
Elasticsearch 8.X 集群 SSL 证书到期了,怎么更换?
Elasticsearch 8.X 集群 SSL 证书到期了,怎么更换?
29 3
|
7天前
|
缓存 JSON 关系型数据库
Elasticsearch 8.X 集群无响应,怎么办?
Elasticsearch 8.X 集群无响应,怎么办?
12 0
|
7天前
|
安全 Linux 数据安全/隐私保护
Windows 部署 Elasticsearch + kibana 8.0 指南
Windows 部署 Elasticsearch + kibana 8.0 指南
13 0
|
7天前
|
存储 安全 网络协议
云服务器 Centos7 部署 Elasticsearch 8.0 + Kibana 8.0 指南
云服务器 Centos7 部署 Elasticsearch 8.0 + Kibana 8.0 指南
18 0
|
7天前
|
存储 数据可视化 Java
Elasticsearch 集群状态变成黄色或者红色,怎么办?
Elasticsearch 集群状态变成黄色或者红色,怎么办?
10 0
|
1月前
|
存储 自然语言处理 算法
elasticsearch集群搭建,以及kibana和ik分词器的安装(7.3.2)
elasticsearch集群搭建,以及kibana和ik分词器的安装(7.3.2)
|
安全 NoSQL MongoDB
mongoDB CentOS7.2集群部署
1.关闭selinux vi /etc/selinux/config SELINUX=disabled setenforce 0   2.
1763 0
|
3天前
|
前端开发 jenkins 持续交付
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
新的centos7.9安装docker版本的jenkins2.436.1最新版本-前端项目发布(五)
13 1

热门文章

最新文章