ES单节点用户认证

默认情况下,拥有安全免费许可证时,Elasticsearch安全功能被禁用。

在elasticsearch.yml配置文件中,配置如下:

cluster.name: my-application
node.name: node-1
network.host: 192.168.10.21
discovery.seed_hosts: ["192.168.10.21"]
# cluster.initial_master_nodes: ["node-1"]

# 新增如下配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
discovery.type: single-node

注意:xpack.security.transport.ssl.enabled的设置。
否则会报错:

[1]: Transport SSL must be enabled if security is enabled on a [basic] license.

Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]

elasticsearch-setup-passwords 用于设置密码。

  • auto - 随机设置用户名和密码
  • interactive - 交互式设置用户名和密码

根据业务需要,选择随机或者自定义密码。
自定义密码设置命令如下:

./elasticsearch-setup-passwords interactive

不使用账号密码访问

[root@es-1 elasticsearch]# curl http://192.168.10.21:9200/_cluster/health
{"error":{"root_cause":[{"type":"security_exception","reason":"missing authentication credentials for REST request [/_cluster/health]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"missing authentication credentials for REST request [/_cluster/health]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}

使用账号密码访问

[root@es-1 ~]# curl -u elastic:123456 http://192.168.10.21:9200/_cluster/health
{"cluster_name":"my-application","status":"green","timed_out":false,"number_of_nodes":1,"number_of_data_nodes":1,"active_primary_shards":8,"active_shards":8,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}

kibana添加账号和密码如下所示:

elasticsearch.username: "kibana"
elasticsearch.password: "123456"
posted @   哈喽哈喽111111  阅读(328)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2020-08-10 python动态参数
2020-08-10 python 循环控制
2020-08-10 python 代码执行顺序
2020-08-10 Python eval() 函数
2020-08-10 if __name__ == '__main__': 详解
2018-08-10 装饰器知识汇总
2018-08-10 python的父类和子类中关于继承的不同版本的写法
点击右上角即可分享
微信分享提示