[自制] 批量操作多节点的脚本
最后更新于:2022-04-02 03:47:54
[TOC]
## 教程
```
# ssh-keygen -t rsa -P ''
# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.0.111
# ssh-copy-id -i .ssh/id_rsa.pub root@192.168.0.229
```
创建脚本
deploy.sh
```
#!/bin/bash
ceph_ips=('192.168.0.110' '192.168.0.229' '192.168.0.111')
# 构造函数
opip(){
for ceph_ip in ${ceph_ips[@]}
do
ssh root@${ceph_ip} $1 &
done
}
# 执行函数
opip "echo 'hello word'>>/root/1.log"
```
执行
`sh deploy.sh`
';