1. 首页
  2. > 香港公司注册 >

网站集群安全是什么意思(网站集群的优势)

一、采坑过程

最近在配置elasticsearch生产可用的集群环境时,集群搭建完成后,为了安全,启用es集群集群的安全配置,根据官方文档[Set up minimal security for Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/security-minimal-setup.html)这一节来配置集群账户密码,然后就出现了开启安全模式后,./bin/elasticsearch-setup-passwords auto ,./bin/e集群lasticsearch-setup-passwords interactive 两个命令均无法访问。提示集群健康状态无法检查,实际上就是集群本身的通讯也存在问题。提示信息如下:


Failed to determine the health of the cluster running at http://192.168.122.1:9200 Unexpected resp优势onse code [503] from cal的ling GET 是什么http://192.168.122.1: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]ERROR: User cancelled operation



看了很多遍官方文档,发现了一句话:


The minimal security scenario is not sufficient for production mode clusters. If your cluster has multi网站ple nodes, you must enable minimal security and then configure Transport Layer Security (TLS) between nodes.

意思是说:最小安全方案对于生产模式集群是不够的。如果您的集群有多个节点,则必须启用最低安全性,然后在节点之间配置传输层安全性 (TLS)。


如果只有一个节点,那么ela安全sticsearch.yml添加如下配置即可:


discovery.type: single-node

但是因为本身我的集群有3个节点,那肯定不能设置为单节点模式,那么这一项不可用,根据文档的提示,那么集群环境下,其实还需要配置其他的安全配置。于是解决方案其实就出来了。根据官方文档的后面一个章节[Set up basic security for the Elastic Stack](优势https://www.elastic.co/guide/en/ela意思sticsearch/reference/7.13/security-basic-setup.html#security-basic-setup)的内容进行配置集群环境的基本安全配置就OK了。


2、 配置步骤:

提示,因为我每次操作命令都是进入es的bin目录下,因此与官方文档不完全相同。


2.1 生成CA证书

在任何单个节点上,使用 elasticsearch-certutil 工具为您的集群生成 CA。


./elasticsearch-certutil ca

a.出现提示时,接受默认文件名,即 elastic-s的tack-ca.p12。此文件包含 CA 的公共证书和用于为每个节点签署证书的私钥。


b.输入 CA 的密码。如果不部署到生产环境,您可以选择将密码留空。


2.2 配置CA证书

在任何单个节点上,为集群中的节点生成证书和私钥。包括在上一步中生成的 elastic-stack-ca.p12 输出文件。


./elasticsearch-certutil cert --ca elastic-stack-ca.p12

a.输入您的 CA 的密码,或者如果您在上一步中没有配置密码,请按 Enter。


b.为证书创建密码并接受默认文件名。


输出的文件是一个名为 elastic-certificates.p12 的密钥库。这个文件包含节点证书、节点密钥和 CA 证书。


2.3 复制证书到集群

在集群中的每个节点上,将 elastic-certificates.p12 文件复制到 $ES_PATH_CONF 目录。也就是config目录。


2.4 修改配置文件

a.基本集群配置,不启用安全也需要的配置:


cluster.name: my-cluster #每个节点一致 node.name: node-1 #每个节点不同

b.安全配置


由于在群集的每个节点上使用相同的Elastic-Certificate.p12文件,因此将验证模式设置为证书:


xpack.security.transport.ssl.enabled: true xpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.client_authentication: required xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

2.5 配置密码

如果在创建节点证书时输入了密码,运行以下命令以将密码存储在Elasticsearch密钥库中:


./elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password ./elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password

2.4-2.5的步骤在每个节点中都需要进行。


2.6 重新启动es

我是采用启动的时候指定pid文件的方式,启动命令如下:


./elasticsearch -d -p /home/elk/pid/es-node-01

就可以使用以下命令停止es


cat /home/elk/pid/es-node-01 ki意思ll -SIGTERM 32167 #32167是上一句语句输出的结果

2.7 配置账户密码

再次启动后,即可运行以下命令配置账户密码:


./elasticsearch-setup-passwords auto

就会自动输出所有内置账户的随机密码,可以自是什么行修改。


也可以使用以下命令自定义网站密码:


./elasticsearch-setup-passwords interactive

上述命令只需要在其中一个节点运行,不需要在所有节点运行。


上述输出的密码可以配置到kibana或者其他需要连接es的工具中,比如cerebro监控。


3、总结

依靠零碎学习的内容,实际上很难完整地掌握一项技术的核心内容安全。还是需要看官方文档,并且最好各个章节都理解一下,才能选择出适合自身需要的配置方式。


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至123456@qq.com 举报,一经查实,本站将立刻删除。

联系我们

工作日:9:30-18:30,节假日休息