Managing Linux in a Virtual Environment

Linux has been running in data centers all over the world for a quite a while now. Traditionally, the concept of a server means a physical machine distinct from other physical machines. This was true until the arrival of virtualization, where a single server could be carved up to become several virtual servers, with each one appearing as if they are independent servers on the network. Conversely, a ”pool” of servers made up of several physical servers can be carved up as deemed necessary.

Since there is a no longer a one-on-one relationship between a physical server and a logical or virtual server, some concepts might appear tricky. For instance, what is available memory? Is it available memory of (1) the virtual server, (2) the individual physical server from where the virtual server was carved out of, or (3) the total of the pool of servers the virtual server is a part of? So Linux commands may behave a little differently when operated under a virtual environment.

In addition, the virtual environment also needs some administration so there are specialized commands for the management of the virtualized infrastructure. In this section you will learn about the specialized commands and activities related to the virtual environment. We will use Oracle VM as an example.

One of the key components of the virtualization in an Oracle VM environment is the Oracle VM Agent, which must be up for Oracle VM to be fully operational. To check if the agent is up, you have to get on to the Administration server (provm1, in this case) and use the service command:

[root@provm1 vnc-4.1.2]# service ovs-agent status ok! process OVSMonitorServer exists. ok! process OVSLogServer exists. ok! process OVSAgentServer exists. ok! process OVSPolicyServer exists. ok! OVSAgentServer is alive.

The output shows clearly that all the key processes are up. If they are not up, they may have been misconfigured and you may want to configure it (or configure it the first time):

# service ovs-agent configure

The same service command is also used to start, restart and stop the agent processes:

service ovs-agent start service ovs-agent restart service ovs-agent stop	

The best way, however, to manage the environment is via the GUI console, which is Web based. The Manager Webpage is available on the Admin server, at the port 8888, by default. You can bring it up by entering the following on any Web browser (assuming the admin server name is oradba2).

http://oradba2:8888/OVS

Login as admin and the password you created during installation. It brings up a screen shown below:

 

The bottom of the screen shows the physical servers of the server pool. Here the server pool is called provmpool1 and the physical server IP is 10.14.106.0. On this screen, you can reboot the server, power it off, take it off the pool and edit the details on the server. You can also add a new physical server to this pool by clicking on the Add Server button.

Clicking on the IP address of the server brings up the details of that physical server, as shown below:

Perhaps the most useful is the Monitor tab. If you click on it, it shows up the utilization of resources on the server – CPU, disk and memory, as shown below. From this page you can visually check if the resources are under or over utilized, if you need to add more physical servers and so on.

Going back to the main page, the Server Pools tab shows the various server pools defined. Here you can define another pool, stop, reinstate the pool and so on:

If you want to add a user or another administrator, you need to click on the Administration tab. There is a default administrator called ”admin”. You can check all the admins here, set their properties like email addresses, names, etc.:

Perhaps the most frequent activity you will perform is the management of individual virtual machines. Almost all the functions are located on the Virtual Machines tab on the main home page. It shows the VMs you have created so far. Here is a partial screenshot showing two machines called provmlin1 and provmlin2:

The VM named provmlin2 shows as ”powered off”, i.e. it appears as down to the end users. The other one – provmlin1 – has some kind of error. First, let’s start the provmlin2 VM. Select the radio button next to it and click on the button Power On. After some time it will show as ”Running”, shown below:

If you click on the VM name, you will be able to see the details of the VM, as shown below:

From the above screen we know that the VM have been allocated 512MB of RAM; it runs Oracle Enterprise Linux 5; it has only one core and so on. One of the key information available on the page is the VNC port: 5900. Using this, you can bring up the VNC terminal of this virtual machine. Here, I have used a VNV viewer, using the hostname provm1 and port 5900:

This brings up the VNC session on the server. Now you can start a terminal session:

Since the VNC port 5900 pointed to the virtual machine called provmlin4, the terminal on that VM came up. Now you can issue your regular Linux commands on this terminal.

xm

On the server running the virtual machines, the performance measurement commands like uptime (described in Installment 3) and top (described in Installment 2) have different meanings compared to their physical server counterparts. In a physical server the uptime refers to the amount if time the server has been up, while in a virtual world it could be ambiguous – referring to the individual virtual servers on that server. To measure performance of the physical serverpool, you use a different command, xm. The commands are issued from this main command. For instance, to list the virtual servers, you can use the command xm list:

[root@provm1 ~]# xm list Name                                        ID   Mem VCPUs      State   Time(s) 22_provmlin4                                1   512     1         -b----   27.8 Domain-0                                    0   532     2         r-----   4631.9

To measure uptime, you would use xm uptime:

[root@provm1 ~]# xm uptime Name                                ID Uptime  22_provmlin4                        1  0:02:05 Domain-0                            0  8:34:07

The other commands available in xm are shown below. Many of these commands can be executed via the GUI as well.

console             Attach to 's console.                       create             Create a domain based on .              new                Adds a domain to Xend domain management             delete             Remove a domain from Xend domain management.        destroy            Terminate a domain immediately.                     dump-core          Dump core for a specific domain.                    help               Display this message.                               list               List information about all/some domains.            mem-set            Set the current memory usage for a domain.          migrate            Migrate a domain to another machine.                pause              Pause execution of a domain.                        reboot             Reboot a domain.                                    restore            Restore a domain from a saved state.                resume             Resume a Xend managed domain.                        save               Save a domain state to restore later.               shell              Launch an interactive shell.                        shutdown           Shutdown a domain.                                 start              Start a Xend managed domain.                        suspend            Suspend a Xend managed domain.                      top                Monitor a host and the domains in real time.        unpause            Unpause a paused domain.                            uptime             Print uptime for a domain.                          vcpu-set           Set the number of active VCPUs for allowed for the domain.

Let’s see some frequently used ones. Besides uptime, you may be interested in the system performance via the top command. This command xm top acts pretty much like the top command in the regular server shell – it refreshes automatically, has some keys that bring up different types of measurements such as CPU, I/O, Network, etc. Here is the output of the basic xm top command:

xentop - 02:16:58   Xen 3.1.4 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 1562776k total, 1107616k used, 455160k free    CPUs: 2 @ 2992MHz NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR SSID 22_provmlin4 --b---       27      0.1    524288  33.5    1048576     67.1     1    1        9      154    1        06598     1207    0  Domain-0 -----r        4647      23.4   544768  34.9   no limit      n/a     2    8    68656  2902548    0        0         0       0

It shows the stats like the percentages of CPU used, memory used and so on for each Virtual Machine. If you press N, you will see network activities as shown below:

 xentop - 02:17:18   Xen 3.1.4 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 1562776k total, 1107616k used, 455160k free    CPUs: 2 @ 2992MHz Net0 RX:   180692bytes     2380pkts        0err      587drop  TX:     9414bytes       63pkts        0err        0drop   Domain-0 -----r       4650   22.5     544768   34.9   no limit       n/a     2    8    68665  2902570    0        0  0        0    0 Net0 RX: 2972232400bytes  2449735pkts        0err        0drop  TX: 70313906bytes  1017641pkts        0err        0drop Net1 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net2 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net3 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net4 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net5 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net6 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop Net7 RX:        0bytes        0pkts        0err        0drop  TX:        0bytes        0pkts        0err        0drop

Pressing V brings up VCPU (Virtual CPU) stats.

xentop - 02:19:02   Xen 3.1.4 2 domains: 1 running, 1 blocked, 0 paused, 0 crashed, 0 dying, 0 shutdown Mem: 1562776k total, 1107616k used, 455160k free    CPUs: 2 @ 2992MHz NAME  STATE   CPU(sec) CPU(%)     MEM(k) MEM(%)  MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS   VBD_OO   VBD_RD   VBD_WR SSID 22_provmlin4 --b---      28      0.1     524288   33.5    1048576    67.1     1    1        9     282    1       06598     1220    0 VCPUs(sec):   0:         28s Domain-0 -----r          4667    1.6     544768   34.9   no limit     n/a     2    8    68791  2902688   0       00        0       0 VCPUs(sec):   0:       2753s  1:       1913s

Let’s go through some fairly common activities – one of which is distributing the available memory among the VMs. Suppose you want to give each VM 256 MB of RAM, you should use xm mem-set command as shown below. Later you should use xm list command to confirm that.

[root@provm1 ~]# xm mem-set 1 256 [root@provm1 ~]# xm mem-set 0 256 [root@provm1 ~]# xm list Name ID Mem VCPUs State Time(s) 22_provmlin4 1 256 1 -b---- 33.0 Domain-0 0 256 2 r----- 4984.4







(Extracted from oracle technet notes author Arup Nanda)