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
相关推荐
w***Q3501 小时前
Git工作流自动化
运维·git·自动化
xu_yule4 小时前
Linux_12(进程信号)内核态和用户态+处理信号+不可重入函数+volatile
linux·运维·服务器
虾..4 小时前
Linux 环境变量&&进程优先级
linux·运维·服务器
数据库学啊5 小时前
团队小希望运维简单,时序数据库选型有什么推荐?
运维·数据库·时序数据库
霍格沃兹软件测试开发6 小时前
Playwright MCP浏览器自动化指南:让AI精准理解你的命令
运维·人工智能·自动化
郝学胜-神的一滴7 小时前
Linux命名管道:创建与原理详解
linux·运维·服务器·开发语言·c++·程序人生·个人开发
wanhengidc7 小时前
云手机性能如何?
运维·服务器·科技·智能手机·云计算
wan_da_ren7 小时前
Docker安装Elasticsearch9.2.1与Kibana9.2.1 保姆教程(带验证版)
运维·docker·jenkins
Eric.Lee20219 小时前
ubuntu 安装 Miniconda
linux·运维·python·ubuntu·miniconda
杭州泽沃电子科技有限公司9 小时前
在线监测:为医药精细化工奠定安全、合规与质量基石
运维·人工智能·物联网·安全·智能监测