Check all articles

Commands to configure zones on Solaris

Since the release of the Solaris 10 (version of 2005), virtualizations can be made through software, this functionality is called Solaris Zones.

Well, but what is a zone? The idea is to create, through the zones, an isolated server with a limited amount of resources: CPU, Memory and Storage. This server would be an instance of the main server (which is called GLOBAL, the operating system is installed here). Each virtualized server (zone) runs on the same version of the kernel, being able to use all the assigned resources up to the limit of that zone, previously configured.

Each zone can execute different applications. Also, a zone has its own name, amount of memory, processors, access to a physical or virtual network interface and its storage. For security, one zone can not access any process from another zone.

The status of a zone could be: configured, installed, incomplete, ready, running.

However, what is the reason for using zones? The zones are optimal for computing environments that consolidate several applications in a single server and you need to have a level of isolation between the zones.

A very important consideration, when we work with infrastructure, is to have a capacity plan to establish our computational resources needs and the usage that we are going to give each zone in our company, always... always... we must always document in detail the allocation of resources.

Here are some of the recommended tasks (task map) by Oracle Corporation when creating zones:

  • Identify the applications that you would like to run in zones.
  • Determine how many zones to configure.
  • Determine whether you will use resource pools with your zone to create a container.
  • Perform the preconfiguration tasks.
  • Develop configurations.
  • As global administrator, verify and install configured zones.
  • As global administrator, boot the non-global zone.
  • Prepare the new zone for production use.

So, in this small article you will find the most common commands for using Zones on Solaris, this is a short guide. For a complete reference, please check the documentation of the Solaris operating system zones.


Activate the zones service

To be able to use the zones, execute:

global#svcadm enable zones

List the zones

To obtain a list of all the zones, the following command is used. In the output, the ID column is the identification of the zone (consider that GLOBAL is always 0). The STATUS column indicates the status of the zone. The PATH column is the directory where the storage of the files of the corresponding zone is located.

global#zoneadm list -icv

Check the available storage of the zone

By executing the command below from the global zone, you can obtain the amount of space assigned to the zone (gigabytes), how much space is being used (gigabytes)?, how much space is still available (gigabytes)? and the percentage of usage. It is necessary to indicate the directory from the content of the PATH column in order to know the available space. Where zone_directory_name is the directory that we assign to the zone in the zonepath parameter.

global#df -kh directory_path

Create a zone

To create a zone we must consider that the name starts with an alphanumeric character; the maximum length is 64 characters; the name accepts alphanumerics, underlining, hyphens and periods; the GLOBAL name is reserved and can not be started by SUNW; the name of the zone must be unique and not exist previously.

Then, for creating a zone follow these steps:

  • Create the directory where there is space in the global zone.
  • Choose the name of the zone, we set "my-zone" for this guide.
  • Create the zone with the chosen name (my-zone).
  • Configure the directory for the storage /export/zonas/my-zone.
  • Configure the network interface.
  • Assign dedicated CPU.
  • Allocate memory.

Then, execute the following commands for creating the zone:

global#mkdir –p /export/zones/my-zone
global#chmod 700 /export/zones
global#zonecfg -z my-zone
zonecfg:my-zone> create
zonecfg:my-zone> set zonepath=/export/zones/my-zone
zonecfg:my-zone> set autoboot=false
zonecfg:my-zone> add net
zonecfg:my-zone:net> set address=10.1.1.10
zonecfg:my-zone:net> set defrouter=10.1.1.1
zonecfg:my-zone:net> set physical=hme0
zonecfg:my-zone:net> end
zonecfg:my-zone> add dedicated-cpu
zonecfg:my-zone:dedicated-cpu> set ncpus=1-3
zonecfg:my-zone:dedicated-cpu> set importance=2
zonecfg:my-zone:dedicated-cpu> end
zonecfg:my-zone> add capped-memory
zonecfg:my-zone:capped-memory> set physical=500m
zonecfg:my-zone:capped-memory> set swap=100m
zonecfg:my-zone:capped-memory> set locked=50m
zonecfg:my-zone:capped-memory> end
zonecfg:my-zone> verify
zonecfg:my-zone> commit
zonecfg:my-zone> exit
global#zoneadm -z my-zone install
global#zoneadm -z my-zone boot
					

Connect to a zone

To connect to a zone, use the command:

#zlogin my-zone

To start a zone

To start a zone, use the command:

#zoneadm –z my-zone boot

To stop a zone

To stop a zone, use the command:

#zoneadm –z my-zone halt

To restart a zone

To restart a zone, use the command:

#zoneadm –z my-zone reboot

Uninstall a zone

When a zone is uninstalled it goes to STATUS configured.

#zoneadm -z my-zone uninstall -F

Delete a zone

Remove the zone with the command:

#zonecfg -z my-zone delete -F

Show the name of the zone

This command prints in the console the name of the zone where we are logged:

#zonename