Jast blog Jast blog
首页
  • 《Ambari自定义开发教程》笔记
  • 《CDH教程》笔记
  • 《ClickHouse教程》笔记
  • 《HDFS教程》笔记
  • 《DolphinScheduler教程》笔记
  • 《Hbase教程》笔记
  • 《Iceberg教程》笔记
  • 《Hive教程》笔记
  • 《Flume教程》笔记
  • 《Kafka教程》笔记
  • 《Impala教程》笔记
  • 《Hue教程》笔记
  • 《Spark教程》笔记
  • 《Flink教程》笔记
  • 《Phoenix教程》笔记
  • 《ElasticSearch教程》笔记
  • 《Kylin教程》笔记
  • 《Storm教程》笔记
  • 《Yarn教程》笔记
  • 《Presto教程》笔记
  • 《图数据库教程》笔记
  • 《Kerberos教程》笔记
  • 《Maxwell教程》笔记
  • 《MinIO教程》笔记
  • 《DataX教程》笔记
  • 《Superset教程》笔记
  • 《IOTDB教程》笔记
  • 《大数据相关》笔记
  • 《PaddleNLP教程》笔记
  • 《Nginx教程》笔记
  • 《Java技术文档》
  • 《Maven教程》笔记
  • 《IDEA使用教程》
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档

Jast-zsh

如果你知道你要去哪里,全世界都会给你让路。
首页
  • 《Ambari自定义开发教程》笔记
  • 《CDH教程》笔记
  • 《ClickHouse教程》笔记
  • 《HDFS教程》笔记
  • 《DolphinScheduler教程》笔记
  • 《Hbase教程》笔记
  • 《Iceberg教程》笔记
  • 《Hive教程》笔记
  • 《Flume教程》笔记
  • 《Kafka教程》笔记
  • 《Impala教程》笔记
  • 《Hue教程》笔记
  • 《Spark教程》笔记
  • 《Flink教程》笔记
  • 《Phoenix教程》笔记
  • 《ElasticSearch教程》笔记
  • 《Kylin教程》笔记
  • 《Storm教程》笔记
  • 《Yarn教程》笔记
  • 《Presto教程》笔记
  • 《图数据库教程》笔记
  • 《Kerberos教程》笔记
  • 《Maxwell教程》笔记
  • 《MinIO教程》笔记
  • 《DataX教程》笔记
  • 《Superset教程》笔记
  • 《IOTDB教程》笔记
  • 《大数据相关》笔记
  • 《PaddleNLP教程》笔记
  • 《Nginx教程》笔记
  • 《Java技术文档》
  • 《Maven教程》笔记
  • 《IDEA使用教程》
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
  • ElasticSearch单机版安装
  • ElasticSearch7集群安装
    • 下载安装包
    • 基础环境安装
      • JDK安装
      • 修改Linux配置
    • 安装ES
    • 启动报错
      • bootstrap check failure [1] of [1]: memory locking requested for elasticsearch process but memory is not locked
    • Kibana简介
    • Kibana下载
    • Kibana安装
  • ElasticSearch-Head浏览器插件离线安装
  • ElasticSearch-SQL浏览器离线插件安装
  • ElasticSearch快照脚本
  • ELasticSearch监控之Cerebro
  • Elasticsearch-SQL
  • ElasticSearch优化指南
  • ElastiSearch Merger
  • Elasticsearch Pipeline 详解
  • ElasticSearch正确的重启方式
  • ElasticSearch查询模板Mustache
  • ElasticSearch索引模板
  • ElasticSearch集群快照
  • ElasticSearch集群修改密码
  • 深入理解ElasticSearch慢查询日志
  • ElasticSearch Kibana白金级破解
  • ElasticSearch API查看集群状态
  • ElasticSearch DSL操作
  • ElasticSearch Script操作数据
  • ElasticSearch中副本和分片如何优化?
  • Docker安装ElasticSearchDump备份数据
  • ElasticSearch使用Grafana监控服务状态
  • Grafana配置ElasitcSearch监控-独立部署版本
  • ElasticSearch批量修改报错
  • ElasticSearch数据版本冲突
  • ElasticSearch索引_cat统计数量与_count统计数量不一致
  • Kibana使用Nginx反向代理设置提示404
  • ElasticSearch优化之线程池介绍
  • 当ElasticSearch时间字段设置多个格式到底是用的哪个?
  • 《ElasticSearch教程》笔记
Jast-zsh
2023-01-12
目录

ElasticSearch7集群安装

[toc]

# ElasticSearch安装

# 下载安装包

下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch (opens new window)

安装版本:7.14.2

image-20230112094348092

# 基础环境安装

# JDK安装

安装es的机器都需要安装

JDK版本11

  • 将安装包移动到/opt目录下
tar -zxvf jdk-11.0.17_linux-x64_bin.tar.gz 
1
  • JDK加入环境变量,进入jdk解压目录,一键设置

    echo 'export JAVA_HOME='$PWD'; export PATH=$JAVA_HOME/bin:$PATH' | sudo tee -a /etc/profile && source /etc/profile
    
    1

# 修改Linux配置

  • 编辑 /etc/security/limits.conf,追加以下内容
* soft nofile 65536
* hard nofile 65536
* hard memlock unlimited
* soft memlock unlimited
1
2
3
4
  • 在/etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
# 或者用下面这个命令一键添加
grep -q '^\s*vm.max_map_count' /etc/sysctl.conf || echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
1
2
3

执行

sysctl -p

  • 修改 /etc/systemd/system.conf
vi /etc/systemd/system.conf
DefaultLimitMEMLOCK=infinity
# 或者用一行命令实现
grep -q '^\s*DefaultLimitMEMLOCK=' /etc/systemd/system.conf || echo 'DefaultLimitMEMLOCK=infinity' | sudo tee -a /etc/systemd/system.conf
1
2
3
4

# 安装ES

需要安装es的集群都要执行以下步骤

  • 将安装包移动到/opt目录
mv elasticsearch-7.14.2-linux-x86_64.tar.gz /opt
1
  • 修改ES使用内存

修改配置文件config/jvm.options

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
-Xms25g
-Xmx25g
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  • 修改elasticsearch.yml配置
cluster.name: dev-cluster
node.name: node-2
node.master: true
node.data: true
node.ingest: true
bootstrap.memory_lock: true
bootstrap.system_call_filter: false
network.host: 172.16.24.192
http.port: 9200
transport.tcp.port: 9300
transport.tcp.compress: true
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes:  ["node-1","node-2","node-3"]
discovery.zen.ping.unicast.hosts: ["172.16.24.191:9300","172.16.24.192:9300","172.16.24.193:9300"]
discovery.zen.minimum_master_nodes: 1
# 启用脚本 默认painless
cluster.routing.allocation.same_shard.host: true
#超时时间
discovery.zen.ping_timeout: 5s
discovery.zen.fd.ping_timeout: 5s
#禁止自动创建索引
action.auto_create_index: true
# 一个集群中的N个节点启动后,才允许进行恢复处理 
gateway.recover_after_nodes: 1
# 设置初始化恢复过程的超时时间,超时时间从上一个配置中配置的N个节点启动后算起 
gateway.recover_after_time: 5m 
# 设置这个集群中期望有多少个节点.一旦这N个节点启动(并且recover_after_nodes也符合), 
# 立即开始恢复过程(不等待recover_after_time超时) 
gateway.expected_nodes: 2
# 线程池  
thread_pool.search.size: 100  
thread_pool.search.queue_size: 1000 
#xpack 插件的授权类型,basic是免费的,还有其他收费版本
xpack.license.self_generated.type: basic
#是否开启安全验证
xpack.security.enabled: true
#是否开启远程访问安全验证
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
# 证书位置,该文件在下面流程会生成
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
# 证书位置,该文件在下面流程会生成
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  • 创建elasticsearch用户
useradd elasticsearch
passwd elasticsearch
1
2
  • 修改目录权限
chown elasticsearch.elasticsearch -R /opt/elasticsearch-7.14.2
1
  • 切换用户启动es
su elasticsearch
cd /opt/elasticsearch-7.14.2
1
2
  • 生成CA证书
bin/elasticsearch-certutil ca
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
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 : #直接回车即可,不用设置密码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

在当前目录可以看到elastic-stack-ca.p12文件

  • 生成密钥
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
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 'cert' mode generates X.509 certificate and private keys.
    * By default, this generates a single certificate and key for use
       on a single instance.
    * The '-multiple' option will prompt you to enter details for multiple
       instances and will generate a certificate and key for each one
    * The '-in' option allows for the certificate generation to be automated by describing
       the details of each instance in a YAML file

    * An instance is any piece of the Elastic Stack that requires an SSL certificate.
      Depending on your configuration, Elasticsearch, Logstash, Kibana, and Beats
      may all require a certificate and private key.
    * The minimum required value for each instance is a name. This can simply be the
      hostname, which will be used as the Common Name of the certificate. A full
      distinguished name may also be used.
    * A filename value may be required for each instance. This is necessary when the
      name would result in an invalid file or directory name. The name provided here
      is used as the directory name (within the zip) and the prefix for the key and
      certificate files. The filename is required if you are prompted and the name
      is not displayed in the prompt.
    * IP addresses and DNS names are optional. Multiple values can be specified as a
      comma separated string. If no IP addresses or DNS names are provided, you may
      disable hostname verification in your SSL configuration.

    * All certificates generated by this tool will be signed by a certificate authority (CA)
      unless the --self-signed command line option is specified.
      The tool can automatically generate a new CA for you, or you can provide your own with
      the --ca or --ca-cert command line options.

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

If you specify any of the following options:
    * -pem (PEM formatted output)
    * -keep-ca-key (retain generated CA key)
    * -multiple (generate multiple certificates)
    * -in (generate certificates from an input file)
then the output will be be a zip file containing individual certificate/key files

Enter password for CA (elastic-stack-ca.p12) : # 直接回车
Please enter the desired output file [elastic-certificates.p12]: # 直接回车
Enter password for elastic-certificates.p12 : # 直接回车

Certificates written to /opt/elasticsearch-7.14.2/elastic-certificates.p12

This file should be properly secured as it contains the private key for 
your instance.

This file is a self contained file and can be copied and used 'as is'
For each Elastic product that you wish to configure, you should copy
this '.p12' file to the relevant configuration directory
and then follow the SSL configuration instructions in the product guide.

For client applications, you may only need to copy the CA certificate and
configure the client to trust this certificate.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

在当前目录会生成elastic-certificates.p12文件

  • 证书移动到指定目录
# 在config目录下创建certs
mkdir config/certs
# 证书移动到certs目录
 mv elastic-certificates.p12 config/certs/
1
2
3
4
  • 后台启动es
cd /opt/elasticsearch-7.14.2
bin/elasticsearch -d
1
2
  • 设置密码

这里可以复制输入

bin/elasticsearch-setup-passwords interactive
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 

Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  • 验证

浏览器访问http://ip:9200/,会提示输入账号密码,输入elastic账号与设置的密码登录即可

{
  "name" : "node-1",
  "cluster_name" : "dev-cluster",
  "cluster_uuid" : "J1_qbq7ZTcC7RC_9HIOJnw",
  "version" : {
    "number" : "7.14.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "6bc13727ce758c0e943c3c21653b3da82f627f75",
    "build_date" : "2021-09-15T10:18:09.722761972Z",
    "build_snapshot" : false,
    "lucene_version" : "8.9.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# 启动报错

# bootstrap check failure [1] of [1]: memory locking requested for elasticsearch process but memory is not locked

修改参数

> vi /etc/systemd/system.conf
DefaultLimitMEMLOCK=infinity

> /etc/security/limits.conf
* hard memlock unlimited
* soft memlock unlimited
1
2
3
4
5
6

# Kibana安装

# Kibana简介

Kibana是一个开源的基于浏览器的分析和可视化平台,可以用于搜索,查看,删除Elasticsearch索引并与存储在Elasticsearch索引中的数据进行交互。可以执行高级数据分析,并且以各种图标、表格和地图的形式可视化数据。

# Kibana下载

下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch (opens new window)

安装版本:7.14.2

image-20230112095310874

# Kibana安装

  • 安装包移动到/opt目录
 mv kibana-7.14.2-linux-x86_64 /opt
1
  • 解压
 tar -zxvf kibana-7.14.2-linux-x86_64.tar.gz 
1
  • 修改配置文件

vi config/kibana.yml

server.host: "172.16.24.191"
elasticsearch.hosts: ["http://172.16.24.191:9200"]
# 设置支持中文
i18n.locale: "zh-CN"
# 在es中设置kibana密码
elasticsearch.username: "kibana"
elasticsearch.password: "设置的密码"
1
2
3
4
5
6
7
  • 修改权限
chown elasticsearch.elasticsearch -R kibana-7.14.2-linux-x86_64
1
  • 启动
nohup bin/kibana > kibana.log &
1
  • 查看进程
ps -ef|grep kibana
elastic+ 11336 11288 99 14:09 pts/0    00:00:12 /opt/kibana-7.14.2-linux-x86_64/node/bin/node --preserve-symlinks-main --preserve-symlinks /opt/kibana-7.14.2-linux-x86_64/src/cli/dist
1
2
  • 访问地址

http://ip:5601

输入账号elastic,与设置的密码登录

image-20230112144634650

上次更新: 2024/09/27, 21:00:17
ElasticSearch单机版安装
ElasticSearch-Head浏览器插件离线安装

← ElasticSearch单机版安装 ElasticSearch-Head浏览器插件离线安装→

最近更新
01
Linux可视化监控
02-26
02
Maven私服搭建
02-26
03
当ElasticSearch时间字段设置多个格式到底是用的哪个?
01-19
更多文章>
Theme by Vdoing | Copyright © 2016-2025 Jast-zsh | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式