elasticsearch8.9.1集群搭建

目录

1.官网文档

2.安装步骤

2.1 环境准备

2.2 添加用户

2.3 修改文件profile文件

2.4 修改elasticsearch.yml

2.5 修改 sysctl.conf

3.启动

3.1 切换到kibana

3.2 启动elasticsearch

3.3 启动kibana

3.4 验证节点情况


1.官网文档

elasticsearch文档:https://www.elastic.co/guide/en/elasticsearch/reference/8.9/targz.html
kibana文档:https://www.elastic.co/guide/en/kibana/current/targz.html

2.安装步骤

无登录密码方式

2.1 环境准备

centos8 +linux

若无shasum,可以先安装

bash: shasum: 未找到命令
[root@localhost apps]# sudo yum install -y perl-Digest-SHA-1:6.02-1.el8.x86_64
[root@localhost apps]# sudo yum install -y perl-Digest-SHA

三台虚拟机或者linux服务器(docker方式此处不在描述):

192.168.23.12     master

192.168.23.13     slave

192.168.23.14     slave

下载文件进行解压(下载速度稍微有点慢):

[root@localhost apps] wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.8.2-linux-x86_64.tar.gz
[root@localhost apps] wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.8.2-linux-x86_64.tar.gz.sha512
[root@localhost apps] shasum -a 512 -c elasticsearch-8.8.2-linux-x86_64.tar.gz.sha512 
[root@localhost apps] tar -xzf elasticsearch-8.8.2-linux-x86_64.tar.gz

kbana在主节点上下载即可,其他机器可以不用(集群例外)

[root@localhost apps]# wget https://artifacts.elastic.co/downloads/kibana/kibana-8.9.1-linux-x86_64.tar.gz
[root@localhost apps]# curl https://artifacts.elastic.co/downloads/kibana/kibana-8.9.1-linux-x86_64.tar.gz.sha512 | shasum -a 512 -c -
[root@localhost apps]# tar -xzf kibana-8.9.1-linux-x86_64.tar.gz

2.2 添加用户

elasticsearch启动不允许使用root用户导致

[root@localhost elasticsearch-8.8.2]# useradd kibana
[root@localhost elasticsearch-8.8.2]# passwd kibana

2.3 修改文件profile文件

三台机器操作

添加ES_JAVA_HOME  elasticsearch下自带有openjdk

[root@localhost apps]# vim /etc/profile
export ES_JAVA_HOME=/usr/local/apps/elasticsearch-8.9.1/jdk

[root@localhost apps]# source  /etc/profile

2.4 修改elasticsearch.yml

/usr/local/apps/elasticsearch-8.9.1/config/

注意data和logs节点需要自己建文件夹

xpack.security.enabled: false  默认这个配置是开启的,配置文件中没有,启动后如果正常一般有一堆的安全配置属性也包括这个(xpack.security.enabled: true),配置就麻烦很多,而且kibana登录时也要配置

主节点


# ======================== 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: elastisearch
#
# ------------------------------------ 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: /usr/local/apps/esdata/data
#
# Path to log files:
#
path.logs: /usr/local/apps/esdata/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.23.12
#
# 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: ["192.168.23.13:9300", "192.168.23.14:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
action.destructive_requires_name: false

xpack.security.enabled: false
 

节点2

修改一下

network.host: 192.168.23.13

discovery.seed_hosts: ["192.168.23.12:9300", "192.168.23.14:9300"]

cluster.initial_master_nodes: ["node-1"]

节点3

network.host: 192.168.23.14

discovery.seed_hosts: ["192.168.23.12:9300", "192.168.23.13:9300"]

cluster.initial_master_nodes: ["node-1"]

几台机器都修改jvm.options文件

-Xms512M
-Xmx512M

2.5 修改 sysctl.conf

Virtual memory | Elasticsearch Guide [8.9] | Elastic

[root@localhost apps]#vim /etc/sysctl.conf
vm.max_map_count=262144
[root@localhost apps]# sysctl -p

2.6 修改kibana下的

/usr/local/apps/kibana-8.9.1/config/kibana.yml

server.port: 5601

server.host: "192.168.23.12"

3.启动

3.1 切换到kibana

如果遇到权限问题

可以使用root用户赋权,如: chown  -R kibana kibana   /usr/local/apps/elasticsearch-8.9.1

[root@localhost elasticsearch-8.9.1]# su kibana

3.2 启动elasticsearch

[kibana@localhost bin]$ /usr/local/apps/elasticsearch-8.9.1/bin/elasticsearch

三台启动完成后,在主节点上启动

3.3 启动kibana

[kibana@localhost bin]$ /usr/local/apps/kibana-8.9.1/bin/kibana

初次启动需要在浏览器上访问一下控制台打的URL,然后才能正常访问

http://192.168.23.12:5601/

3.4 验证节点情况

http://192.168.23.13:9200/_cat/nodes

192.168.23.12 19 92 4 0.09 0.31 0.27 cdfhilmrstw - node-1
192.168.23.14 30 92 4 0.02 0.22 0.19 cdfhilmrstw - node-3
192.168.23.13 30 92 6 0.05 0.31 0.24 cdfhilmrstw * node-2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Elasticsearch7.9.0是一个开源的分布式搜索和分析引擎,用于构建高效、可扩展的实时搜索解决方案。要搭建Elasticsearch7.9.0集群,需要按照以下步骤进行操作: 1. 下载和安装Elasticsearch7.9.0:从官方网站上下载Elasticsearch7.9.0压缩包,并解压到合适的目录下。 2. 配置Elasticsearch集群参数:在每个节点上的elasticsearch.yml配置文件中,设置集群名称、节点名称、绑定IP地址等参数。确保每个节点的配置文件相同,以便节点可以识别彼此。 3. 修改JVM配置:根据服务器的硬件配置和需求,修改jvm.options文件中的内存分配参数,以确保Elasticsearch能够充分利用可用的系统资源。 4. 启动Elasticsearch节点:在每个节点的终端或命令行中,切换到Elasticsearch的安装目录,并运行./bin/elasticsearch命令来启动节点。确保每个节点都能正常启动。 5. 集群发现和节点自动加入:在elasticsearch.yml配置文件中,配置集群发现机制,如使用单播或多播,以及设置初始主节点。这将使得新的节点能够自动连接到现有的Elasticsearch集群。 6. 验证集群状态:使用curl或其他HTTP客户端发送请求到任意一个节点的IP地址和端口号,查看集群的状态信息。确保所有的节点都连接到集群,并且状态正常。 7. 索引和搜索数据:使用Elasticsearch的REST API或Java客户端,可以索引和搜索数据。通过创建索引、定义映射、增删改查操作可以实现灵活和高效的搜索和分析功能。 8. 监控集群健康和性能:使用Elasticsearch提供的监控工具或第三方插件,可以实时监控集群的健康状态、性能指标和查询性能。这有助于及时发现和解决潜在的问题。 总结:以上是搭建Elasticsearch7.9.0集群的基本步骤。搭建集群后,可以实现数据的高可用性、可扩展性和分布式计算,为企业提供全文搜索、日志分析等功能。通过合理的集群配置、优化和监控,可以提高集群的性能和稳定性。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值