你可以使用正则表达式而不是使用完整主机名和 IP:
$ clush -w 192.168.1.[4,9] uname -r 192.168.1.9: 4.15.0-45-generic 192.168.1.4: 3.10.0-957.el7.x86_64
或者,如果服务器位于同一 IP 系列中,则可以使用以下格式:
$ clush -w 192.168.1.[4-9] date 192.168.1.6: Mon Mar 4 21:08:29 IST 2019 192.168.1.7: Mon Mar 4 21:08:29 IST 2019 192.168.1.8: Mon Mar 4 21:08:29 IST 2019 192.168.1.5: Mon Mar 4 09:16:30 CST 2019 192.168.1.9: Mon Mar 4 21:08:29 IST 2019 192.168.1.4: Mon Mar 4 09:16:30 CST 2019
clustershell 允许我们以批处理模式运行命令。使用以下格式来实现此目的:
$ clush -w 192.168.1.4,192.168.1.9 -b Enter 'quit' to leave this interactive mode Working with nodes: 192.168.1.[4,9] clush> hostnamectl --------------- 192.168.1.4 --------------- Static hostname: CentOS7.2daygeek.com Icon name: computer-vm Chassis: vm Machine ID: 002f47b82af248f5be1d67b67e03514c Boot ID: f9b37a073c534dec8b236885e754cb56 Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-957.el7.x86_64 Architecture: x86-64 --------------- 192.168.1.9 --------------- Static hostname: Ubuntu18 Icon name: computer-vm Chassis: vm Machine ID: 27f6c2febda84dc881f28fd145077187 Boot ID: f176f2eb45524d4f906d12e2b5716649 Virtualization: oracle Operating System: Ubuntu 18.04.2 LTS Kernel: Linux 4.15.0-45-generic Architecture: x86-64 clush> free -m --------------- 192.168.1.4 --------------- total used free shared buff/cache available Mem: 1838 641 217 19 978 969 Swap: 2047 0 2047 --------------- 192.168.1.9 --------------- total used free shared buff/cache available Mem: 1993 352 1067 1 573 1473 Swap: 1425 0 1425 clush> w --------------- 192.168.1.4 --------------- 09:21:14 up 3:21, 3 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT daygeek :0 :0 06:02 ?xdm? 1:28 0.30s /usr/libexec/gnome-session-binary --session gnome-classic daygeek pts/0 :0 06:03 3:17m 0.06s 0.06s bash daygeek pts/1 192.168.1.6 06:03 52:26 0.10s 0.10s -bash --------------- 192.168.1.9 --------------- 21:13:12 up 3:12, 1 user, load average: 0.08, 0.03, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT daygeek pts/0 192.168.1.6 20:42 29:41 0.05s 0.05s -bash clush> quit
(编辑:ASP站长网)
|