Linux安装elasticsearch单机版

下载地址:

Download Elasticsearch | Elastic

下载的安装包是elasticsearch-7.12.0-linux-x86_64.tar.gz

解压缩文件

复制代码
tar -zxvf  elasticsearch-7.12.0-linux-x86_64.tar.gz

#编辑文件
vim config/elasticsearch.yml
 
 
 
# 加入如下配置
# 集群名称,一个 Elasticsearch 集群有一个唯一的名字标识,默认就是elasticsearch
cluster.name: elasticsearch
#数据存放路径
path.data: /data/esdata/data
#日志存放路径
path.logs: /data/esdata/data/logs 
# 节点名称,如果未设置,默认为随机生成的名称
node.name: node-1
#本机IP地址(设置可以访问的ip地址)
network.host: 0.0.0.0
#es暴露对外的端口
http.port: 9200
#初始主节点的名称或ID,可放集群中可知的node.name
cluster.initial_master_nodes: ["node-1"]

修改配置文件/etc/sysctl.conf

在配置文件中加入以下内容:

一个进程可以拥有的 VMA(虚拟内存区域)的数量,默认值为 65536

vm.max_map_count=655360

不然启动会报错

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

重新加载

复制代码
 sysctl -p

后台启动es

./bin/elasticsearch -d

配置用户名密码

启用 X-Pack 安全功能

在 elasticsearch.yml 配置文件中,添加以下配置来启用基本安全功能:

复制代码
xpack.security.enabled: true
#discovery.type: single-node
xpack.security.transport.ssl.enabled: true

启用SSL

当设置了 network.host: 0.0.0.0 之后,es会无法启动,要求你配置SSL,启动会提示

io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: No available authentication scheme

使用 elasticsearch-certutil 工具生成自签名证书以及相关配置如下:

运行 elasticsearch-certutil ca 命令:
复制代码
bin/elasticsearch-certutil ca

你将被提示输入证书相关的信息。一般情况下,可以直接按 Enter 使用默认值。

选择输出格式:

你会看到如下提示:

复制代码
Please enter the desired output file [elastic-stack-ca.p12]:

输入文件名或按 Enter 使用默认文件名 elastic-stack-ca.p12。

接下来你会看到:

复制代码
Enter password for elastic-stack-ca.p12 :

输入一个密码并记住它,你将在稍后使用。

最终,你会看到如下信息:

复制代码
CA certificate written to /path/to/elasticsearch/bin/elastic-stack-ca.p12
运行 elasticsearch-certutil cert 命令并指定 CA 证书:
复制代码
./bin/elasticsearch-certutil --ca elastic-stack-ca.p12

你将被提示输入 CA 证书的密码(之前设置的密码)。

输入一个密码并记住它,你将在配置 Elasticsearch 时使用它。

设置为如下时访问不需要密码

复制代码
cluster.initial_master_nodes: ["node-1"]
xpack.security.enabled: true
#discovery.type: single-node
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /home/es/elasticsearch-7.12.0/config/elastic-certificates.p12
xpack.security.transport.ssl.keystore.password: password
xpack.security.transport.ssl.truststore.path: /home/es/elasticsearch-7.12.0/config/elastic-certificates.p12
xpack.security.transport.ssl.truststore.password: password

如果要输入密码登录,在上述生成秘钥时密码敲回车,不输入密码!

bin/elasticsearch-certutil ca

配置文件为

复制代码
cluster.initial_master_nodes: ["node-1"]
xpack.security.enabled: true
#discovery.type: single-node
#xpack.license.self_generated.type: basic

xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /home/es/elasticsearch-7.12.0/config/elastic-certificates.p13
xpack.security.transport.ssl.truststore.path: /home/es/elasticsearch-7.12.0/config/elastic-certificates.p13

设置内置用户的密码

运行以下命令来设置内置用户的密码,该命令会提示你设置几个内置用户(如 elastic、kibana、logstash_system 等)的密码。

复制代码
./bin/elasticsearch-setup-passwords interactive
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]

重启es后,访问需要用户密码

参考文章:

Linux安装elasticsearch单机版_linux 安装es-CSDN博客

Elasticsearch单机部署(Linux)_elasticsearch 单机部署-CSDN博客

Linux安装elasticsearch单机版_linux 安装es-CSDN博客

https://www.jianshu.com/p/ea1c9cb14515

ElasticSearch 7配置密码认证及创建用户_please enter the desired output file [elastic-stac-CSDN博客

相关推荐
zskj_zhyl3 小时前
科技向暖,银发无忧:十五五规划中智慧养老的温度革命
大数据·人工智能·科技·物联网·生活
muxue1784 小时前
Hadoop集群搭建(上):centos 7为例(已将将安装所需压缩包统一放在了/opt/software目录下)
大数据·hadoop·centos
阿里云大数据AI技术4 小时前
【跨国数仓迁移最佳实践11】基于 MaxCompute Resource & Quota策略优化实现资源管理性能与成本最优平衡
大数据
Elastic 中国社区官方博客5 小时前
Elasticsearch 的结构化文档配置 - 递归分块实践
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索·jenkins
神的孩子都在歌唱5 小时前
Elasticsearch 7.6 安装 Jieba 中文分词插件完整教程
elasticsearch·中文分词·jenkins
草明5 小时前
Elasticsearch 报错:index read-only / allow delete (api) 深度解析与解决方案
大数据·elasticsearch·jenkins
得帆云5 小时前
低代码高频实践场景系列之一——EHS系统
大数据·人工智能·物联网
失散136 小时前
分布式专题——55 ElasticSearch性能调优最佳实践
java·分布式·elasticsearch·架构
Elasticsearch6 小时前
在 Elastic Observability 中使用 OpAmp 对 EDOT SDK 进行集中配置
elasticsearch
yachuan_qiao6 小时前
专业的建筑设备监控管理系统选哪家
大数据·运维·python