Professional Documents
Culture Documents
Home
LDOM
Zones
How-To-Docs-LDOM
How-To-Docs-Zones
A zone is a virtualized OS which is created within a single instance of Solaris 10. Each
environment has its own identification that is separate from the primary hardware. Each
environment works independently as if running on its own system, making consolidation simple,
safe, and secure. In this article, we will discuss about the Solaris Zones/container in detail.
whenever we go to the new topic, there are 3 questions will raise, what ? why ? and how? let we
can find the answers...
Advantages of ZONES
Reduce costs by running multiple instances
workloads on the same system
Better hardware utilization
Reduced infrastructure overhead
Lesser administration costs (admins/workload)
Resource controls
Security isolation
Software package administration
ZONE FEATURES
Zones can run on any number of available CPUs and amount of available
Granularity
memory.
Isolate Run the Multiple application on same Global Zone.
Hacking one zone does not compromise applications running in other
Security
zones.
Applications do not need to be recompiled to run in zones (except for
Transparency
some privileged operations)
Virtualization Hide configuration information from applications
Memory Capping Manage the memory usage of zones
Dynamic Resource
Assign CPUs to Zones
Pools
Fair share scheduler Grant a zone minimal CPU usage.
Key Points :-
• Depends on our hardware capability we can create the non-global zones up to 8191.
• Each zone has an ID assigned by system when it's booted with the global zone, always listed as
zone ID 0.
• Only the global zone contains a bootable Solaris kernel and is aware of all devices, file
systems, zones.
Types Of ZONES : Zones come in two flavors:
Global Zone
• Global zones controls the hardware resources and are administrating the Non-Global
Zones.
Non-Global Zone
• Virtualized Solaris execution environments, but that look and feel just like a normal
standalone servers and also its called as Local Zones. There are 3 types Of Local Zones.
• Share binaries with the global zone and also called as Native Zones.
• /usr, /platform, /sbin, /lib are the FS are shared from global zone as read-only loopback
filesystem.
• Very Less disk Space is sufficient for creating this type of Zones.
• Quick and Very less time is required to create this type of Zones.
• Contain a complete copy of the Solaris binaries that are installed in the global zone
• Approximately its required 3 GB space for creating this type of zones.
Branded Zone
• Supports different versions of Solaris OS. For example, you can install Solaris 8 or 9 in a
branded
zone.
ZONE States
As shown in below image we can understand the flow of zone states clearly.
ZONE States
Configured Configuration was completed and Committed
Incomplete Transition state during install or uninstall Operations
Installed The packages have been successfully installed
Ready The virtual platform has been established
Running The zone booted successfully and is now running
Shutting The zone is in the process of shutting down - this is a temporary state, leading to
down "Down"
The zone has completed the shut down process and is down - this is a temporary
Down
state, leading to "Installed"
Zoneadmd
zonecfg
# zonecfg -z zone-name: Interactive mode; can be used to remove properties of the following
types: fs, device, rctl, net, attr
# zonecfg -z zone-name commit
# zonecfg -z zone-name create
# zonecfg -z zone-name delete
# zonecfg -z zone-name verify
zoneadm
zlogin
# zlogin zone-name
# zlogin -C zone-name ( Login to zone console)
Zone
Definition
Components
zonepath Path of the zone root which is from global zone's file space.
Autoboot Define whether we need automatically boot the zone
pool Associate the zone with a resource pool; multiple zones may share a pool.
net Network interface of Zone
File systems from the zone's /etc/vfstab, automounted file systems configured
fs within the zone, manually mounted file systems or ZFS mounts from within the
zone
dataset To manage non-global zone with ZFS file system.
In a sparse root zone, represents directories containing packaged software that a
inherit-pkg-
non-global zone shares with the global zone. (Should not be used in a whole
dir
root zone.)
device Devices that should be configured in a non-global zone.
rctl Zone-wide resource controls such as zone.cpu-shares andzone.max-lwps
attr Zone comments
also please note the below "sub commands", this will also important while configuration the
zone.
SUB
COMMANDS
add Add the specified resource or components
Ends the resource specification and returns to the global scope without
cancel
retaining partially specified resources.
commit Save the current configuration to the disk.
create Create new zone configurations
delete Destroy configuration.
end Ends the resource specification
exit Ends the zonecfg session.
info Display information about the configuration of the current scope.
remove Remove the specified resource
revert Return to the last state written to disk.
set Set the specified property to the specified value
verify Verify the current configuration for correctness.
Let we can see how to add the listed zone components with using "zonecfg" command
* In the following example, ZFS Dataset filesystem is added into the non-global zone
bash-3.00# zonecfg -z zone1
zonecfg:zone1> add dataset
zonecfg:zone1:dataset> set name=zonepool/zone1vol
zonecfg:zone1:dataset> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
* In this example, Specify the Memory Limits. Each limit is optional, but at least one must be
set.
zonecfg:zone1> add capped-memory
zonecfg:zone1:capped-memory> set physical=50m
zonecfg:zone1:capped-memory> set swap=100m
zonecfg:zone1:capped-memory> set locked=30m
zonecfg:zone1:capped-memory> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
* In this example, Assigning Dedicated CPU (1-3). we can set the importance as well.
zonecfg:zone1> add dedicated-cpu
zonecfg:zone1:dedicated-cpu> set ncpus=1-3
zonecfg:zone1:dedicated-cpu> set importance=2
zonecfg:zone1:dedicated-cpu> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
*In this example, specifies Capped CPU of 3.5 CPUs for the zone1
zonecfg:zone1> add capped-cpu
zonecfg:zone1:capped-cpu> set ncpus=3.5
zonecfg:zone1:capped-cpu> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit
create local zones:
=====================================================================
=
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.
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
#zlogin my-zone
To start a zone
To stop a zone
To restart a zone
Uninstall a zone
Delete a zone
This command prints in the console the name of the zone where we are logged:
#zonename
=====================================================================
=====
Zone types
Global zone – every installed OS acts like a global zone, which is present by default. All non-
global zones can only be intalled, configured and administered from global zone.
Non-global zone – They share the functioning of the kernel booted under the global zone. All the
software and other resources are inherited from the global zone.
Whole Root zone (Big zone) – It gets their own writable copy of all the file systems like /opt,
/usr. It takes more disk space.
Sparse root zone (Small zone) – File systems like /opt, /usr are shared from global zone as
loopback file-system (you only have a read-only access to these directories in non-global zone).
It takes very less disk space.
Branded zones – These are solaris 8 or solaris 9 zones on the solaris 10 global zones.
Let us create a new zone with a minimal resources and settings required to get it up and running.
We’ll see how to add other resources like cpu, memory, file system etc later in this post.We
would be creating a sparse root zone in this case. To create a whole root zone we just have to use
create -b instead of just create in the configuration prompt.
-C here connects you to the console of the zone. This has to be done only once to get the zone
configured with hostname, timezone and other basic settings.
Resource configuration examples
Below are some most commonly used examples of resource configuration in a zone.
CPU
1. Dedicated CPU
To see the CPU information in the global zone you can use
global# psrinfo -v
global# psrinfo -vp
After you have confirmed the CPUs you want to use, you can add a fixed no of CPUs to the
zone.
Memory
Capped Memory
zonecfg:zone01> add fs
zonecfg:zone01:fs> set dir=/usr/local
zonecfg:zone01:fs> set special=/opt/zones/my-zone/local
zonecfg:zone01:fs> set type=lofs
zonecfg:zone01:fs> end
zonecfg:zone01> add fs
zonecfg:zone01:fs> set dir=/data01
zonecfg:my-zone01:fs> set special=/dev/dsk/c1t1d0s0
zonecfg:my-zone01:fs> set raw=/dev/rdsk/c1t1d0s0
zonecfg:my-zone01:fs> add options [logging, nosuid] (optional)
zonecfg:my-zone01:fs> end
ZFS dataset
When we delegate a dataset to a non-global zone we can do any operation on that dataset inside
of the zone without requiring global zone to configure it all the time.
NOTE: These resources can not be modified once the zone is installed
IP
We can either give an exclusive IP using a dedicated interface to a non-global zone or use an
existing interface in the global zone to share it with the non-global zone. When we configure an
exclusive IP we have to configure IP address inside of the non-global zone and not during the
configuration.
a. Exclusive IP
NOTE: No need to specify IP here you can control everything from inside of the non-global zone
b. Shared IP
In this case zone uses a shared interface which is already plumbed and being used in the global
zone.
Device
We can also directly assign a physical device like disk to a non-global disk.
Comments
In case you want to add some comments like function of the non-global zone or anything else for
that matter.
Other
Other settings like scheduling class of the CPU in the non-global zone can also be configured
from the global zone.