关于SegmentFault:ESes761开通安全防护认证流程

0次阅读

共计 2619 个字符,预计需要花费 7 分钟才能阅读完成。

1. 啥是 X -Pack?

X-Pack 是 Elastic Stack 扩大性能,提供安全性,警报,监督,报告,机器学习和许多其余性能。ES7.0+ 之后,默认状况下,当装置 Elasticsearch 时,会装置 X -Pack,无需独自再装置。

  • 1、5.X 版本之前:没有 x -pack,是独立的:security 平安,watch 查看,alert 正告等独立单元。
  • 2、5.X 版本:对本来的平安,正告,监督,图形和报告做了一个封装,造成了 x -pack。
  • 3、6.3 版本之前:须要额定装置。
  • 4、6.3 版本及之后:曾经集成在一起公布,无需额定装置,根底平安属于付费黄金版内容。7 .1 版本:根底平安收费。

自 6.8 以及 7.1+ 版本之后,根底级平安永恒收费。

根底版本平安性能列表如下:

2.ES 配置

2.1 集群化配置(docker 环境)

1. 进入 ES docker 容器,生成节点证书

借助 elasticsearch-certutil 命令生成证书
(在 elasticsearch 目录下执行 /usr/share/elasticsearch)

/usr/share/elasticsearch/bin/elasticsearch-certutil.bat ca -out config/elastic-certificates.p12 -pass ""

//-out 指定证书生成门路,-pass 默认无明码
注:只须要应用由同一 CA 签名的证书,即可主动容许该节点退出集群

2. 配置加密通信

启用平安性能后,必须应用 TLS 来确保节点之间的通信已加密。
在 elasticsearch.yml 核心新增配置如下:

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 

具体配置如下:

cluster.name: es-docker
node.name: es-nodename
network.bind_host: 0.0.0.0
network.publish_host: ***.***.***.*** ## 本机 ip 地址
http.port: 9200 ## 凋谢端口
transport.tcp.port: 9300 ## 凋谢 tcp 端口
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.enabled: true
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
node.master: true 
node.data: true
discovery.seed_hosts: ["***.***.***.***:9300","elasticsearch2:10293","elasticsearch1:10193"]
cluster.initial_master_nodes: ["es-nodename1","es-nodename2","es-nodename3"]

留神:
1. 最好将证书与配置文件放在同一目录下
2. 生成的这书最好手动赋一下权 chmod 644 *.ca

3. 设置集群明码

ES 中内置了几个治理其余集成组件的账号即:apm_system, beats_system, elastic, kibana, logstash_system, remote_monitoring_user,应用之前,首先须要增加一下明码:

/bin/elasticsearch-setup-passwords interactive
  • interactive:给用户一一设置明码。
  • auto:主动生成明码。


留神:必须配置好 xpack 之后,能力设置明码。否则会报错。
如果这个中央报如下谬误:

Failed to determine the health of the cluster running at http://192.168.3.42:9200
Unexpected response code [503] from calling GET http://192.168.3.42:9200/_cluster/health?pretty
Cause: master_not_discovered_exception

It is recommended that you resolve the issues with your cluster before running elasticsearch-setup-passwords.
It is very likely that the password changes will fail when run against an unhealthy cluster.
Do you want to continue with the password setup process [y/N]y

可能是有脏数据导致,此时能够停掉 es,删除 data 数据目录,而后重新启动在进行操作。

4. 配置其余节点
  • 将配置好的带证书的文件 copy 到另外的其余节点下,放在同样目录下
  • elasticsearch.yml 复制新增配置和配置好的节点一样
  • 除了 node.name 应用各自主机名之外,其余配置都一样。
5. 配置实现,重启各个节点

配置结束之后,能够通过如下形式拜访 es 服务:

curl -XGET -u elastic 'localhost:9200/_xpack/security/user?pretty'
curl 127.0.0.1:9200 -u elastic

附录:
https://blog.csdn.net/laoyang…
http://www.eryajf.net/3500.html

正文完
 0