远程给多台主机安装软件

网友投稿 241 2022-11-13

远程给多台主机安装软件

案例1:在物理机上编写一个自动化批量管理服务器的脚本。要求用ssh命令远程给3台虚拟机全自动安装vsftpd、ftp、lftp、tree、samba、tftp-server、bind、dhcp、 -q查询软件是否已安装,全自动启动vsftpd、smb、rpcbind、nfs、mariadb服务。

参考脚本一:

vim auto.sh

#!/bin/bash

IPS=192.168.10.

for I  in {6..9};do

(

ssh  root@${IPS}$I 'yum   install  -y   vsftpd   ftp  lftp   tree  samba  tftp-server   bind   dhcp    mariadb-server'

ssh  root@${IPS}$I 'rpm  -q   vsftpd   ftp   lftp   tree  samba   tftp-server  bind  dhcp    mariadb-server'

ssh  root@${IPS}$I  'systemctl   restart   vsftpd'

ssh  root@${IPS}$I  'systemctl   restart   smb'

ssh  root@${IPS}$I  'systemctl   restart   rpcbind'

ssh  root@${IPS}$I  'systemctl   restart   nfs'

ssh  root@${IPS}$I  'systemctl   restart   mariadb'

)&

done

wait

参考脚本二:先将需要安装的软件写到一个文件里,然后用scp传送到服务端

vim install.sh

#!/bin/bash

yum   install  -y   vsftpd   ftp  lftp   tree  samba  tftp-server   bind   dhcp    mariadb-server

rpm  -q   vsftpd   ftp   lftp   tree  samba   tftp-server  bind  dhcp    mariadb-server

systemctl   restart   vsftpdsystemctl   restart   smbsystemctl   restart   rpcbindsystemctl   restart   nfssystemctl   restart   mariadb

vim scp.sh

#!/bin/bash

IPS=192.168.10.

for I in {6..9};do

(

scp  -r install.sh root@${IPS}$I:/opt/

ssh root@${IPS}$I 'bash /opt/install.sh'

)&

done

wait

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:基于区块链技术的BMarket数字资产交易平台介绍
下一篇:关于log4j2的异步日志输出方式
相关文章

 发表评论

暂时没有评论,来抢沙发吧~