背景:当我们拥有集群时,需要操作每台服务节点,用到shell脚本自动化去执行某些命令是程序员的第一选择。简单、快捷、方便。
- shell脚本实现,实现去每一台节点去安装python服务依赖的jar包。
cat scp_servicelib.sh
#!/bin/bash
nodes=$(cat ./other_nodes)
for node in $nodes
do
echo $node ":"
ssh username@$node "cd /data/service ; pip install -r requirement.txt -i https://mirrors.aliyun.com/pypi/simple/"
done
exit 0
===============================
cat other_nodes
#服务节点
值得注意的是,当出现cd /../.bashrc:行105: conda: 未找到命令,无需关注,命令其实已经执行了,可以到对应的节点去查看。

这篇博客介绍了如何通过Shell脚本自动化地在多个服务节点上执行命令,特别是安装Python服务所需的jar包。脚本`catscp_servicelib.sh`读取`other_nodes`文件中的节点列表,然后逐个节点执行`pip install`命令,利用阿里云镜像加速依赖安装。尽管过程中可能出现conda命令找不到的提示,但不影响实际命令的执行。
2214

被折叠的 条评论
为什么被折叠?



