首页 > 其他分享 >es8 通过 rpm 部署集群

es8 通过 rpm 部署集群

时间:2025-01-21 19:31:56浏览次数:1  
标签:01 ca es8 certs elasticsearch 分片 集群 rpm es

系统配置

ulimit 设置

echo "*  soft  nofile  65535" >> /etc/security/limits.conf
echo "*  hard  nofile  65535" >> /etc/security/limits.conf

ubuntu 系统

vim /etc/pam.d/su

session    required   pam_limits.so

elasticsearch.service

sed -i -e '/ExecStart/a LimitMEMLOCK=infinity' /lib/systemd/system/elasticsearch.service

sysctl

echo "vm.max_map_count=655360" >> /etc/sysctl.conf
echo "net.ipv4.tcp_retries2=5" >> /etc/sysctl.conf
echo "vm.swappiness=1" >> /etc/sysctl.conf 
sysctl -p

集群规划

节点 hostname
192.168.174.100 es-01
192.168.174.101 es-02
192.168.174.102 es-03

安装 elasticsearch

export ELASTIC_PASSWORD="py7Ki=JiW=WCxnDrKV4-"
yum -y install elasticsearch
Dependencies resolved.
=======================================================================================================================================================================
 Package                                   Architecture                       Version                              Repository                                     Size
=======================================================================================================================================================================
Installing:
 elasticsearch                             x86_64                             8.17.0-1                             elasticsearch-8.x                             607 M

Transaction Summary
=======================================================================================================================================================================
Install  1 Package

Total download size: 607 M
Installed size: 1.1 G
Downloading Packages:
elasticsearch-8.17.0-x86_64.rpm                                                                                                         55 MB/s | 607 MB     00:10    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                   55 MB/s | 607 MB     00:10     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                               1/1 
  Running scriptlet: elasticsearch-8.17.0-1.x86_64                                                                                                                 1/1 
Creating elasticsearch group... OK
Creating elasticsearch user... OK

  Installing       : elasticsearch-8.17.0-1.x86_64                                                                                                                 1/1 
  Running scriptlet: elasticsearch-8.17.0-1.x86_64                                                                                                                 1/1 
--------------------------- Security autoconfiguration information ------------------------------

Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.

The generated password for the elastic built-in superuser is : py7Ki=JiW=WCxnDrKV4-

If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>'
after creating an enrollment token on your existing cluster.

You can complete the following actions at any time:

Reset the password of the elastic built-in superuser with 
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.

Generate an enrollment token for Kibana instances with 
 '/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.

Generate an enrollment token for Elasticsearch nodes with 
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.

-------------------------------------------------------------------------------------------------
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
 sudo systemctl start elasticsearch.service

  Verifying        : elasticsearch-8.17.0-1.x86_64                                                                                                                 1/1 

Installed:
  elasticsearch-8.17.0-1.x86_64                                                                                                                                        

Complete!

生成集群证书

证书路径

/usr/share/elasticsearch

instances.yml

echo >> /usr/share/elasticsearch/config/certs/instances.yml <<EOF
instances:
  - name: "es-01" 
    ip: 
      - "192.168.174.100"
      - "172.16.174.100"
      - "127.0.0.1"
    dns: 
      - "es-01"
      - "localhost"
  - name: "es-02"
    ip:
      - "192.168.174.101"
      - "172.16.174.101"
      - "127.0.0.1"
    dns: 
      - "es-02"
      - "localhost"
  - name: "es-03"
    ip:
      - "192.168.174.102"
      - "172.16.174.102"
      - "127.0.0.1"
    dns: 
      - "es-03"
      - "localhost"
EOF

生成 ca

cd /usr/share/elasticsearch
bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip
unzip config/certs/ca.zip -d config/certs

生成证书

cd /usr/share/elasticsearch
bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key
unzip config/certs/certs.zip -d config/certs

查看证书文件

tree config/certs
config/certs
├── ca
│   ├── ca.crt
│   └── ca.key
├── ca.zip
├── certs.zip
├── instances.yml
├── es-01
│   ├── es-01.crt
│   └── es-01.key
├── es-02
│   ├── es-02.crt
│   └── es-02.key
└── es-03
    ├── es-03.crt
    └── es-03.key

复制证书到各个节点

scp /usr/share/elasticsearch/config/certs/* 192.168.174.100:/etc/elasticsearch/certs
scp /usr/share/elasticsearch/config/certs/* 192.168.174.101:/etc/elasticsearch/certs
scp /usr/share/elasticsearch/config/certs/* 192.168.174.102:/etc/elasticsearch/certs

配置 elasticsearch

修改配置文件

sed -i -e 's@#cluster.name: my-application@cluster.name: es-cluster@' -e 's@#node.name: node-1@node.name: es-03@' -e 's@#http.port: 9200@http.port: 19200@' -e '/#discovery.seed_hosts/a discovery.seed_hosts: ["es-01", "es-02", "es-03"]' -e '/#cluster.initial_master_nodes/a cluster.initial_master_nodes: ["es-01", "es-02", "es-03"]' -e 's@#transport.host: 0.0.0.0@transport.host: 0.0.0.0@' /etc/elasticsearch/elasticsearch.yml

查看配置文件

egrep -v '^$|^#' /etc/elasticsearch/elasticsearch.yml
cluster.name: es-cluster
node.name: es-01
path.data: /data/disk1/elasticsearch/data
path.logs: /data/disk1/elasticsearch/logs
http.port: 19200
action.auto_create_index: .monitoring*,.watches,.triggered_watches,.watcher-history*,.ml*
discovery.seed_hosts: ["es-01", "es-02", "es-03"]
cluster.initial_master_nodes: ["es-01", "es-02", "es-03"]
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
  enabled: true
  key: certs/es-01/es-01.key
  certificate: certs/es-01/es-01.crt
  certificate_authorities: certs/ca/ca.crt
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  key: certs/es-01/es-01.key
  certificate: certs/es-01/es-01.crt
  certificate_authorities: certs/ca/ca.crt
http.host: 0.0.0.0
transport.host: 0.0.0.0

运行 elasticsearch

 systemctl start elasticsearch --now

重置内置超级用户密码

/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
This tool will reset the password of the [elastic] user.
You will be prompted to enter the password.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]:       # 输入密码
Re-enter password for [elastic]:    # 确认密码
Password for the [elastic] user successfully reset.

验证集群状态

curl --cacert /etc/elasticsearch/certs/ca.crt -u elastic https://192.168.174.100:19200/_cluster/health?pretty
{
  "cluster_name" : "es-cluster",
  "status" : "green",      # 
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 3,
  "active_shards" : 6,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "unassigned_primary_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
cluster_name: 集群的名称,这里是 "es-cluster"。
status: 集群的状态,这里是 "green",表示集群健康且所有主要索引都已分配。
timed_out: 是否超时。如果为 true,则表示在获取集群状态时遇到了超时。这里为 false 表示没有超时。
number_of_nodes: 集群中的节点总数,这里是 3。
number_of_data_nodes: 集群中的数据节点数,这里是 3。在Elasticsearch中,数据节点存储索引数据并参与到集群的搜索和查询操作。
active_primary_shards: 活跃的主要分片数,这里是 3。一个分片可以是主分片或副本分片,主分片是存储文档数据的分片。
active_shards: 活跃的分片总数,因为每个主分片通常有一个或多个副本分片,所以这里的数量通常是主分片的两倍加一起(如果不考虑故障转移等情况)。这里是 6。
relocating_shards: 正在迁移的分片数。当节点出现故障或发生其他变更时,分片可能会从一个节点迁移到另一个节点。这里为 0 表示没有正在迁移的分片。
initializing_shards: 正在初始化的分片数。新加入的分片可能需要初始化。这里为 0 表示没有正在初始化的分片。
unassigned_shards: 未分配的分片数。如果一个分片不能被分配到任何节点,则它处于未分配状态。这里为 0 表示所有分片都已分配。
unassigned_primary_shards: 未分配的主要分片数。这里为 0 表示所有的主要分片都已分配。
delayed_unassigned_shards: 延迟未分配的分片数。这里为 0 表示没有延迟未分配的分片。
number_of_pending_tasks: 待处理的任务数。这些任务通常与分片的分配或移动有关。这里为 0 表示没有待处理的任务。
number_of_in_flight_fetch: 正在执行中的获取任务数,通常与分片的移动有关。这里为 0 表示没有正在执行中的获取任务。
task_max_waiting_in_queue_millis: 任务在队列中等待的最大时间(毫秒)。这里为 0 表示没有任务在等待队列中。
active_shards_percent_as_number: 活跃分片的百分比,以数字形式表示。因为所有分片都是活跃的(从上面的字段可以看出),所以这里是 100.0%。

参考文档

 https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html

标签:01,ca,es8,certs,elasticsearch,分片,集群,rpm,es
From: https://www.cnblogs.com/wangguishe/p/18683507

相关文章

  • 安装集群的过程有哪些?
    Kubernetes(K8s)安装过程的步骤,概述如下:1.准备环境集群节点:确保至少有两台或更多的服务器,这些节点可以是物理机或云主机。集群需要至少一个控制平面节点和多个工作节点。操作系统:选定合适的操作系统(如Ubuntu、CentOS等)。容器运行时环境:安装Docker或其他容器运行时(如cont......
  • Arduino 平台下 ESP32-P4 驱动ES8311实现 MP3音频文件播放-方式2
    arduino平台下ESP32-P4开发板驱动ES8311,从SD_MMC读取MP3文件播实验程序,方式2。这个测试程序与之前的有所不同,直接使用了arduino-audio-drivers库中的ES8311驱动文件。采用arduino-audio-drivers比单独使用ES8311驱动来的更好,毕竟这个库支持ES8388,ES8311等多种芯片,程序......
  • Kubernetes 集群中安装和配置 Kubernetes Dashboard
    前言上篇成功部署Kubernetes集群后,为了方便管理和监控集群资源,安装KubernetesDashboard显得尤为重要。KubernetesDashboard是一个通用的、基于Web的UI,旨在让用户轻松地部署容器化应用到Kubernetes集群,并对这些应用进行故障排查以及管理集群资源。通过Dashboard,你......
  • InfluxDB:单节点与集群部署实操及 java.lang.RuntimeException 报错的高效解决方案
    前言:在当今数据驱动的时代,时序数据的管理和分析变得愈发重要。InfluxDB作为一款高性能、开源的时序数据库,凭借其强大的写入性能、灵活的查询功能以及对大规模数据的高效处理能力,成为了众多开发者的首选工具。无论是用于监控系统、物联网设备数据存储,还是日志分析,InfluxDB......
  • 蓝易云 - CentOS7系统编译安装SRPM源码包的多种方式
    在CentOS7系统中,编译安装SRPM(SourceRPM)源码包有多种方式。SRPM是一种软件包源代码的打包格式,它包含了软件的源代码和.spec文件,用于构建RPM软件包。以下是几种在CentOS7系统中编译安装SRPM源码包的方式:方式1:使用rpmbuild命令安装编译工具和RPM构建依赖:sudoyumgroupinsta......
  • 彻底讲清楚 单体架构、集群架构、分布式架构及扩展架构
    目录什么是系统架构单体架构介绍示例图优点缺点集群架构介绍示意图优点缺点分布式架构示意图优点缺点生态扩展介绍示意图优点缺点扩展:分布式服务解析纵切拆服务全链路追踪能力循环依赖全链路日志(End-to-EndLogs)阅前提醒:前后端分离架构是前后端之......
  • 【linux合集】redis集群部署
    集群式部署redis介绍:三台机器001、002、003然后再三台机器上面都部署redis_6379、redis_6380做主从,然后三台机器上面做集群1、安装/解压redismkdir-p/data/applications/wgethttps://download.redis.io/releases/redis-5.0.14.tar.gztar-xzf./redis-5.0.14.tar.gzcd......
  • rpm安装clickhouse(24.11.8.5单机)
    环境:OS:Centos7db:24.11.8.51.下载安装介质下载地址为:https://packagecloud.io/Altinity/clickhouse或是这里下载https://mirrors.tuna.tsinghua.edu.cn/clickhouse/rpm/stable/x86_64/我这里下载的是如下三个包clickhouse-client-24.8.11.5.noarch.rpmclickhouse-common-sta......
  • 集群虚谷数据库锁等待处理方法
    模拟集群下虚谷数据库锁冲突情景开启三个会话,会话1在节点1上,会话2在节点2上,会话1和会话2用于模拟锁冲突,会话3在节点1上,用于查看锁和会话信息:会话1:关闭自动提交,并更新id=1的数据SETauto_commitoff;updatetasetname='session1'whereid=1;会话2:关闭自动提交SETauto_......
  • Django Admin 实战:实现 ECS 集群批量同步功能
    引言在管理大规模AWSECS(ElasticContainerService)集群时,保持本地数据库与AWS实际状态的同步是一项关键任务。手动更新既耗时又容易出错,因此自动化这个过程变得尤为重要。本文将介绍如何利用DjangoAdmin的自定义动作功能来实现ECS集群的批量同步操作,从而大幅......