elasticsearch-8.7.1 部署手册

该文详细介绍了如何在Linux环境下安装Elasticsearch8.7.1,包括创建用户、下载软件包、解压、生成证书和密钥、迁移凭证、修改配置文件、设置密码、后台启动服务以及调整系统参数等步骤,确保集群的安全运行。
摘要由CSDN通过智能技术生成

1.创建用户

useradd es
su - es

2.下载最新的包
https://www.elastic.co/cn/downloads/elasticsearch
3.解压

tar -zxvf elasticsearch-8.7.1-linux-x86_64.tar.gz
mv elasticsearch-8.7.1 elasticsearch

4.生成证书

./bin/elasticsearch-certutil ca

This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.

The 'ca' mode generates a new 'certificate authority'
This will create a new X.509 certificate and private key that can be used
to sign certificate when running in 'cert' mode.

Use the 'ca-dn' option if you wish to configure the 'distinguished name'
of the certificate authority

By default the 'ca' mode produces a single PKCS#12 output file which holds:
    * The CA certificate
    * The CA's private key

If you elect to generate PEM format certificates (the -pem option), then the output will
be a zip file containing individual files for the CA certificate and private key

Please enter the desired output file [elastic-stack-ca.p12]: 【不用管,直接回车】
Enter password for elastic-stack-ca.p12 : 【输入密码】

5.生成秘钥

./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

6.将凭证迁移到指定目录

mkdir ./config/cert
mv ./elastic-certificates.p12 ./config/cert/
chmod 777 ./config/cert/elastic-certificates.p12

7.修改配置文件

vim ./config/elasticsearch.yml

cluster.name: app-es
node.name: es-node0

path.data: /home/es/elasticsearch/data
path.logs: /home/es/elasticsearch/logs

network.host: 0.0.0.0
http.port: 19200

http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Type,Content-Length

xpack.security.enabled: true
xpack.security.enrollment.enabled: true

xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: cert/elastic-certificates.p12
  truststore.path: cert/elastic-certificates.p12


cluster.initial_master_nodes: ["es-node0"]

8.在各个节点上添加密码

./bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
输入之前设置的密码
./bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
输入之前设置的密码

9.后台启动

./bin/elasticsearch -d

10.设置密码
./bin/elasticsearch-setup-passwords interactive

11.重设默认用户elastic密码
./elasticsearch-reset-password -u elastic -i
执行命令之后,输入y 在输入两次密码即可

12.浏览器访问
http://192.168.2.60:19200/
输入用户名密码,出现下面内容即是安装成功

{
  "name" : "es-node0",
  "cluster_name" : "packdt-es",
  "cluster_uuid" : "iyfbeI0BT-OyMPM_eZMuQg",
  "version" : {
    "number" : "8.7.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "f229ed3f893a515d590d0f39b05f68913e2d9b53",
    "build_date" : "2023-04-27T04:33:42.127815583Z",
    "build_snapshot" : false,
    "lucene_version" : "9.5.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

13.配置系统参数
修改系统参数的目的是确保系统有足够的资源启动 Elasticsearch。

(a)设置内核参数

vi /etc/sysctl.conf
增加以下参数
vm.max_map_count=655360

执行以下命令,确保参数生效:
sysctl -p

(b)设置资源参数

vi /etc/security/limits.conf

在末尾增加如下

* soft nofile 65536
* hard nofile 131072
* soft nproc 65536
* hard nproc 131072

(c)设置用户资源参数

vi /etc/security/limits.d/20-nproc.conf

添加如下:
# 设置elk用户参数
elk    soft    nproc     65536
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值