In the last issue we discussed how to install Solaris 10 on x86 systems and
highlighted some of its unique features. In this article, we discuss how to
implement 'Containers,' an in-built application that lets you create different
instances of Solaris 10.
Direct Hit! |
Applies To: Network admins USP: Learn how to make and manage Containers Primary Link: www.sun.com/software/solaris Keywords: Solaris 10 |
The concept of Containers in Solaris is similar to that of 'Virtualization'
in Linux or Windows. Using this technology one can run multiple applications on
a single server and each application runs as if it's the only application
running on that virtual instance. Suppose an enterprise has three different
servers for handling three different tasks-a mail server, a web server and a
database server. Using containers these servers can be consolidated into a
single powerful server and you can allocate the any amount of resources for each
of them. Further you can also assign a single resource to two different servers
(sharing of resources).
Before we move further, you should be familiar with the following terms:
1. Solaris Zone: It is similar to a complete virtual machine in Linux
or Windows. There can be more than two zones on a single system, depending on
the hardware configuration, and each zone is completely isolated from the other.
The global zone is by default, the master zone (you can understand it as the
DOM0 of XEN virtualization). The master zone helps in creating other zones where
you can implement your applications; these newly created zones are called local
zones. The local zone runs parallel to the global zone and not inside the global
zone.
2. Resource pool: It's an abstraction of the actual hardware resource
and is associated to a particular zone. In other words, a pool contains a subset
of a hardware resource and is also known as a resource set, which contains
information about the number of CPUs and the amount of memory that would be used
by a particular zone. Presently there is only one resource type found in Solaris
10, the processor set.
Create a zone & resource pool
Here we show you how to make a resource pool and then a zone, which will
serve as a web server. As discussed, there is a global zone and a default
resource pool on any Solaris 10 system.This default resource pool is associated
with the global zone. So to create a resource pool you have to explicitly enable
this facility and then update the current configuration file by running the
following command:
# pooladm -e
# pooladm —s
Initially there is no pool configured and hence only one pool as well as
one zone will be visible. In order to view the resource pool and the zone,
execute the following command:
# pooladm
In the output you can see three different things: “pool pool_default”,
“pset pser_default” and “pool pool_default.' These show you all the parameters
related to the global pool, default resource set and default resource pool. Now
we need to create a new resource pool, which can be done by running the
following:
# poolcfg -c 'create pset web-pset (uint pset.min=1,
uint pset.max=1)'
# poolcfg -c 'create pool web-pool'
# poolcfg -c 'associate pool web-pool (pset web-pset)'
# poolcfg -c
The first command is used to create a processor set (also known as a resource
set), which means that only one CPU will be allocated to the pool. Next we
create a pool named as 'web-pool' and then associate the processor set to the
'web-pool'. This means that any zone which is using this 'web-pool' will be
allocated with one CPU. And then you finally activate the configuration that you
just created, ie the web-pool. To view the 'web-pool' and 'resource set' execute
the following command:
# pooladm
In the output search for the line “pset.size 1” which will be found under
'pset web-pset'. This tells you that only one CPU is allocated to the web-pool
created by you.
After the pool has been created, it's time to create a zone. For creating a
zone, first define the properties for the zone, second install and copy a part
of the file system hierarchy to be reserved for this zone, third by using the
Zone tool we will boot the zone. Once the zone is completely booted we will log
on to the zone and configure it for usage.
For creating the zone you have to use the Zone Configuration tool. Invoke the
tool by running the following command:
# zonecfg -z web-zone
After this command is executed, you will be shown a message, 'No such zone is
there to configure. To create such a zone use create command.' So create a zone
by following the steps below:
A single resource pool can be dedicated to a single zone (left). The same resource pool can also be used to share resources between two zones (right) |
zonecfg:web-zone# create
zonecfg:web-zone> set zonepath=/export/home/zones/web-zone
zonecfg:web-zone> set autoboot=true
zonecfg:web-zone> add net
zonecfg:web-zone:net> set address = 192.168.0.60
zonecfg:web-zone:net> set physical=erg0
zonecfg:web-zone:net> end
zonecfg:web-zone> set pool=web-pool
zonecfg:web-zone> verify
zonecfg:web-zone> commit
zonecfg:web-zone> exit
In the above commands we have assigned disk space to the zone, which is by
default 100 MB plus the amount of the space required by the application. Now,
suppose you need to restart your system, you'll find that your configured zone
doesn't automatically boot, so for that you need to set 'autoboot' option as
true. Next comes the networking part where you need to specify a static IP for
your zone so that it can be used virtually as a separated PC on the network. And
by default the subnet is taken from the global pool. Replace the IP
“192.168.0.60” below with any free IP of your network and then specify which
network card it should use. If you don't know the name of the network card, run
'ifconfig —a' and this will show you all the required details. Next assign which
pool the web-zone should use, which in our case is web-pool. Finally commit the
configuration and exit.
After this configuration, it's time to install and boot the web-zone. For
this, run the following command. This process will take time, as file system
hierarchy will be created in this step.
# zoneadm -z web-zone install
# zoneadm -z web-zone boot
Once the system i.e. zone is booted, you have to log on to this new system,
ie the web-zone, to configure it to serve as a web server. To login, type
username as 'root' and the password, the same as the systems root password. Run
the command:
# zlogin -C web-zone
Provide the username and password, and you are logged into this new system,
ie web-zone. To configure it as a web server it is assumed that you have
installed the entire distro of Solaris 10 on your system. So run the following
commands and your web server will be up and running:
# mv /etc/apache/httpd.conf-example /etc/apache/httpd.conf
# /usr/apache/apachectl start
For testing this open a web browser on any computer connected to the same
network, to which your Solaris 10 machine is connected and type the IP specified
by you while configuring the web-zone network. In our case it's '192.168.0.60.'
After this, press enter and it shows you the Apache test page.