很多重要的VMWARE相关操作将不得不从VCenter转到Console。在这一章中,我们将使用一些有用的命令行工具去监控、配置ESX服务器。
5.1通过命令行进入维护模式
Problem
You are unable to access your vCenter GUI and you want to put your ESX Server into
maintenance mode.
Solution
Log into your ESX host via SSH or directly from the console.
Discussion
To enter maintenance mode, use this command:
vimsh -n -e /hostsvc/maintenance_mode_enter
To exit maintenance mode, enter:
vimsh -n -e /hostsvc/maintenance_mode_exit
5.2显示服务器信息
Run the esxcfg-info command on the ESX Server.
$ esxcfg-info -h
Usage: esxcfg-info mode
-a, --all Print all information
-w, --hardware Print hardware information
-r, --resource Print resource information
-s, --storage Print storage information
-n, --network Print network information
-y, --system Print system information
-o, --advopt Print advanced options
-u, --hwuuid Print hardware uuid
-b, --bootuuid Print boot partition uuid
-e, --boottype Print boot type
-c, --cmdline Print vmkernel command line
-F, --format Print the information in the given format
Valid values are "xml" and "perl"
-h, --help Print this message.
The following example displays the first few lines of output on one of our systems:
$ esxcfg-info | more
The information you can gather about your system from this command is so comprehensive
that you may wish to export it to a text file, like this:
esxcfg-info > esxcfginfo12102008.txt
The -F option will also let you export the data in XML or Perl. This can be useful if you
wish to parse the output and store it in a proprietary or third-party application.
An example of exporting network and storage information in XML format follows
(we’ve truncated the output in this example to save space):
$ esxcfg-info -s -n -F xml | more
<network-info>
<value name="current-max-virtual-switches" type="uint32"
format="dec">128</value>
<value name="next-reboot-max-virtual-switches" type="uint32"
<console-nic-info>
<console-nics>
<vswif>
<value name="name" type="string">vswif0</value>
<value name="port-group" type="string">Service Console</value>
<value name="port-id" type="uint32" format="dec">16777221</value>
<value name="enabled" type="bool">true</value>
<value name="exists" type="bool">true</value>
<value name="mac-address" type="string">00:50:56:41:a6:93</value>
<value name="mtu" type="uint32" format="dec">1500</value>
<configured-ip-settings>
<value name="type" type="string">Static</value>
<value name="ipv4-address" type="string">172.20.46.2</value>
<value name="ipv4-netmask" type="string">255.255.255.0</value>
<value name="ipv4-broadcast" type="string">172.20.46.255</value>
<value name="valid-config" type="bool">true</value>
</configured-ip-settings>
<actual-ip-settings>
</actual-ip-settings>
</vswif>
</console-nics>
</console-nic-info>
5.3 查询esx版本号