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
相关推荐
Danileaf_Guo3 小时前
256台H100服务器算力中心的带外管理网络建设方案
运维·服务器
Robot侠4 小时前
极简LLM入门指南4
大数据·python·llm·prompt·提示工程
技术钱5 小时前
vue3解决大数据加载页面卡顿问题
大数据
拾贰_C5 小时前
【Linux | Windows | Terminal Command】 Linux---grep | Windows--- findstr
linux·运维·服务器
虹科网络安全6 小时前
艾体宝洞察 | 利用“隐形字符”的钓鱼邮件:传统防御为何失效,AI安全意识培训如何补上最后一道防线
运维·网络·安全
石像鬼₧魂石6 小时前
Kali Linux 网络端口深度扫描
linux·运维·网络
alengan6 小时前
linux上面写python3日志服务器
linux·运维·服务器
yBmZlQzJ7 小时前
免费内网穿透-端口转发配置介绍
运维·经验分享·docker·容器·1024程序员节
JH30737 小时前
docker 新手入门:10分钟搞定基础使用
运维·docker·容器
福客AI智能客服7 小时前
从被动响应到主动赋能:家具行业客服机器人的革新路径
大数据·人工智能