禁用和启用安全插件
安全插件默认安装在 OpenSearch 中,但你可以暂时禁用它或完全删除它。禁用插件涉及更改 opensearch.yml
文件;你可能希望这样做以简化测试。完全删除安全插件需要更实质性的更改。例如,如果你正在使用自己的安全解决方案或因开发目的需要删除它,你可能希望将其删除。
禁用或删除插件会暴露安全插件的配置索引。如果索引包含敏感信息,请务必通过其他方式保护它。如果不再需要该索引,请将其删除。
禁用、删除或安装安全插件需要完全重启集群,因为在此过程中,各个节点无法相互通信。
禁用/启用安全插件
你可以通过编辑 opensearch.yml
文件来禁用安全插件
plugins.security.disabled: true
然后可以通过删除 plugins.security.disabled
设置来启用该插件。
删除和添加安全插件
你可以从 OpenSearch 实例中完全删除安全插件。请注意,OpenSearch Dashboards 只能在安全集群上运行,因此如果你卸载安全插件,你也需要卸载 OpenSearch Dashboards 插件。
从 OpenSearch 中删除安全插件
执行以下操作以从 OpenSearch 中删除插件。
-
禁用分片分配并停止所有节点,以便在集群重启时分片不会移动
curl -XPUT "https://:9200/_cluster/settings" -u "admin:<password>" -H 'Content-Type: application/json' -d '{ "transient": { "cluster.routing.allocation.enable": "none" } }'
- 从
opensearch.yml
中删除所有plugins.security.*
配置条目。 -
使用以下命令卸载安全插件
./bin/opensearch-plugin remove opensearch-security
- 重启节点并重新启用分片分配
curl -XPUT "https://:9200/_cluster/settings" -H 'Content-Type: application/json' -d '{ "transient": { "cluster.routing.allocation.enable": "all" } }'
要在 Docker 镜像上执行这些步骤,请参阅使用插件。
从 OpenSearch Dashboards 中删除安全插件
如果你在 opensearch.yml
中禁用安全插件,并且仍然想使用 OpenSearch Dashboards,你必须删除相应的 OpenSearch Dashboards 安全插件。有关更多信息,请参阅删除插件。
参考以下安装类型以删除 OpenSearch Dashboards 插件。
Docker
-
从
opensearch_dashboards.yml
中删除所有安全插件配置设置,或将示例文件移动到与Dockerfile
相同的文件夹--- server.name: opensearch-dashboards server.host: "0.0.0.0" opensearch.hosts: https://:9200
-
创建新的
Dockerfile
FROM opensearchproject/opensearch-dashboards:3.1.0 RUN /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin remove securityDashboards COPY --chown=opensearch-dashboards:opensearch-dashboards opensearch_dashboards.yml /usr/share/opensearch-dashboards/config/
-
要构建新的 Docker 镜像,运行以下命令
docker build --tag=opensearch-dashboards-no-security .
- 在
docker-compose.yml
中,将opensearchproject/opensearch-dashboards:3.1.0
更改为opensearch-dashboards-no-security
。 - 将
OPENSEARCH_HOSTS
或opensearch.hosts
更改为http://
而不是https://
。 - 输入
docker compose up
。
Tarball
-
导航到 OpenSearch Dashboards 安装文件夹中的
/bin
目录,并通过按下Ctrl + C
停止正在运行的 OpenSearch Dashboards 实例。 -
运行以下命令卸载安全插件
./bin/opensearch-dashboards-plugin remove securityDashboards
-
从
opensearch_dashboards.yml
文件中删除所有安全插件配置设置,或使用以下示例文件--- server.name: opensearch-dashboards server.host: "0.0.0.0" opensearch.hosts: https://:9200
-
启动 OpenSearch Dashboards
./bin/opensearch-dashboards
RPM 和 Debian
-
使用以下命令停止正在运行的 OpenSearch Dashboards 实例
sudo systemctl stop opensearch-dashboards
-
导航到 OpenSearch Dashboards 文件夹
/usr/share/opensearch-dashboards
并运行以下命令卸载安全插件./bin/opensearch-dashboards-plugin remove securityDashboards
-
从
opensearch_dashboards.yml
文件中删除所有安全插件配置设置,或将示例文件放置在/etc/opensearch_dashboards
文件夹中--- server.name: opensearch-dashboards server.host: "0.0.0.0" opensearch.hosts: https://:9200
-
启动 OpenSearch Dashboards
sudo systemctl start opensearch-dashboards
安装安全插件
使用以下步骤重新安装插件
-
禁用分片分配并停止所有节点,以便在集群重启时分片不会移动
curl -XPUT "https://:9200/_cluster/settings" -H 'Content-Type: application/json' -d '{ "transient": { "cluster.routing.allocation.enable": "none" } }'
-
使用其中一种安装方法在集群中的所有节点上安装安全插件
bin/opensearch-plugin install opensearch-security
-
向
opensearch.yml
添加 TLS 加密所需的配置。有关需要配置的设置信息,请参阅配置。 -
创建
OPENSEARCH_INITIAL_ADMIN_PASSWORD
变量。有关更多信息,请参阅设置自定义管理员密码。 -
重启节点并重新启用分片分配
curl -XPUT "https://:9200/_cluster/settings" -u "admin:<password>" -H 'Content-Type: application/json' -d '{ "transient": { "cluster.routing.allocation.enable": "all" } }'
在 OpenSearch Dashboards 上安装安全插件
使用以下步骤在 OpenSearch Dashboards 上重新安装插件
- 停止运行你的 OpenSearch Dashboards 集群。
-
安装安全插件
./bin/opensearch-dashboards-plugin install securityDashboards
- 在
opensearch_dashboards.yml
文件中添加必要的配置设置。 - 启动 OpenSearch Dashboards。如果插件安装成功,系统将提示你输入登录凭据。