13.3. Configuring and Managing ESX Server Service Console from the Command LineThe previous section of this chapter focused on some of the more common commands used to navigate the directory structure, to manage files and directories and manage users and groups. This section covers commands which are most applicable for managing your processes, devices, and the configuration of your ESX Server from the Service Console. The command line can be used to manage your ESX server VMFS volumes, device allocations, network configuration, running processes, and virtual machines. This section discusses the following:
13.3.1. Managing Processes, Restarting Services, and Viewing Performance StatisticsFrom time to time you may find it necessary to view running processes for troubleshooting purposes. You may also need to kill a running process that is not running correctly. The following sections show the command-line tools you can use to manage processes, restart services, and view the performance data of your Service Console. 13.3.1.1. Managing ProcessesYou can use the ps and kill commands to view your running processes. To list all processes running on the Service Console, type
Each process will be listed with its process ID (PID). If you want to list all processes shown with its parent process, type
Figure 13.27 shows a partial output of the command. Notice the PPID, which is circled. This is the process ID of the parent controlling process. Figure 13-27. Partial Output of ps CommandIf you need to kill a process, type
You would replace pid with the process ID of the process you wish to stop. If you need to force a process to stop if kill will not work, type
If you have a program that is actively running in the foreground, you can suspend the program by pressing Ctrl + z. You can also place the program in the background and let it continue to run by typing
To start a command running in the background, type
To list all programs running in the background, type
And to stop a background job, type
13.3.1.2. Restarting ServicesIf you need to change the way services start on your Service Console, or you need to restart services when configuration changes have been made, you can use the following commands: If you need to restart a service, type
A good example would be restarting the Web server by typing
To have a service start at boot time, type
Note: You can find the name of available services in the /etc/init.d directory by typing ls/etc/init.d. 13.3.1.3. Viewing Service Console Performance StatisticsTo get a real-time view of your Service Console's performance statistics, type
The results for top are shown in Figure 13.28 Figure 13-28. Real-Time View of a Service Console's Performance StatisticsTo exit the top utility, press Quit. The top utility displays top CPU processes by default, but you can specify additional options. You can specify specific processes you would like to monitor, kill processes, and rearrange the way results are shown on screen. If you want more details on the capabilities of top, you can view the man page for it by typing
13.3.2. Managing Physical and Virtual DisksThis section shows the commands used to manage both the physical disk of your ESX Server and the virtual disk files. If you need to view current partitions, sizes, and the amount of disk space consumed, type
The output of the vdfh command is shown in Figure 13.29 Figure 13-29. Output of the vdfh CommandIf you want to view the contents of a VMFS volume on your server, type
Or you can specify the hba number, scsi target, LUN number, and partition numbersay, for example, by typing
Figure 13.30 shows the output of the vmkfstoolsl vmhba0:011 command. The easiest way to find the vmhba information is to look back at Figure 13.29, which shows the output of the vdfh command. This shows you the configured vmfs volumes on your server. You can also use the lsl command to view the contents of your vmfs volume. Figure 13-30. Using the lsl Command to View the Contents of a vmfs FileTo identify the source of a vmdk file, type
Table 13.4 shows the outputs depending on which VMware product was used to create the virtual disk.
To check disk space consumption under a specific directory, type
To find out which device file maps to a LUN, type
(This refreshes the table of device files.) Then type
To export a virtual disk from vmfs to a different location on your ESX Server, type
One of the main reasons you would want to do this is to move a virtual machine template from the vmfs volume to a directory that contains your template images on your server. If you need to import a virtual disk file from VMware Workstation of GSX Server, type
If the virtual disk is already in ESX Server format, you can use the cp or mv commands to move the file from a template directory to the VMFS volume or vise versa. 13.3.3. Installing and Managing Software PackagesWhile maintaining your ESX Server you may find it necessary to install or remove additional software packages on the Service Console. Examples of this are third-party management agents, backup software, and so on. The Service Console uses Red Hat Package Manager (RPM packages) for software tracking and installation. RPM maintains a database of installed packages and tracks which files are required for software to function properly. If you want to find out which packages are currently installed on your server, type
Remember, you can also use the command with grep to filter for specific packages. For example, we queried the RPM database for all packages that contain VM in the package name. You can see the results of this query in Figure 13.31 Figure 13-31. Output of the rpmqa | grep vm CommandTo view the packages in sorted order, type
To view the description of a package, type
An example of this can be seen in the following command:
The results are shown in Figure 13.32 Figure 13-32. Output of rpmqi Displaying Detailed RPM Package InformationTo find out which files are associated with a software package, type
To uninstall a package on your server, type
13.3.4. Managing Devices and Changing Hardware and Network SettingsYou may want to know which device drivers are currently loaded by the Service Console for troubleshooting purposes. The following shows a few ways to find out. To view the device drivers currently loaded by the Service Console, type
To view the device drivers currently loaded by the VMkernel, type
To view or change the device allocation between the Service Console and the VMkernel, type
This command allows you to change the following options on your ESX Server:
You'll have the option to commit or discard your changes at the end of the configuration questions. To view the IP address of the Service Console, type
To change the IP address or subnet mask of the Service Console NIC, edit the following file:
Change the IPADDR=xx.xx.xx.xx line to the new IP address or change the NETMASK=xx.xx.xx.xx line to the new subnet mask. To change the default gateway, edit the following file:
Then, edit the following line:
Note: If you used the netconfig utility to configure networking on your server, you may actually find the gateway address in the /etc/sysconfig/network-scripts/ifcfg-eth0 file. To change the DNS Server settings on the Service Console, edit the following file:
Then, edit the following lines:
If you need to change the host name of the ESX Server, edit the following files:
Change the HOSTNAME=servername line to reflect the new hostname /etc/hosts (if an entry for your server does not exist, then add one in the following format):
The following can be used as an example:
Once you've made the changes to the configuration files, you need to restart networking for the changes to take effect. To restart networking, type
To prepare your Service Console to synchronize time across the network, you need to set up the ntpd daemon by performing the following steps: Set the ntpd service to start at boot time by typing
Then you need to create the /etc/ntpd.conf file. Within the /etc/ntdp.conf file place the IP address or DNS name of your NTP server, preceded by the work server. An example of this would look like the following:
Once you've completed this step, you need to start the ntpd daemon by typing
|