ES脚本启动报错修改

使用自写脚本启动ES集群时,添加安全策略时报错如下:

Positional arguments not allowed, found -E xpack.security.enabled=true -E xpack.security.transport.ssl.enabled=true -E xpack.license.self_generated.type=basic -E xpack.security.transport.ssl.keystore.path=certs/elastic-certificates.p12 -E xpack.security.transport.ssl.truststore.path=certs/elastic-certificates.p12 -E xpack.security.transport.ssl.verification_mode=certificate

bash 复制代码
if [[ $1 == 'security' ]]; then
    echo '使用安全集群'
    shift 1
    ES_OPT=$@
    ES_OPT="$ES_OPT -E xpack.security.enabled=true -E xpack.security.transport.ssl.enabled=true -E xpack.license.self_generated.type=basic -E xpack.security.transport.ssl.keystore.path=certs/elastic-certificates.p12 -E xpack.security.transport.ssl.truststore.path=certs/elastic-certificates.p12 -E xpack.security.transport.ssl.verification_mode=certificate"
fi

cd $ES_HOME
for (( i = 0; i < $num; i++ )); do
    echo "尝试启动第`expr $i + 1`个ES节点"
    bin/elasticsearch -E node.name=node$i -E cluster.name=cluster -E path.data=node${i}_data $ES_OPT -d
done

最后发现$ES_OPT为字符串处理,修改为数组处理

bash 复制代码
if [[ $1 == 'security' ]]; then
    echo '使用安全集群'
    shift 1
    ES_OPT=$@
    ES_OPT=($ES_OPT[@] -Expack.security.enabled=true -Expack.security.transport.ssl.enabled=true -Expack.license.self_generated.type=basic -Expack.security.transport.ssl.keystore.path=certs/elastic-certificates.p12 -Expack.security.transport.ssl.truststore.path=certs/elastic-certificates.p12 -Expack.security.transport.ssl.verification_mode=certificate)
fi

cd $ES_HOME
for (( i = 0; i < $num; i++ )); do
    echo "尝试启动第`expr $i + 1`个ES节点"
    bin/elasticsearch -E node.name=node$i -E cluster.name=cluster -E path.data=node${i}_data $ES_OPT -d
done
相关推荐
时间的拾荒人6 小时前
Docker 入门实战:从核心概念、安装配置到镜像操作与 Dockerfile 定制
运维·docker·容器·eureka
光电笑映7 小时前
TCP 为什么可靠?从三次握手、滑动窗口到拥塞控制全面拆解(上)
运维·服务器·网络·udp
Elasticsearch7 小时前
Java4Shell 远程代码执行漏洞 - CVE-2026-114938
elasticsearch
飞奔的瓜牛7 小时前
Linux 下使用 OpenSSL 生成自签名证书完整指南
运维·服务器·nginx
字节跳动数据平台7 小时前
火山引擎 VeKnow 落地指南(上):从选场景到知识治理
大数据
无奈笑天下7 小时前
银河麒麟桌面上USB打印机无法打印问题标准处理流程
linux·运维·网络协议
Decay__8 小时前
附 - 02・SQLServer 分库分表与中间件 —— 原生分区表、横向分库实践与联邦查询
运维·数据库·sql·mysql·架构
Elasticsearch8 小时前
哈利波特问答 Agent Builder + Workflow 教程
elasticsearch
安心联-车辆监控管理系统9 小时前
以事实为基础,详解车辆主动安全相关功能
大数据·人工智能·安全
wno7049 小时前
CentOS下FTP服务搭建
linux·运维·centos