Windows环境下es8的集群部署

原创文章:Windows环境下es8的集群部署 – 编程屋

目录

1 相关概念

1.1 单机集群

1.2 集群Cluster

1.3 节点Node

2 Windows下部署

2.1 节点node-1001

2.2 节点node-1002

2.3 节点node-1003


1 相关概念

1.1 单机集群

单台Elasticsearch服务器提供服务,往往都有最大的负载能力,超过这个阀值,服务器新能就会大大降低不可用,所以生产环境中,一般都是运行在指定服务器集群中。

除了负载能力,单点服务器也存在其他问题:

  • 单台机器存储容量有限
  • 单服务器容易出现单点故障,无法实现高可用
  • 单服务的并发能力有限

配置服务器集群时,集群中节点数量没有限制,大于等于两个节点就能够看做集群了,一般出于高性能和高可用来说集群节点数量都是3个月以上。

1.2 集群Cluster

一个集群就是由一个或多个服务器节点组织在一起,共同持有整个的数据,并一起提供索引和搜索功能。一个Elasticsearch集群有一个唯一的名字标识,这个名字默认就是“elasticsearch”。一个节点只能通过指定某个集群的名字,来加入这个集群。

1.3 节点Node

        集群中包含很多服务器,一个节点就是其中的一台服务器。作为集群的一部分,它存储数据,参与集群的索引和搜索功能。

        一个节点也是由一个名字来标识的,默认情况下,这个名字是一个随机的角色的名字,这个名字会在启动的时候赋予节点。这个名字对于管理工作挺重要的,因为在管理过程中,你会去确定网络中的哪些服务器对于Elasticsearch集群中的哪些节点。

一个节点可以通过配置集群名称的方式来加入一个指定的集群。默认情况下,每个节点都会安排加入到一个叫做“Elasticsearch”的集群中。

2 Windows下部署

我们准备部署3个节点:node-1001、node-1002、node-1003。

es:8.1.1版本

2.1 节点node-1001

将之前使用过的es文件夹复制到一个文件夹中。并打开我们的es文件夹

1)删除掉其中的data文件夹和清空logs文件夹下的日志。

2)打开config目录,修改elasticsearch.yml文件

官网文档:Networking | Elasticsearch Guide [8.2] | Elastic

放开集群名称和节点名称(并告知当前节点可以是master也可以是数据):

放开通信端口、端口号、监听端口

 增加跨域配置:

http.cors.enabled: true
http.cors.allow-origin: "*"

3)将文件夹名称改成node-1001

4)双击bin目录下elasticsearch.bat启动,

5)访问:http://localhost:1001/_cluster/health 查看集群状态

 可以看到当前节点数一个,数据节点也是1个。 

2.2 节点node-1002

将节点1的文件夹复制一份

注意:需要将其中的data文件夹删掉,并且清空logs下的日志

除了相应的端口号需要改变外,还需要加上如下配置,发现其他的节点。

discovery.seed_hosts: ["localhost:9301"]

 完整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-1002
node.roles: [master,data]

#
# 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 -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: localhost
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 1002
#集群之间通信的tcp端口
transport.port: 9302
discovery.seed_hosts: ["localhost:9301"]
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["localhost:1001"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1001"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 27-03-2022 08:14:12
#
# --------------------------------------------------------------------------------

# Enable security features
xpack.security.enabled: false

xpack.security.enrollment.enabled: true

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later

# Allow HTTP API connections from localhost and local networks
# Connections are encrypted and require user authentication
http.host: [_local_, _site_]

# Allow other nodes to join the cluster from localhost and local networks
# Connections are encrypted and mutually authenticated
#transport.host: [_local_, _site_]

http.cors.enabled: true
http.cors.allow-origin: "*"

#----------------------- END SECURITY AUTO CONFIGURATION -------------------------

此时我们依然访问节点1001:http://localhost:1001/_cluster/health 查看集群状态:

发现我们节点数量和数据节点数量变为2。

2.3 节点node-1003

 按照节点2的方法如法炮制:唯一不同的是:需要发现节点有两个

discovery.seed_hosts: ["localhost:9301","localhost:9302"]

此时我们依然访问节点1001:http://localhost:1001/_cluster/health 查看集群状态:

 发现我们节点数量和数据节点数量变为3。

以上只是部分内容,为了维护方便,本文已迁移到新地址:

Windows环境下es8的集群部署 – 编程屋

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
搭建Docker ES8集群,可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Docker和Docker Compose。 2. 创建一个Docker Compose文件,例如docker-compose.yml,在该文件中定义你的ES集群配置。可以使用以下示例配置: ```yaml version: '3' services: elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.0.1 environment: - discovery.type=single-node ports: - 9200:9200 volumes: - esdata:/usr/share/elasticsearch/data volumes: esdata: ``` 3. 在终端中,导航到包含docker-compose.yml文件的目录。 4. 运行以下命令以启动集群: ``` docker-compose up -d ``` 这将启动一个单节点的Elasticsearch集群,并将其绑定到本地的9200端口。 5. 要停止集群,可以运行以下命令: ``` docker-compose down ``` 这将停止容器,但保留Docker卷中的数据。 希望以上步骤可以帮助你成功搭建Docker ES8集群。如果有任何问题,请随时提问。123 #### 引用[.reference_title] - *1* *3* [Elasticsearch(4) 利用docker-compose搭建es8集群环境](https://blog.csdn.net/m0_66557301/article/details/123892665)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *2* [搭建Elasticsearch8.0集群](https://blog.csdn.net/qq_39677803/article/details/123279194)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值