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
相关推荐
workflower43 分钟前
人机交互部分OOD
运维·人工智能·自动化·集成测试·人机交互·软件需求
农村小镇哥1 小时前
nginx服务器的介绍
运维·服务器·nginx
小夏子_riotous1 小时前
Docker学习路径——3、常用命令
linux·运维·服务器·学习·docker·容器·centos
STLearner2 小时前
WSDM 2026 | 时间序列(Time Series)论文总结【预测,表示学习,因果】
大数据·论文阅读·人工智能·深度学习·学习·机器学习·数据挖掘
亚马逊云开发者3 小时前
【Bedrock AgentCore】AI Agent 回答不一致怎么办?双 Memory 架构实现服务标准化(附完整代码)
大数据·人工智能·架构
IMPYLH3 小时前
Linux 的 rm 命令
linux·运维·服务器·网络·bash
white-persist4 小时前
【vulhub shiro 漏洞复现】vulhub shiro CVE-2016-4437 Shiro反序列化漏洞复现详细分析解释
运维·服务器·网络·python·算法·安全·web安全
老陈头聊SEO5 小时前
AI技术带来的SEO关键词优化新方向与应用探索
其他·搜索引擎·seo优化
代码中介商5 小时前
手把手教你Linux 打包压缩与 gcc 编译详解
linux·运维·服务器·编译·打包·压缩
大嘴皮猴儿5 小时前
从零开始学商品图翻译:小白也能快速掌握的多语言文字处理与上架技巧
大数据·ide·人工智能·macos·新媒体运营·xcode·自动翻译