ES8关闭SSL配置和验证
✅ 关闭 ES SSL / TLS
✅ 保留账号认证
✅ 能正常 HTTP 访问
✅ 创建索引
✅ 写入数据
✅ 查询验证
接下来看 ES 8.x 环境如何使用。
✅ 一、关闭 ES 的 SSL(仅保留账号密码认证)
你现在遇到的问题本质是:
ES 8 默认开启 TLS,但 transport 层没配置 → 启动失败
我们直接关闭 TLS,只保留安全认证。
👉 第一步:编辑配置文件
打开:
vi /etc/elasticsearch/elasticsearch.yml
找到或新增以下内容:
# 开启账号认证
xpack.security.enabled: true
# 关闭 HTTP SSL
xpack.security.http.ssl.enabled: false
# 关闭 transport SSL
xpack.security.transport.ssl.enabled: false
👉 第二步:确认端口
http.port: 29200
network.host: 0.0.0.0
👉 第三步:重启服务
systemctl daemon-reload
systemctl restart elasticsearch
查看状态:
systemctl status elasticsearch
👉 第四步:验证访问
curl -u elastic:你的密码 http://127.0.0.1:29200
看到:
"You Know, for Search"
说明:
👉 HTTP 正常
👉 SSL 已关闭
👉 账号认证仍生效
✅ 二、创建索引(类似数据库表)
创建一个测试索引:
curl -u elastic:你的密码
-X PUT http://127.0.0.1:29200/user_index
-H "Content-Type: application/json"
-d '{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}'
成功返回:
"acknowledged": true
✅ 三、写入数据
写入一条文档:
curl -u elastic:你的密码
-X POST http://127.0.0.1:29200/user_index/_doc/1
-H "Content-Type: application/json"
-d '{
"name": "小李",
"age": 30,
"job": "风控工程师"
}'
返回:
"result": "created"
✅ 四、查询数据
按 ID 查询:
curl -u elastic:你的密码
http://127.0.0.1:29200/user_index/_doc/1?pretty
查询全部:
curl -u elastic:你的密码
http://127.0.0.1:29200/user_index/_search?pretty
✅ 五、更新数据
curl -u elastic:你的密码
-X POST http://127.0.0.1:29200/user_index/_update/1
-H "Content-Type: application/json"
-d '{
"doc": {
"age": 31
}
}'
✅ 六、删除数据
curl -u elastic:你的密码
-X DELETE http://127.0.0.1:29200/user_index/_doc/1
🔥 验证流程总结
关闭 SSL
↓
启动 ES
↓
创建索引
↓
写入数据
↓
查询验证
本作品采用《CC 协议》,转载必须注明作者和本文链接
关于 LearnKu