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
相关推荐
文人sec14 分钟前
【Linux 服务器上搭建 JMeter 性能测试与监控环境(实战版)】
linux·运维·服务器·jmeter·性能测试
顾北1215 分钟前
从零搭建 ELK 栈(ES+Kibana+Logstash):含 IK + 拼音分词,MySQL 同步 ES 完整配置
运维·elasticsearch
papaofdoudou18 分钟前
Linux内核的边界在哪里?
linux·运维·服务器
路由侠内网穿透19 分钟前
本地部署开源零信任网络平台 NetBird 并实现外部访问
运维·服务器·数据库·开源
zzzsde23 分钟前
【Linux】文件:基础IO
linux·运维·服务器
qq_2546744125 分钟前
Docker Docker Compose
运维·docker·容器
Aurora(^*_*^)27 分钟前
docker 部署openclaw踩坑记录
运维·docker·容器
霑潇雨32 分钟前
题解 | 深入分析各款产品年总销售额与竞品的年度对比
大数据·开发语言·数据库
wanhengidc37 分钟前
服务器托管对企业的作用
大数据·运维·服务器·分布式·智能手机
Code知行合壹38 分钟前
Spark使用总结
大数据·分布式·spark