当前位置: 首页 > news >正文

ElasticSearch9.2单节点部署

背景

众所周知 es是漏洞重灾区了,每次安全部门下发高危漏洞清单上都有它。可以说是军书十二卷,卷卷有爷名了。趁这次机会记录一下当前最新版本的ES部署的详细步骤。

image

 

准备工作

创建es用户,配置系统优化参数和es用户文件句柄数。

1. 创建专用运行用户
# 创建用户组和用户
groupadd elastic
useradd -g elastic -m -d /home/elastic elastic
# 设置密码(自定义,记好)
passwd elastic
xxxxxx2. 关闭防火墙和 SELinux
# 临时关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
# 临时关闭SELinux
setenforce 0
# 永久关闭SELinux(重启生效)
sed -i 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config3. 配置系统内核参数(ES 强制要求)
vi /etc/sysctl.conf# ES内核参数
vm.max_map_count=262144
fs.file-max=6553560
net.ipv4.ip_local_port_range=1024 65535
net.core.somaxconn=32768# 执行使之生效
sysctl -p4. 配置用户资源限制(ES 强制要求)
vi /etc/security/limits.conf# elastic用户资源限制,文件末尾新增
elastic soft nofile 65535
elastic hard nofile 65535
elastic soft nproc 4096
elastic hard nproc 4096
elastic soft memlock unlimited
elastic hard memlock unlimited重新登录生效
su - elastic
exit5. 创建部署目录
# 创建根目录,授权给elastic用户
mkdir -p /data/elastic/{elasticsearch,kibana,data,logs}
chown -R elastic:elastic /data/elastic
chmod -R 755 /data/elastic

二、Elasticsearch 9.2.4 安装与配置

1. 上传并解压二进制包
# 切换到临时目录
cd /tmp
curl -o elasticsearch-9.2.4-linux-x86_64.tar.gz https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.2.4-linux-x86_64.tar.gz
# 解压到ES程序目录(解压后会有elasticsearch-9.2.4子目录)
tar -zxvf elasticsearch-9.2.4-linux-x86_64.tar.gz -C /data/elastic/elasticsearch
# 创建软链接(方便后续升级,无需修改配置路径)
ln -s /data/elastic/elasticsearch/elasticsearch-9.2.4 /data/elastic/elasticsearch/current
# 授权目录给elastic用户
chown -R elastic:elastic /data/elastic/elasticsearch2. 核心配置文件修改
# 切换为elastic用户
su - elastic
# 进入配置目录
cd /data/elastic/elasticsearch/current

生成自签名证书

[elastic@elk-server current]$ ./bin/elasticsearch-certutil http## Elasticsearch HTTP Certificate UtilityThe 'http' command guides you through the process of generating certificates
for use on the HTTP (Rest) interface for Elasticsearch.This tool will ask you a number of questions in order to generate the right
set of files for your needs.## Do you wish to generate a Certificate Signing Request (CSR)?A CSR is used when you want your certificate to be created by an existing
Certificate Authority (CA) that you do not control (that is, you don't have
access to the keys for that CA).If you are in a corporate environment with a central security team, then you
may have an existing Corporate CA that can generate your certificate for you.
Infrastructure within your organisation may already be configured to trust this
CA, so it may be easier for clients to connect to Elasticsearch if you use a
CSR and send that request to the team that controls your CA.If you choose not to generate a CSR, this tool will generate a new certificate
for you. That certificate will be signed by a CA under your control. This is a
quick and easy way to secure your cluster with TLS, but you will need to
configure all your clients to trust that custom CA.Generate a CSR? [y/N]N## Do you have an existing Certificate Authority (CA) key-pair that you wish to use to sign your certificate?If you have an existing CA certificate and key, then you can use that CA to
sign your new http certificate. This allows you to use the same CA across
multiple Elasticsearch clusters which can make it easier to configure clients,
and may be easier for you to manage.If you do not have an existing CA, one will be generated for you.Use an existing CA? [y/N]n
A new Certificate Authority will be generated for you## CA Generation OptionsThe generated certificate authority will have the following configuration values.
These values have been selected based on secure defaults.
You should not need to change these values unless you have specific requirements.Subject DN: CN=Elasticsearch HTTP CA
Validity: 5y
Key Size: 2048
Key Usage: keyCertSign,cRLSignDo you wish to change any of these options? [y/N]y## What should your CA be named?Every client that connects to your Elasticsearch cluster will need to trust
this custom Certificate Authority.
It is helpful to have a meaningful name for this CACA Name [CN=Elasticsearch HTTP CA]   ## How long should your CA be valid?Every certificate has an expiry date. When the expiry date is reached, clients
will stop trusting your Certificate Authority and TLS connections will fail.We recommend that you set this to a long duration (3 - 5 years) and then perform a
manual update a few months before it expires.
You may enter the validity period in years (e.g. 3Y), months (e.g. 18M), or days (e.g. 90D)
CA Validity [5y] ## What key size should your CA have?The RSA private key for your Certificate Authority has a fixed 'key size' (in bits).
Larger key sizes are generally more secure, but are also slower.We recommend that you use one of 2048, 3072 or 4096 bits for your key.
Key Size [2048] ## What key usage should your CA have?The key usage extension defines the purpose of the key contained in the certificate.
The usage restriction might be employed when a key, that could be used for more than 
one operation, is to be restricted.
You may enter the key usage as a comma-delimited list of following values: - cRLSign- dataEncipherment- decipherOnly- digitalSignature- encipherOnly- keyAgreement- keyCertSign- keyEncipherment- nonRepudiationKey Usage [keyCertSign,cRLSign] Subject DN: CN=Elasticsearch HTTP CA
Validity: 5y
Key Size: 2048
Key Usage: keyCertSign,cRLSignDo you wish to change any of these options? [y/N]n## CA passwordWe recommend that you protect your CA private key with a strong password.
If your key does not have a password (or the password can be easily guessed)
then anyone who gets a copy of the key file will be able to generate new certificates
and impersonate your Elasticsearch cluster.IT IS IMPORTANT THAT YOU REMEMBER THIS PASSWORD AND KEEP IT SECURECA password:  [<ENTER> for none]## How long should your certificates be valid?Every certificate has an expiry date. When the expiry date is reached clients
will stop trusting your certificate and TLS connections will fail.Best practice suggests that you should either:
(a) set this to a short duration (90 - 120 days) and have automatic processes
to generate a new certificate before the old one expires, or
(b) set it to a longer duration (3 - 5 years) and then perform a manual update
a few months before it expires.You may enter the validity period in years (e.g. 3Y), months (e.g. 18M), or days (e.g. 90D)For how long should your certificate be valid? [5y] ## Do you wish to generate one certificate per node?If you have multiple nodes in your cluster, then you may choose to generate a
separate certificate for each of these nodes. Each certificate will have its
own private key, and will be issued for a specific hostname or IP address.Alternatively, you may wish to generate a single certificate that is valid
across all the hostnames or addresses in your cluster.If all of your nodes will be accessed through a single domain
(e.g. node01.es.example.com, node02.es.example.com, etc) then you may find it
simpler to generate one certificate with a wildcard hostname (*.es.example.com)
and use that across all of your nodes.However, if you do not have a common domain name, and you expect to add
additional nodes to your cluster in the future, then you should generate a
certificate per node so that you can more easily generate new certificates when
you provision new nodes.Generate a certificate per node? [y/N]y## What is the name of node #1?This name will be used as part of the certificate file name, and as a
descriptive name within the certificate.You can use any descriptive name that you like, but we recommend using the name
of the Elasticsearch node.node #1 name: es001## Which hostnames will be used to connect to es001?These hostnames will be added as "DNS" names in the "Subject Alternative Name"
(SAN) field in your certificate.You should list every hostname and variant that people will use to connect to
your cluster over http.
Do not list IP addresses here, you will be asked to enter them later.If you wish to use a wildcard certificate (for example *.es.example.com) you
can enter that here.Enter all the hostnames that you need, one per line.
When you are done, press <ENTER> once more to move on to the next step.abc.es.comYou entered the following hostnames.- abc.es.comIs this correct [Y/n]y## Which IP addresses will be used to connect to es001?If your clients will ever connect to your nodes by numeric IP address, then you
can list these as valid IP "Subject Alternative Name" (SAN) fields in your
certificate.If you do not have fixed IP addresses, or not wish to support direct IP access
to your cluster then you can just press <ENTER> to skip this step.Enter all the IP addresses that you need, one per line.
When you are done, press <ENTER> once more to move on to the next step.192.168.0.45You entered the following IP addresses.- 192.168.0.45Is this correct [Y/n]Y## Other certificate optionsThe generated certificate will have the following additional configuration
values. These values have been selected based on a combination of the
information you have provided above and secure defaults. You should not need to
change these values unless you have specific requirements.Key Name: es001
Subject DN: CN=es001
Key Size: 2048
Key Usage: digitalSignature,keyEnciphermentDo you wish to change any of these options? [y/N]n
Generate additional certificates? [Y/n]n## What password do you want for your private key(s)?Your private key(s) will be stored in a PKCS#12 keystore file named "http.p12".
This type of keystore is always password protected, but it is possible to use a
blank password.If you wish to use a blank password, simply press <enter> at the prompt below.
Provide a password for the "http.p12" file:  [<ENTER> for none]## Where should we save the generated files?A number of files will be generated including your private key(s),
public certificate(s), and sample configuration options for Elastic Stack products.These files will be included in a single zip archive.What filename should be used for the output zip file? [/data/elastic/elasticsearch/elasticsearch-9.2.4/elasticsearch-ssl-http.zip] /data/elastic/elasticsearch/current/certs/elasticsearch-ssl-http.zipZip file written to /data/elastic/elasticsearch/current/certs/elasticsearch-ssl-http.zip

 

http://www.jsqmd.com/news/321059/

相关文章:

  • 突破规模极限:AI前沿五大颠覆性技术洞察
  • Gitee:本土化技术生态如何重塑中国开发者协作范式
  • 好写作AI:法学论文中案例检索与逻辑链生成的智能辅助
  • 上海靠谱的护肤品费用多少,有性价比高的推荐吗?
  • 网络安全怎么入门?零基础看这一篇就够了!
  • 流量分析进阶(一):RCTF2025-Shadows of Asgard - 教程
  • 售后完善的AI智能办公鼠标价格多少,南方网通费用高吗
  • 2026年Apple Watch苹果手表维修中心推荐:基于紧急与日常场景深度评测与排名
  • 2026年金昌装修品牌机构排名,有实力的装修专业公司哪家性价比高
  • 2026年修手表服务网点综合评测报告——年度服务能力盘点与用户口碑实证分析
  • 好写作AI:环境科学跨尺度数据论文的AI综合写作模式
  • 长春通过率高的消防设施操作员考证机构靠谱的有哪些?
  • 2026年钟表维修服务网点推荐与评价:解构高端腕表后市场服务新标准
  • 3.22 Kubebuilder实战进阶:控制器测试、Webhook、多版本CRD完整实现
  • 吐血推荐自考必备TOP10 AI论文软件
  • 2026年Apple Watch苹果手表维修推荐:紧急与日常场景评测,针对高价与等待痛点附排名
  • 【自选股】【持仓股】
  • 简单理解:STM32TrustedPackageCreator软件和STM32CubeProgrammer软件
  • 珠海百爱科技GEO服务专业不?价格贵不贵?
  • 【概念板块和行业板块】
  • 2026年北京钟表维修网点推荐:权威评测揭示四大服务中心综合排名
  • 【收藏必学】大模型(LLM)技术揭秘:从预训练到RLHF的完整路径
  • 收藏!AI会取代程序员工作吗?Java开发者转型大模型必看指南
  • 2026年收纳袋排名,浙江天森大容量款式佳,权威材质有保障
  • 鹰潭市英语雅思培训机构推荐? 2026权威测评出国雅思辅导机构口碑榜单
  • 2026年防水背衬板制造企业推荐,靠谱品牌全解读
  • 收藏!未来10年,最有发展潜力的职业领域,小白/程序员必看
  • 分期乐购物额度回收攻略,零风险变现指南分享
  • 新余市英语雅思培训机构推荐:2026权威测评出国雅思辅导机构口碑榜单
  • 2026年值得关注的护肤品生产企业,广州靠谱的厂商有这些