在手機上安裝 vSphere Mobile Watchlist,可以利用手機來查看 ESXi Server VM 的執行狀態。
以 Android 手機為例
1. 開啟 Google Play
2. 搜尋 vSphere Mobile Watchlist,並 安裝
全新的繁體中文 WordPress 網站《宜蘭部落格教育平台 網站》
如果要備份或回復 VMware ESXi 的設定,可以安裝 VMware vSphere Command Line Interface。
1. 登入 VMware 官方網站下載 VMware vSphere Command Line Interface
1 – For Windows
2 – For Linux x86_64
3 – For Linux x86
2. 下載 ActivePerl http://www.activestate.com/activeperl
選擇 Free Community Edition
如果沒有先安裝 ActivePerl,執行 VMware vSphere-CLI 會出現無法認識 .pl 檔案的問題
6. 執行 vicfg-cfgbackup.pl –server xxx.xxx.xxx.xxx -s d:esxi.cfg
出現錯誤訊息
參考網頁:
傲笑紅塵路: 使用 VMware ESXi Direct Console User Interface (DCUI)
雙管齊下搞定vSphere 綜合運用GUI及文字介面 – 專題報導 – 網管人NetAdmin
虛擬技術狂熱者: 在ESXi本機使用指令將vm開機、關機、重開機
[@more@]3. 選擇 Troubleshooting Options
6. 按一下 Alt+F1 即可進入 ESXi Shell
輸入管理者的帳號及密碼
參考網頁:
以esxi5 command line方式啟動VM | 資訊組
VMWare ESX/ESXi CLI模式常用指令 | Tonyhack
[root@esxi:~] esxcli storage nfs list
Volume Name Host Share Accessible Mounted Read-Only isPE Hardware Acceleration
———– ———— ———————————- ———- ——- ——— —– ———————
SynologyNAS 192.168.131.4 /volume1/homes/test/Server/esxi true true false false Not Supported
[root@localhost ~]# esxcli –server 192.168.131.234 storage nfs list
Connect to 192.168.131.4 failed. Server SHA-1 thumbprint: 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 (not trusted).
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 storage nfs list
Volume Name Host Share Accessible Mounted Read-Only isPE Hardware Acceleration
———– ———— ———————————- ———- ——- ——— —– ———————
SynologyNAS 192.168.131.4 /volume1/homes/test/Server/esxi true true false false Not Supported [@more@]
[root@esxi:~] esxcli storage filesystem list
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 storage filesystem list
Mount Point Volume Name UUID Mounted Type Size Free
————————————————- ———– ———————————– ——- —— ————- ————-
/vmfs/volumes/75b5d24a-74d26ae7 SynologyNAS 75b5d24a-74d26ae7 true NFS 5892709236736 2628361314304
/vmfs/volumes/58cf7115-fa3ce98b-c6a7-ac220b89c4ca datastore1 58cf7115-fa3ce98b-c6a7-ac220b89c4ca true VMFS-5 119990648832 118971432960
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca ST500G 58cf7810-bde83e8a-457c-ac220b89c4ca true VMFS-5 499826819072 372961705984
/vmfs/volumes/58cf7105-aa6028b9-3b61-ac220b89c4ca 58cf7105-aa6028b9-3b61-ac220b89c4ca true vfat 299712512 83927040
/vmfs/volumes/58cf7115-1fb5970a-817d-ac220b89c4ca 58cf7115-1fb5970a-817d-ac220b89c4ca true vfat 4293591040 4278255616
/vmfs/volumes/01e19870-f6a57a2a-ef43-8a0ec55b7d60 01e19870-f6a57a2a-ef43-8a0ec55b7d60 true vfat 261853184 261844992
/vmfs/volumes/4f70f378-d547f85f-a7d0-bb87da3f428b 4f70f378-d547f85f-a7d0-bb87da3f428b true vfat 261853184 111271936
列出目前有開機的 VM
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 vm process list
[root@esxi:~] esxcli vm process list
ArchLinux
World ID: 170247
Process ID: 0
VMX Cartel ID: 170246
UUID: 56 4d ee c4 34 b0 7b 76-5b 7a 64 fc a1 02 b8 97
Display Name: ArchLinux
Config File: /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx
OB2D Linux 2017 1.0
World ID: 170391
Process ID: 0
VMX Cartel ID: 170390
UUID: 56 4d ff d9 24 d7 09 68-60 03 51 55 23 d1 f8 42
Display Name: OB2D Linux 2017 1.0
Config File: /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ob2d/ob2d.vmx
關閉某一台 VM
esxcli vm process kill –tyep=[soft,hard,force] –world-id=World ID
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 vm process kill –type=soft –world-id=170391
[root@esxi:~] esxcli vm process kill –type=soft –world-id=170391
列出 ESXi Server 上的 VM 資訊
[root@esxi:~] vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
1 OB2D Linux 2017 1.0 [ST500G] ob2d/ob2d.vmx other26xLinux64Guest vmx-13
2 Custom CentOS 7.x [ST500G] Custom CentOS 7.x/Custom CentOS 7.x.vmx centos7_64Guest vmx-13
21 OpenNMS [ST500G] OpenNMS/OpenNMS.vmx centos7_64Guest vmx-13
22 Nginx [ST500G] Nginx/Nginx.vmx centos7_64Guest vmx-13
24 Ubuntu 16.04.2 [ST500G] Ubuntu 16.04.2/Ubuntu 16.04.2.vmx ubuntu64Guest vmx-13
25 ArchLinux [ST500G] ArchLinux/ArchLinux.vmx other26xLinux64Guest vmx-13
26 Windows 10 1607 14393.969 [ST500G] Windows 10 1607 14393.969/Windows 10 1607 14393.969.vmx windows9_64Guest vmx-13
28 Windows 10 x64 1607 Build 14393.0 [ST500G] Windows 10 x64 1607 Build 14393.0/Windows 10 x64 1607 Build 14393.0.vmx windows9_64Guest vmx-12
開啟 OB2D Linux 2017 1.0
# vim-cmd vmsvc/power.on 1
Powering on VM:
[root@esxi:~] vim-cmd /vmsvc/power.getstate 1
Retrieved runtime info
Powered on
關閉 OB2D Linux 2017 1.0
[root@esxi:~] vim-cmd vmsvc/power.off 1
Powering off VM:
重新啟動 OB2D Linux 2017 1.0
[root@esxi:~] vim-cmd vmsvc/power.reboot 1
進入維護模式
[root@localhost ~]# esxcli –server 192.168.131.234 system maintenanceMode set –enable true
Connect to 192.168.131.234 failed. Server SHA-1 thumbprint: 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 (not trusted).
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system maintenanceMode set –enable true
Enter username: root
Enter password:
[root@esxi:~] esxcli system maintenanceMode set –enable true
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation enter
Enter username: root
Enter password:
Host esxi.localdomain entered into maintenance mode successfully.
[root@esxi:~] vim-cmd hostsvc/maintenance_mode_enter
退出維護模式
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system maintenanceMode set –enable false
Enter username: root
Enter password:
[root@esxi:~] esxcli system maintenanceMode set –enable false
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation exit
Enter username: root
Enter password:
Host esxi.localdomain exited from maintenance mode successfully.
[root@esxi:~] vim-cmd hostsvc/maintenance_mode_exit
將特定 vmid 的 vm 自磁碟中刪除,不會做任何確認,請小心使用
原本有 8 台 VM
[root@esxi:~] vim-cmd vmsvc/destroy 28
刪除後剩下 7 台
列出 ESXi Server 網路相關資訊
[root@esxi:~] vim-cmd hostsvc/net/info
[root@esxi:~] esxcli network ip interface ipv4 address list
Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type Gateway DHCP DNS
—- ————- ————- ————– ———— ————– ——–
vmk0 192.168.131.234 255.255.255.0 192.168.131.255 STATIC 192.168.131.254 false
[root@esxi:~] esxcli network ip interface ipv6 address list
Interface Address Netmask Type Status
——— ———————— ——- —— ———
vmk0 fe80::ae22:bff:fe89:c4ca 64 STATIC PREFERRED
vmk0 2001:288:a229:4::234 64 STATIC PREFERRED
[root@esxi:~] esxcli network ip interface ipv4 get
Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type Gateway DHCP DNS
—- ————- ————- ————– ———— ————– ——–
vmk0 192.168.131.234 255.255.255.0 192.168.131.255 STATIC 192.168.131.254 false
[root@esxi:~] esxcli network ip interface ipv6 get
Name IPV6 Enabled DHCPv6 Enabled Router Adv Enabled DHCP DNS Gateway
—- ———— ————– —————— ——– ———————
vmk0 true false false false 2001:288:a229:1::ffff
[root@esxi:~] esxcli network vm list
World ID Name Num Ports Networks
——– ———————– ——— ———-
75113 Windows_10_1607_14393.0 1 VM Network
74293 OB2D_Linux_2017_1.0 1 VM Network
67872 ArchLinux 1 VM Network
[root@esxi:~] esxcli network vm port list -w 74293
Port ID: 33554439
vSwitch: vSwitch0
Portgroup: VM Network
DVPort ID:
MAC Address: 00:0c:29:d1:f8:42
IP Address: 0.0.0.0
Team Uplink: vmnic0
Uplink Port ID: 33554434
Active Filters:
[root@esxi:~] esxcli network port stats get -p 33554434
Packet statistics for port 33554434
Packets received: 1426447
Packets sent: 106420
Bytes received: 465858786
Bytes sent: 25293372
Broadcast packets received: 684895
Broadcast packets sent: 91
Multicast packets received: 591189
Multicast packets sent: 302
Unicast packets received: 150363
Unicast packets sent: 106027
Receive packets dropped: 0
Transmit packets dropped: 13
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system module list
Enter username: root
Enter password:
Name Is Loaded Is Enabled
—————————– ——— ———-
vmkernel true true
chardevs true true
user true true
crypto true true
vsanapi true true
vsanbase true true
vprobe true true
vmkapi_mgmt true true
procfs true true
vmkapi_v2_2_0_0_mgmt_shim true true
vmkapi_v2_3_0_0_mgmt_shim true true
vmkapi_v2_1_0_0_vmkernel_shim true true
iodm true true
vmkapi_v2_3_0_0_vmkernel_shim true true
vmkapi_v2_2_0_0_vmkernel_shim true true
vmkata true true
iscsi_trans true true
iscsi_trans_compat_shim true true
vmkapi_v2_3_0_0_vmklinux_shim true true
vmkplexer true true
vmklinux_9 true true
vmkusb true true
vmkapi_v2_2_0_0_iscsiInc_shim true true
vmkapi_v2_3_0_0_iscsiInc_shim true true
etherswitch true true
netsched_fifo true true
netsched_hclk true true
netioc true true
vmklinux_9_2_3_0 true true
cnic_register true true
e1000 true true
dm true true
nmp true true
vmw_satp_local true true
vmw_satp_default_aa true true
vmw_psp_lib true true
vmw_psp_fixed true true
vmw_psp_rr true true
vmw_psp_mru true true
healthchk true true
teamcheck true true
vlanmtucheck true true
heartbeat true true
shaper true true
lldp true true
cdp true true
ipfix true true
tcpip4 true true
dvsdev true true
vmci true true
dvfilter true true
lacp true true
vmkapi_v2_3_0_0_dvfilter_shim true true
vmkapi_v2_1_0_0_dvfilter_shim true true
vmkapi_v2_2_0_0_dvfilter_shim true true
mptspi true true
esxfw true true
dvfilter-generic-fastpath true true
vmkibft true true
gss true true
lvmdriver true true
deltadisk true true
vdfm true true
sunrpc true true
vmfs3 true true
ufs true true
vfat true true
vmklink_mpi true true
swapobj true true
nfsclient true true
nfs41client true true
vflash true true
procMisc true true
nrdma true true
nrdma_vmkapi_shim true true
vmkapi_v2_3_0_0_rdma_shim true true
vmkapi_v2_2_0_0_nmp_shim true true
vmkapi_v2_1_0_0_nmp_shim true true
vmkapi_v2_3_0_0_nmp_shim true true
vmkapi_v2_2_0_0_iscsi_shim true true
vmkapi_v2_1_0_0_iscsi_shim true true
vmkapi_v2_3_0_0_iscsi_shim true true
hbr_filter true true
ftcpt true true
vrdma true true
filtmod true true
svmmirror true true
cbt true true
migrate true true
vfc true true
balloonVMCI true true
qfle3 false false
qflge false false
ixgben false false
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system module list –enabled=true
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system module list –enabled=true
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system module list –loaded=true
[root@localhost ~]# vicfg-module –server 192.168.131.234 –list
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system module set –module=module_name –enabled=true
防火牆
[root@esxi:~] esxcli network firewall get
Default Action: DROP
Enabled: true
Loaded: true
[root@esxi:~] esxcli network firewall ruleset list –ruleset-id sshServer
Name Enabled
——— ——-
sshServer true
[root@esxi:~] esxcli network firewall ruleset allowedip add –ruleset-id sshServer –ipaddress 192.168.131.1.0/24
[root@esxi:~] esxcli network firewall ruleset allowedip add –ruleset-id sshServer –ipaddress 192.168.1.10
列出 SSH Server Firewall Rule
[root@esxi:~] esxcli network firewall ruleset allowedip list –ruleset-id sshServer
Ruleset Allowed IP Addresses
——— ——————–
sshServer 192.168.1.10, 192.168.131.0/24
磁碟資訊
[root@esxi:~] esxcli system coredump partition list
Name Path Active Configured
————————————————————————– ———————————————————————————————- —— ———-
t10.ATA_____TS128GSSD370S___________________________C981072070__________:7 /vmfs/devices/disks/t10.ATA_____TS128GSSD370S___________________________C981072070__________:7 false false
t10.ATA_____TS128GSSD370S___________________________C981072070__________:9 /vmfs/devices/disks/t10.ATA_____TS128GSSD370S___________________________C981072070__________:9 true true
SNMP 相關資訊
[root@esxi:~] esxcli system snmp get
Authentication:
Communities: public
Enable: true
Engineid: 00000063000000a100000000
Hwsrc: indications
Largestorage: true
Loglevel: info
Notraps:
Port: 161
Privacy:
Remoteusers:
Syscontact:
Syslocation:
Targets:
Users:
V3targets:
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system snmp get
Enter username: root
Enter password:
Authentication:
Communities:
Enable: false
Engineid: 00000063000000a100000000
Hwsrc: indications
Largestorage: true
Loglevel: info
Notraps:
Port: 161
Privacy:
Remoteusers:
Syscontact:
Syslocation:
Targets:
Users:
V3targets:
[root@localhost ~]# vicfg-snmp –server 192.168.131.234 –show
Enter username: root
Enter password:
Current SNMP agent settings:
Enabled : 0
UDP port : 161
Communities :
Notification targets :
Options :
EnvEventSource=indications
engineid=00000063000000a100000000
loglevel=info
啟動 SNMP 服務
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system snmp set –enable=yes
Enter username: root
Enter password
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system snmp get
Enter username: root
Enter password:
Authentication:
Communities:
Enable: true
Engineid: 00000063000000a100000000
Hwsrc: indications
Largestorage: true
Loglevel: info
Notraps:
Port: 161
Privacy:
Remoteusers:
Syscontact:
Syslocation:
Targets:
Users:
V3targets
[root@localhost ~]# vicfg-snmp –server 192.168.131.234 –show
Enter username: root
Enter password:
Current SNMP agent settings:
Enabled : 1
UDP port : 161
Communities :
Notification targets :
Options :
EnvEventSource=indications
engineid=00000063000000a100000000
loglevel=info
[root@localhost ~]# esxcli –server 192.168.131.234 –thumbprint 8D:82:C4:77:31:18:C0:F7:21:B7:35:87:DA:F8:4C:F9:26:F9:9C:44 system snmp set –enable=no
Enter username: root
Enter password:
列出網路卡資訊
[root@esxi:~] esxcfg-nics -l
Name PCI Driver Link Speed Duplex MAC Address MTU Description
vmnic0 0000:00:19.0 ne1000 Up 1000Mbps Full ac:22:0a:80:c4:ca 1500 Intel Corporation 82579V Gigabit Network Connection
[root@localhost ~]# vicfg-nics –server 192.168.131.234 -l
Enter username: root
Enter password:
Name PCI Driver Link Speed Duplex MAC Address MTU Description
vmnic0 0000:02:01.0 e1000 Up 1000Mbps Full ac:22:0a:80:c4:ca 1500 Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
相當於 Linux 上的 top
[root@esxi:~] esxtop
列出開機時啟動的服務
[root@esxi:~] chkconfig -l
參考網頁:
用PowerCLI命令列介面 高效率管理vSphere環境 – 專題報導 – 網管人NetAdmin
vSphere自動化管理-PowerCLI | 單純的資訊年代 – 點部落
以esxi5 command line方式啟動VM | 資訊組
Jess’ IT Note: VMware vSphere PowerCLI 安裝
1. 連線到 VMware 官方網站下載 VMware-PowerCLI
提示電腦中的 PowerShell 尚未開啟 “RemoteSigned” Policy
. : 因為這個系統上已停用指令碼執行,所以無法載入 C:Program FilesVMwareInfrastructurePowerCLIScriptsInitialize-Pow
erCLIEnvironment.ps1 檔案。如需詳細資訊,請參閱 about_Execution_Policies,網址為 http://go.microsoft.com/fwlink/?LinkID
=135170。
位於 線路:1 字元:3
+ . “C:Program FilesVMwareInfrastructurePowerCLIScriptsInitialize …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
4. 執行 Set-ExecutionPolicy RemoteSigned
PS C:Windowssystem32> Set-ExecutionPolicy RemoteSigned
執行原則變更
執行原則有助於防範您不信任的指令碼。如果變更執行原則,可能會使您接觸到 about_Execution_Policies 說明主題 (網址為
http://go.microsoft.com/fwlink/?LinkID=135170) 中所述的安全性風險。您要變更執行原則嗎?
[Y] 是(Y) [A] 全部皆是(A) [N] 否(N) [L] 全部皆否(L) [S] 暫停(S) [?] 說明 (預設值為 “N”): Y
5. 再重新開啟一次,就不會有警告訊息了!
開啟時即會載入 VMware 相關指令集,詢問是否想要加入 CEIP (VMware Customer Experience Improvement Program, 即客戶使用經驗改善計劃),輸入 J 加入或 L 不加入。輸入 L 離開
6. 進行連線
PowerCLI C:> Connect-VIServer –Server <vCenter Server hostname> –User <Username> –Password <password>
或
PowerCLI C:> Connect-VIServer –Server <vCenter Server hostname>
7. VMware ESXi 主機資訊
PowerCLI C:> Get-VMHost <vCenter Server hostname>
8. VM 虛擬機器資訊
PowerCLI C:> Get-VMHost <vCenter Server hostname> | Get-VM
9. VM 網路設定
PowerCLI C:> Get-VMHost <vCenter Server hostname> | Get-VM | Get-NetworkAdapter
10. 查詢 Host 上所有 VMs 的 Snapshot
PowerCLI C:> Get-VMHost <vCenter Server hostname> | Get-VM | Get-Snapshot
11.
12. 刪除虛擬機器
PowerCLI C:> Remove-VMHost <vCenter Server hostname> –
底下在 CentOS 7.x 操作
ESXi Server IP:192.168.131.234
列出 ESXi Server 上的虛擬機器
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 -l
Enter username: root
Enter password:
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ob2d/ob2d.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Custom CentOS 7.x/Custom CentOS 7.x.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/OpenNMS/OpenNMS.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Nginx/Nginx.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Ubuntu 16.04.2/Ubuntu 16.04.2.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Windows 10 1607 14393.969/Windows 10 1607 14393.969.vmx
/vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Windows 10 x64 1607 Build 14393.0/Windows 10 x64 1607 Build 14393.0.vmx
[@more@]列出 ESXi Server 上的 VM 資訊
[root@esxi:~] vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
1 OB2D Linux 2017 1.0 [ST500G] ob2d/ob2d.vmx other26xLinux64Guest vmx-13
2 Custom CentOS 7.x [ST500G] Custom CentOS 7.x/Custom CentOS 7.x.vmx centos7_64Guest vmx-13
21 OpenNMS [ST500G] OpenNMS/OpenNMS.vmx centos7_64Guest vmx-13
22 Nginx [ST500G] Nginx/Nginx.vmx centos7_64Guest vmx-13
24 Ubuntu 16.04.2 [ST500G] Ubuntu 16.04.2/Ubuntu 16.04.2.vmx ubuntu64Guest vmx-13
25 ArchLinux [ST500G] ArchLinux/ArchLinux.vmx other26xLinux64Guest vmx-13
26 Windows 10 1607 14393.969 [ST500G] Windows 10 1607 14393.969/Windows 10 1607 14393.969.vmx windows9_64Guest vmx-13
28 Windows 10 x64 1607 Build 14393.0 [ST500G] Windows 10 x64 1607 Build 14393.0/Windows 10 x64 1607 Build 14393.0.vmx windows9_64Guest vmx-12
列出某一部虛擬機器有無做過 snapshot,1 代表有做過 snapshot
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ob2d/ob2d.vmx hassnapshot
Enter username: root
Enter password:
hassnapshot () = 1
顯示虛擬機器是否有開機 off 代表沒有開機
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/Nginx/Nginx.vmx getstate
Enter username: root
Enter password:
getstate() = off
顯示虛擬機器是否有開機 off 代表有開機
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getstate
Enter username: root
Enter password:
getstate() = on
傳回值:on, off, suspended, or unknown.
顯示虛擬機器開機的時間
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getuptime
Enter username: root
Enter password:
getuptime() = 82404
查詢 ESXi Server 版本資訊
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getproductinfo product
Enter username: root
Enter password:
getproductinfo(product) = embeddedEsx
傳回值 esx for VMware ESX, embeddedESX for VMware ESXi, or unknown.
查詢安裝的 VM 安裝平台
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx getproductinfo platform
Enter username: root
Enter password:
getproductinfo(platform) = vmnix-x86
傳回值 win32-x86 for an x86-based Windows system, linux-x86 for an x86-based Linux system, or vmnix-x86 for an x86-based ESXi microkernel.
檢查 VM 是否有安裝 VMware Tools
[root@localhost ~]# /opt/vmwarecli/bin/vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux/ArchLinux.vmx gettoolslastactive
Enter username: root
Enter password:
gettoolslastactive() = 1
傳回值
0 – VMware Tools is not installed or not running.
1 – Guest operating system is responding normally.
5 – Intermittent heartbeat. There might be a problem with the guest operating system.
100 – No heartbeat. Guest operating system might have stopped responding.
將 VM 關機
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux stop soft
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux start soft
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux reset soft
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux suspend hard
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux suspend soft
建立 Snapshot 快照
quiesce flag (0 or 1) and memory flag (0 or 1).
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux createsnapshot ArchLinuxOK ‘ArchLinux OK 2017.04.01’ 0 0
還原快照
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux revertsnapshot
刪除快照
[root@localhost ~]# vmware-cmd -H 192.168.131.234 /vmfs/volumes/58cf7810-bde83e8a-457c-ac220b89c4ca/ArchLinux removesnapshots
查詢 DNS Server 設定
[root@localhost ~]# vicfg-dns –server 192.168.131.234
Enter username: root
Enter password:
DNS Configuration
Host Name esxi
Domain Name test.ilc.edu.tw
DHCP false
DNS Servers
140.111.66.10
168.95.1.1
將 VMware ESXi Server 關機
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation shutdown –force
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation shutdown
Enter username: root
Enter password:
Host esxi.localdomain shutdown successfully.
將 VMware ESXi Server 重新啟動
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation reboot –force
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation reboot
Enter username: root
Enter password:
Host esxi.localdomain rebooted successfully.
顯示 VMware ESXi Server 資訊
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation info
Enter username: root
Enter password:
Host Name : esxi.localdomain
Manufacturer : VMware, Inc.
Model : VMware Virtual Platform
Processor Type : Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
CPU Cores : 2 CPUs x 3300 GHz
Memory Capacity : 4095.48828125 MB
VMotion Enabled : no
In Maintenance Mode : no
Last Boot Time : 2017-03-29T07:05:37.890796Z
進入維護模式
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation enter
Enter username: root
Enter password:
Host esxi.localdomain entered into maintenance mode successfully.
退出維護模式
[root@localhost ~]# vicfg-hostops –server 192.168.131.234 –operation exit
Enter username: root
Enter password:
Host esxi.localdomain exited from maintenance mode successfully.
顯示和設置一台主機從所有路徑到達它的儲存設備
[root@localhost ~]# vicfg-mpath –server 192.168.131.234 –list
Enter username: root
Enter password:
vmhba0:C0:T5:L0
Runtime Name: vmhba0:C0:T5:L0
Device: vmhba0:C0:T5:L0
Device Display Name:
Adapter: vmhba0 Channel: 0 Target: 5 LUN: 0
Adapter Identifier: sata.vmhba0
Target Identifier: sata.0:5
Plugin: NMP
State: active
Transport: sata
vmhba1:C0:T0:L0
Runtime Name: vmhba1:C0:T0:L0
Device: vmhba1:C0:T0:L0
Device Display Name:
Adapter: vmhba1 Channel: 0 Target: 0 LUN: 0
Adapter Identifier: sata.vmhba1
Target Identifier: sata.0:0
Plugin: NMP
State: active
Transport: sata
[root@localhost ~]# vicfg-nas –server 192.168.131.234 -l
Enter username: root
Enter password:
SynologyNAS is /volume1/homes/test/Server/esxi from 192.168.231.4 mounted
[root@esxi:~] esxcli storage nfs list
Volume Name Host Share Accessible Mounted Read-Only isPE Hardware Acceleration
———– ———— ———————————- ———- ——- ——— —– ———————
SynologyNAS 192.168.131.4 /volume1/homes/test/Server/esxi true true false false Not Supported
列出使用者
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o list
Enter username: root
Enter password:
USERS
—————–
Principal -: root
Full Name -: Administrator
UID -: 0
Shell Access -:1
—————–
Principal -: dcui
Full Name -: DCUI User
UID -: 100
Shell Access -:0
—————–
Principal -: vpxuser
Full Name -: VMware VirtualCenter administration account
UID -: 500
Shell Access -:0
—————–
增加一個新的使用者
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o add -l user27 -p 27_password
Enter username: root
Enter password:
Created user user27 successfully.
修改使用者密碼
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o modify -l user27 -p 27_password2
Enter username: root
Enter password:
Updated user user27 successfully.
將使用者改成唯讀
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o modify -l user27 –role read-only
Enter username: root
Enter password:
Do you want to change the password (y/n): n
Updated user user27 successfully.
刪除使用者
[root@localhost ~]# vicfg-user –server 192.168.131.234 -e user -o delete -l user27
Enter username: root
Enter password:
Removed the user user27 successfully.
安裝在 ESXi Server 中的 Arch Linux 也安裝了 open-vm-tools,但系統上還是顯示未安裝
安裝 open-vm-tools
# pcman -S open-vm-tools
檢查系統是否有安裝
# pacman -Qs open-vm-tools
local/open-vm-tools 6:10.1.0-2
The Open Virtual Machine Tools (open-vm-tools) are the open source
implementation of VMware Tools[@more@]原因是未啟動 vmtoolsd 服務,啟用了就正常了!
# systemctl list-unit-files | grep vmtools
vmtoolsd.service disabled
# systemctl enable vmtoolsd.service
Created symlink /etc/systemd/system/multi-user.target.wants/vmtoolsd.service → /usr/lib/systemd/system/vmtoolsd.service.
# systemctl start vmtoolsd.service
如果要備份或回復 VMware ESXi 的設定,可以安裝 VMware vSphere Command Line Interface。
1. 登入 VMware 官方網站下載 VMware vSphere Command Line Interface
1 – For Windows
2 – For Linux x86_64
3 – For Linux x86
[@more@]參考網頁:
vmware-vsphere-cli-centos7.sh · GitHub
The Pain and Fury of vmware-cli on CentOS 7 | Morgajel.net
Install vCLI 6 on CentOS 7 – vSphere SDK for Perl
[VMware] 在 CentOS7 上安裝 VMware vSphere CLI (vcli) 操作 VM @ 亂打一通的心情日記 :: 痞客邦 PIXNET ::
在 CentOS7 上安裝 VMware vSphere CLI (vcli) – IT閱讀
2. 安裝必備套件
# yum install epel-release
# yum update
# yum install openssl-devel cpan perl-Devel-StackTrace perl-Class-Data-Inheritable perl-Convert-ASN1 perl-Crypt-OpenSSL-RSA perl-Exception-Class perl-Archive-Zip perl-Try-Tiny perl-Crypt-SSLeay perl-XML-SAX perl-XML-NamespaceSupport perl-libxml-perl perl-XML-LibXML perl-Socket6 perl-IO-Socket-INET6 libuuid-devel perl-Crypt-OpenSSL-X509 perl-Path-Class perl-Class-MethodMaker perl-Data-UUID perl-Data-Dump perl-SOAP-Lite perl-Net-INET6Glue
# PERL_MM_USE_DEFAULT=1 cpan install BINGOS/ExtUtils-MakeMaker-6.96.tar.gz LEONT/Module-Build-0.4205.tar.gz GBARR/libnet-1.22.tar.gz GAAS/libwww-perl-5.837.tar.gz PERLER/UUID-Random-0.04.tar.gz
3. 解壓縮
# tar xvzf VMware-vSphere-CLI-6.5.0-4566394.x86_64.tar.gz
4. 切換目錄
# cd vmware-vsphere-cli-distrib
5. 進行安裝
# ./vmware-install.pl –prefix=/opt/vmwarecli EULA_AGREED=yes –default
Creating a new vSphere CLI installer database using the tar4 format.
Installing vSphere CLI 6.5.0 build-4566394 for Linux.
This vSphere CLI installer includes precompiled Perl modules for RHEL.
Answering yes will install the precompiled modules, and answering no will
install from CPAN.
Do you want to install precompiled Perl modules for RHEL?
[yes]
Please wait while copying vSphere CLI files…
The installation of vSphere CLI 6.5.0 build-4566394 for Linux completed
successfully. You can decide to remove this software from your system at any
time by invoking the following command:
“/opt/vmwarecli/bin/vmware-uninstall-vSphere-CLI.pl”.
This installer has successfully installed both vSphere CLI and the vSphere SDK
for Perl.
The following Perl modules were found on the system but may be too old to work
with vSphere CLI:
Devel::StackTrace 1.31 or newer
MIME::Base64 3.14 or newer
Try::Tiny 0.22 or newer
LWP 6.15 or newer
Socket6 0.23 or newer
IO::Socket::INET6 2.71 or newer
Net::HTTP 6.09 or newer
Enjoy,
–the VMware team
6. 程式安裝路徑
# ls -l /opt/vmwarecli/bin/vicfg-*
-r-xr-xr-x. 1 root root 9632 3月 28 19:23 /opt/vmwarecli/bin/vicfg-advcfg
-r-xr-xr-x. 1 root root 11645 3月 28 19:23 /opt/vmwarecli/bin/vicfg-authconfig
-r-xr-xr-x. 1 root root 8920 3月 28 19:23 /opt/vmwarecli/bin/vicfg-cfgbackup
-r-xr-xr-x. 1 root root 9140 3月 28 19:23 /opt/vmwarecli/bin/vicfg-dns
-r-xr-xr-x. 1 root root 12580 3月 28 19:23 /opt/vmwarecli/bin/vicfg-dumppart
-r-xr-xr-x. 1 root root 16564 3月 28 19:23 /opt/vmwarecli/bin/vicfg-hostops
-r-xr-xr-x. 1 root root 24199 3月 28 19:23 /opt/vmwarecli/bin/vicfg-ipsec
-r-xr-xr-x. 1 root root 76696 3月 28 19:23 /opt/vmwarecli/bin/vicfg-iscsi
-r-xr-xr-x. 1 root root 6872 3月 28 19:23 /opt/vmwarecli/bin/vicfg-module
-r-xr-xr-x. 1 root root 20543 3月 28 19:23 /opt/vmwarecli/bin/vicfg-mpath
-r-xr-xr-x. 1 root root 17871 3月 28 19:23 /opt/vmwarecli/bin/vicfg-mpath35
-r-xr-xr-x. 1 root root 8314 3月 28 19:23 /opt/vmwarecli/bin/vicfg-nas
-r-xr-xr-x. 1 root root 9364 3月 28 19:23 /opt/vmwarecli/bin/vicfg-nics
-r-xr-xr-x. 1 root root 7144 3月 28 19:23 /opt/vmwarecli/bin/vicfg-ntp
-r-xr-xr-x. 1 root root 2874 3月 28 19:23 /opt/vmwarecli/bin/vicfg-rescan
-r-xr-xr-x. 1 root root 13481 3月 28 19:23 /opt/vmwarecli/bin/vicfg-route
-r-xr-xr-x. 1 root root 21745 3月 28 19:23 /opt/vmwarecli/bin/vicfg-scsidevs
-r-xr-xr-x. 1 root root 12387 3月 28 19:23 /opt/vmwarecli/bin/vicfg-snmp
-r-xr-xr-x. 1 root root 5643 3月 28 19:23 /opt/vmwarecli/bin/vicfg-syslog
-r-xr-xr-x. 1 root root 22531 3月 28 19:23 /opt/vmwarecli/bin/vicfg-user
-r-xr-xr-x. 1 root root 26398 3月 28 19:23 /opt/vmwarecli/bin/vicfg-vmknic
-r-xr-xr-x. 1 root root 13010 3月 28 19:23 /opt/vmwarecli/bin/vicfg-volume
-r-xr-xr-x. 1 root root 36078 3月 28 19:23 /opt/vmwarecli/bin/vicfg-vswitch
# ls -l /opt/vmwarecli/bin/vm*
-r-xr-xr-x. 1 root root 40411 3月 28 19:23 /opt/vmwarecli/bin/vmkfstools
-r-xr-xr-x. 1 root root 59908 3月 28 19:23 /opt/vmwarecli/bin/vmware-cmd
-r-xr-xr-x. 1 root root 128151 3月 28 19:23 /opt/vmwarecli/bin/vmware-uninstall-vSphere-CLI.pl
7. 進行備份
–server Server’IP
-s 備份設定
# /opt/vmwarecli/bin/vicfg-cfgbackup –server 192.168.1.234 -s /root/esx.cfg
Enter username: root
Enter password:
Saving firmware configuration to /root/esx.cfg …
8. 還原設定值,ESXi Server 會重新啟動
# /opt/vmwarecli/bin/vicfg-cfgbackup –server 192.168.1.234 -l /root/esx.cfg
Enter username: root
Enter password:
The restore operation will reboot the host.
Type ‘yes’ to continue:
yes
Uploading config bundle to configBundle.tgz …
Performing restore …
系統重新開機
9. 指令用法
# /opt/vmwarecli/bin/vicfg-cfgbackup –help
Synopsis: /opt/vmwarecli/bin/vicfg-cfgbackup OPTIONS [<backupfile>]
Command-specific options:
–force
-f
Force the restore of the configuration.
–load
-l
Restore configuration onto the host
–quiet
-q
Do not prompt for user confirmation.
–reset
-r
Resets host, restore to factory settings.
–save
-s
Backup the host configuration.