6、ES单机设置用户名密码、集群设置用户名密码、es-head登录、如何去掉密码

目录

一、ES单节点密码配置

1、修改配置文件

在配置文件中添加如下参数cat config/elasticsearch.yml:

powershell 复制代码
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

2、 重启es服务

关闭es服务如果服务启动(kill进程id)

启动es服务

3,执行修改密码命令

待服务启动完成,且能正常访问后,执行

powershell 复制代码
# 注意在es用户下执行
./bin/elasticsearch-setup-passwords interactive
#执行命令后会提示让输入密码,挨个输入回车即可
# 或者后面这条自动生成密码
./bin/elasticsearch-setup-passwords auto

4、访问服务

二、ES集群密码配置

1、确定主节点

集群此时是启动状态

2、生成elastic-stack-ca.p12

进入主节点的bin目录下执行

powershell 复制代码
./bin/elasticsearch-certutil ca
#会要求输入密码直接回车即可
#执行完成之后会在bin目录的同级目录生成一个文件elastic-stack-ca.p12

3、生成elastic-certificates.p12

再次在bin目录输入命令并指定刚才生成的elastic-stack-ca .p12文件

powershell 复制代码
./bin/elasticsearch-certutil cert -ca ../elastic-stack-ca.p12
#会要求输入密码直接回车即可
#执行完成之后会在bin目录的同级目录生成一个文件elastic-certificates.p12

4、修改配置文件并重启集群

  • 在每一个es节点的config目录下创建一个certs文件夹将生成的elastic-certificates.p12文件复制到其中
  • 修改配置文件,添加如下配置:
powershell 复制代码
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: cert/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: cert/elastic-certificates.p12
#下面这行是为了es-head能够连上
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
  • 重启es集群

5、进行密码配置

​ 在任意点bin下执行设置密码

powershell 复制代码
# 注意在es用户下执行
./bin/elasticsearch-setup-passwords interactive
#执行命令后会提示让输入密码,挨个输入回车即可
# 或者后面这条自动生成密码
./bin/elasticsearch-setup-passwords auto

6、验证

网页登录任意一台服务器:http://192.168.180.46:9200/,需要输入用户名密码

三、es-head登录增加密码的es

访问地址:

http://192.168.180.35:9101/?auth_user=elastic\&auth_password=密码

四、去掉密码

  • 去掉elasticsearch.yml中添加的内容
  • 用es-head 连接es删除索引 .security-7
  • 重启es
相关推荐
Elasticsearch5 小时前
基于 Elasticsearch 与 Jina AI 的全模态智能搜索实践:技术全解析
elasticsearch
北风toto12 小时前
Elasticsearch 8.2.3 快照迁移实战:从备份到恢复的完整指南
大数据·elasticsearch·jenkins
Elasticsearch1 天前
你的日志早已写好告警:在 Elasticsearch 中生成 ES|QL 检测查询
elasticsearch
垚垚学技术_聚焦云原生1 天前
Ansible Vault 安全实践:敏感密码、密钥加密存储方案
安全·elasticsearch·ansible
Flynn Liang2 天前
内存/Redis/PGVector/Milvus/ES 怎么选?Spring AI VectorStore 抽象与向量库选型对照表
redis·elasticsearch·milvus·rag·springai·pgvector·向量库
Elastic 中国社区官方博客3 天前
基于 Jina OCR v1 与 Elasticsearch 的 PDF 智能混合检索与 RAG 系统实战指南
大数据·数据库·elasticsearch·搜索引擎·ocr·jina
Eloudy3 天前
Qwen2.5-14B-Instruct-AWQ 模型文件结构分析
大数据·elasticsearch·搜索引擎
YIN_尹3 天前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Elastic 中国社区官方博客4 天前
Elastic 在《Forrester Wave™:2026 年第四季度智能运维平台》报告中被评为强劲表现者
大数据·运维·数据库·elasticsearch·搜索引擎·全文检索
Elasticsearch4 天前
Elastic Cloud 无服务器服务审计日志:将审计记录发送到可观测性或安全解决方案
elasticsearch