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
相关推荐
Elasticsearch1 天前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
Elasticsearch2 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
海兰4 天前
离线合同结构化提取与检索:LangExtract + 本地DeepSeek + Elasticsearch 9.x
大数据·elasticsearch·django
yumgpkpm4 天前
AI视频生成:Wan 2.2(阿里通义万相)在华为昇腾下的部署?
人工智能·hadoop·elasticsearch·zookeeper·flink·kafka·cloudera
Sheffield4 天前
如果把ZooKeeper按字面意思比作动物园管理员……
elasticsearch·zookeeper·kafka
嗝屁小孩纸4 天前
ES索引重建(零工具纯脚本执行)
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客4 天前
使用 Jina Embeddings v5 和 Elasticsearch 构建“与你的网站数据聊天”的 agent
大数据·人工智能·elasticsearch·搜索引擎·容器·全文检索·jina
Elastic 中国社区官方博客4 天前
Elastic 公共 roadmap 在此
大数据·elasticsearch·ai·云原生·serverless·全文检索·aws
码云数智-大飞4 天前
像写 SQL 一样搜索:dbVisitor 如何用 MyBatis 范式颠覆 ElasticSearch 开发
sql·elasticsearch·mybatis