elasticsearch单机集群搭建(version-8.7.0)

文章讲述了如何下载并配置Elasticsearch的多节点集群,包括修改端口、集群名称、数据路径、日志路径以及设置master节点和发现主机。在配置过程中提到了http.port和transport.port的区别,并分享了启动和验证集群状态的步骤,以及遇到的问题和解决方法。
摘要由CSDN通过智能技术生成
  1. 官网下载es安装包,找个地方复制三份
    https://www.elastic.co/cn/downloads/elasticsearch
  2. 打开配置文件,修改
vim software/es/es-a/config/elasticsearch.yml 
vim software/es/es-b/config/elasticsearch.yml 
vim software/es/es-b/config/elasticsearch.yml 

需要修改的地方

transport.profiles.default.port: 9300 # 表示这个节点是靠这个端口通信的,如果是多个机器,可以不配置
cluster.name: chen-application #集群名称,配置成一样的就好
path.data: /Users/chenyuxi/Documents/study/es/a/data #数据存放路径
path.logs: /Users/chenyuxi/Documents/study/es/a/logs
http.port: 9200 #使用http访问服务的端口,需要和transport port区分开
cluster.initial_master_nodes: ["node-a", "node-b"] # 定义集群的master
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"] #定义会通过这里配置的主机+端口号发现master

贴一个node-a的配置

# ======================== 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
# -------security---
xpack.security.enabled: false
#-------transport---
transport.profiles.default.port: 9300
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: chen-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-a
#
# 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: /Users/chenyuxi/Documents/study/es/a/data
#
# Path to log files:
#
path.logs: /Users/chenyuxi/Documents/study/es/a/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: 192.168.0.1
#
# 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: 9200
#
# 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: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-a", "node-b"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false
  1. 启动
./software/es/es-a/bin/elasticsearch
./software/es/es-b/bin/elasticsearch
./software/es/es-c/bin/elasticsearch
  1. 验证
  • 通过http访问三个节点
http://localhost:9200/
http://localhost:9201/
http://localhost:9202/

在这里插入图片描述

  • 查看集群信息
http://localhost:9200/_cat/health?v

在这里插入图片描述
green !!!
把kibana也安装配置起来
通过命令查看节点情况,可以看到,只有一个master,这是因为在集群运行过程中,只能有一个master,虽然我们之前配置的是两,但是配置的含义是这两都能被选举成master

GET /_cat/nodes?v #查看节点情况

在这里插入图片描述

  1. 踩坑
    最开始没分清楚http.port和transport.port,在discovery那里配置的是http.port,但是就一直报找不到master node,后来就改成配置host+transport.port
    另外启动一个node后,会找一会master,不会一下子就找到的,等找到了就不会有[WARN]了
[2023-04-16T21:39:40,047][WARN ][o.e.c.c.ClusterFormationFailureHelper] [node-b] master not discovered or elected yet, an election requires a node with id [2AEek3vvTEm1yrB6I_H-3A], have only discovered non-quorum [{node-b}{ZpIuYu5gQtuoemPpstHCGQ}{m7wckfDXRNaDNfmI-rTu0g}{node-b}{127.0.0.1}{127.0.0.1:9301}{cdfhilmrstw}{8.7.0}, {node-c}{FN7dwBshT8aXPDmTzxywWw}{aThNzQyqQB-aKk13mhmmtA}{node-c}{127.0.0.1}{127.0.0.1:9302}{cdfhilmrstw}{8.7.0}]; discovery will continue using [127.0.0.1:9300, 127.0.0.1:9302] from hosts providers and [{node-b}{ZpIuYu5gQtuoemPpstHCGQ}{m7wckfDXRNaDNfmI-rTu0g}{node-b}{127.0.0.1}{127.0.0.1:9301}{cdfhilmrstw}{8.7.0}, {node-a}{2AEek3vvTEm1yrB6I_H-3A}{0pRNMUVYR0eEOsQQoPGrNQ}{node-a}{127.0.0.1}{127.0.0.1:9300}{cdfhilmrstw}{8.7.0}] from last-known cluster state; node term 3, last-accepted version 35 in term 3; for troubleshooting guidance, see https://www.elastic.co/guide/en/elasticsearch/reference/8.7/discovery-troubleshooting.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值