elasticsearch 设置访问密码

elasticsearch 安装后,默认端口是9200,如果暴露在互联网中存在安全风险,需要为elastic 设置访问密码,从elasticsearch7.7 以后,开源了密码的使用,我们可以直接使用内置的加密方案。

首先切换到已经安装好的es目录中,

bash 复制代码
cd /data/canal/elasticsearch-7.16.0/

然后生成证书

bash 复制代码
./bin/elasticsearch-certutil ca
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

#将证书拷贝到config中

cp elastic-certificates.p12 config/
cp elastic-stack-ca.p12 config/

在config/elasticsearch.yml 中增加配置脚本

bash 复制代码
xpack.security.enabled: true
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: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

配置文件修改后,需要停止es 并重启成功后可以设置访问密码

上述准备工作完成后,可以生成es访问密码(请牢记访问密码)

bash 复制代码
./bin/elasticsearch-setup-passwords interactive

需要在如下输入框输入密码,比如: es123456, 连续输入6组密码后结束

密码输入后,可以使用 curl 来访问es

bash 复制代码
curl http://127.0.0.1:9200/_cat/indices -u elastic:es123456

得到如下结果,表示访问成功

root@ddd config\]# curl http://127.0.0.1:9200/_cat/indices?pretty -u elastic:es123456 green open .security-7 _VYk4f_0QiW2aAeJ5UQeGg 1 0 7 0 25.8kb 25.8kb yellow open order_user 5fPLPo8qQUW0NOfEIB63Rg 1 1 14004 5 5.4mb 5.4mb yellow open order dzac0X1ITB67RUaXFH8cSA 1 1 5490 96 1.8mb 1.8mb yellow open saas 0WR2-4L-Ru2hm-G0VW1HpQ 1 1 4059 7 1.6mb 1.6mb 未使用密码访问es curl http://127.0.0.1:9200/_cat/indices

相关推荐
罗技1231 天前
Elasticsearch、OpenSearch 与 Easysearch:三代搜索引擎的演化与抉择
大数据·elasticsearch·搜索引擎
非极限码农1 天前
Apache Spark 上手指南(基于 Spark 3.5.0 稳定版)
大数据·spark·apache
Guheyunyi1 天前
消防管理系统如何重构现代空间防御体系
大数据·运维·人工智能·安全·信息可视化·重构
二进制_博客1 天前
spark on hive 还是 hive on spark?
大数据·hive·spark
智海观潮1 天前
Spark RDD详解 —— RDD特性、lineage、缓存、checkpoint、依赖关系
大数据·缓存·spark
极限实验室1 天前
Elasticsearch 备份:snapshot 镜像使用篇
数据库·elasticsearch
一个会的不多的人1 天前
数字化转型:概念性名词浅谈(第七十二讲)
大数据·人工智能·制造·数字化转型
数据智能老司机1 天前
在 Databricks 上的 Unity Catalog 数据治理——Unity Catalog 的内部机制
大数据·架构
LaughingZhu2 天前
Product Hunt 每日热榜 | 2025-10-11
人工智能·经验分享·搜索引擎·产品运营
gb42152872 天前
elasticsearch索引多长时间刷新一次(智能刷新索引根据数据条数去更新)
大数据·elasticsearch·jenkins