esxi常用命令
作者:互联网
esxi底层其实也是linux系统,可以使用shell脚本进行一些操作,但是由于shell类型的问题,部分bash的脚本无法执行,可以考虑使用python脚本
[root@localhost:~] vmware -v VMware ESXi 6.7.0 build-14320388 [root@localhost:~] cat /etc/shells /bin/ash /bin/sh [root@localhost:~] python -V Python 3.5.7
常用命令:
- esxicli:主要用来做一些系统及的操作,网络、磁盘、系统等操作,同时还有vm的一些操作
[root@localhost:~] esxcli Usage: esxcli [options] {namespace}+ {cmd} [cmd options] Options: --formatter=FORMATTER Override the formatter to use for a given command. Available formatter: xml, csv, keyvalue --debug Enable debug or internal use options --version Display version information for the script -?, --help Display usage information for the script Available Namespaces: device Device manager commands esxcli Commands that operate on the esxcli system itself allowing users to get additional information. fcoe VMware FCOE commands. graphics VMware graphics commands. hardware VMKernel hardware properties and commands for configuring hardware. iscsi VMware iSCSI commands. network Operations that pertain to the maintenance of networking on an ESX host. This includes a wide variety of commands to manipulate virtual networking components (vswitch, portgroup, etc) as well as local host IP, DNS and general host networking settings. nvme VMware NVMe driver esxcli extensions rdma Operations that pertain to remote direct memory access (RDMA) protocol stack on an ESX host. sched VMKernel system properties and commands for configuring scheduling related functionality. software Manage the ESXi software image and packages storage VMware storage commands. system VMKernel system properties and commands for configuring properties of the kernel core system and related system services. vm A small number of operations that allow a user to Control Virtual Machine operations. vsan VMware vSAN commands
esxi 停止所有虚拟机
for i in $(esxcli vm process list |grep World|awk -F' ' '{print $3}');do esxcli vm process kill --type=hard --world-id=$i ;done
- vim-cmd:虚拟机相关操作
[root@localhost:~] vim-cmd Commands available under /: hbrsvc/ internalsvc/ solo/ vmsvc/ hostsvc/ proxysvc/ vimsvc/ help
[root@localhost:~] vim-cmd vmsvc/getallvms Vmid Name File Guest OS Version Annotation 1 VMware vCenter Server Appliance [90] VMware vCenter Server Appliance/VMware vCenter Server Appliance.vmx other3xLinux64Guest vmx-10 VMware vCenter Server Appliance 10 10.19.170.182 [90] 10.19.170.182/10.19.170.182.vmx centos7_64Guest vmx-14 13 10.19.170.175 [90] 10.19.170.175/10.19.170.175.vmx coreos64Guest vmx-14 14 10.19.170.101-centos76 [90] 10.19.170.101-centos76/10.19.170.101-centos76.vmx centos7_64Guest vmx-14 15 10.19.170.102-centos76 [90] 10.19.170.102-centos76/10.19.170.102-centos76.vmx centos7_64Guest vmx-14 16 10.19.170.103-centos76 [90] 10.19.170.103-centos76/10.19.170.103-centos76.vmx centos7_64Guest vmx-14 17 10.19.170.104-centos76 [90] 10.19.170.104-centos76/10.19.170.104-centos76.vmx centos7_64Guest vmx-14
创建快照,
[root@localhost:~] vim-cmd vmsvc/snapshot.create 14 testsnapshot ##14为上一步中的vmid Create Snapshot: [root@localhost:~]
批量创建快照参考脚本,list中为主机名称
#!/usr/bin/python
# -*-coding:utf-8-*-
import os
import sys
if len(sys.argv) != 2:
print("need at least 1 params")
exit()
hostname_list = ["10.19.170.190", "10.19.170.191", "10.19.170.192", "10.19.170.193", "10.19.170.194", "10.19.170.195", "10.19.170.196"]
for a in hostname_list:
vid = os.popen("vim-cmd vmsvc/getallvms |awk '{print $1,$2}' |grep " + a + "|awk '{print $1}'").read().split("\n")[0]
print(vid)
os.system("vim-cmd vmsvc/snapshot.create {} {}".format(vid, sys.argv[1]))
磁盘挂载失败 # 列出存储卷信息
esxcfg-volume -l# 挂载指定的存储卷
esxcfg-volume -m VOLUMEID
标签:commands,14,esxi,10.19,vmx,常用命令,centos76,VMware 来源: https://www.cnblogs.com/yannay/p/15608792.html