Pages

Wednesday, February 23, 2011

How to create zone

Zone allow virtual environment to run in the same host server. You can limit amount of physical resource that a zone can use. There are 2 types of zone, global zone and non-global zone. Global zone is the host server it self. Non global zone is the zone that we want to create. You can have maximum 8192 non global zone in a single host server. Below is tips to create a zone.


  1. Set the zonepath for your zone. In this example zonepath is /export/home/zone1 from the global zone.
    root@solaris-sunray # mkdir -p /export/home/zone1
root@solaris-sunray # chmod 700 /export/home/zone1
  1. Configure the zone. Below example shows that your zone use IP address 172.16.31.150, use 20% of CPU resource, and label “zone number 1”.
    root@solaris-sunray # zonecfg -z zone1
zone1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:zone1> create
zonecfg:zone1> set zonepath=/export/home/zone1
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add net
zonecfg:zone1:net> set physical=e1000g0
zonecfg:zone1:net> set address=172.16.31.150
zonecfg:zone1:net> end
zonecfg:zone1> add rctl
zonecfg:zone1:rctl> set name=zone.cpu-shares
zonecfg:zone1:rctl> add value (priv=privileged,limit=20,action=none)
zonecfg:zone1:rctl> end
zonecfg:zone1> add attr
zonecfg:zone1:attr> set name=comment
zonecfg:zone1:attr> set type=string
zonecfg:zone1:attr> set value="zone number 1"
zonecfg:zone1:attr> end
  1. After you configure the zone, do verify and commit.
    zonecfg:zone1> verify
zonecfg:zone1> exit
  1. Check the zone status (zone is configured properly or not)
root@solaris-sunray # zoneadm -z zone1 list -v
ID NAME STATUS PATH BRAND IP
- zone1 configured /export/home/zone1 native shared
root@solaris-sunray # zoneadm -z zone1 verify
  1. Install the zone
    root@solaris-sunray # zoneadm -z zone1 install
Preparing to install zone <zone1>.
Creating list of files to copy from the global zone.
Copying <7079> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1077> packages on the zone.
...
Initialized <1077> packages on zone.
Zone <zone1> is initialized.
Installation of <1> packages was skipped.
Installation of these packages generated warnings: <STATsrv>
The file </export/home/zone1/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
  1. Change the zone state to ready and verify
    root@solaris-sunray # zoneadm -z zone1 ready
zoneadm: zone 'zone1': WARNING: The zone.cpu-shares rctl is set but
zoneadm: zone 'zone1': FSS is not the default scheduling class for
zoneadm: zone 'zone1': this zone. FSS will be used for processes
zoneadm: zone 'zone1': in the zone but to get the full benefit of FSS,
zoneadm: zone 'zone1': it should be the default scheduling class.
zoneadm: zone 'zone1': See dispadmin(1M) for more details.
root@solaris-sunray # zoneadm -z zone1 verify
root@solaris-sunray # zoneadm -z zone1 list -v
ID NAME STATUS PATH BRAND IP
1 zone1 ready /export/home/zone1 native shared
  1. Boot the zone and verify
    root@solaris-sunray # zoneadm -z zone1 boot
root@solaris-sunray # zoneadm -z zone1 bootlist -v
ID NAME STATUS PATH BRAND IP
1 zone1 running /export/home/zone1 native shared
  1. Log in to the zone console and set initial configuration like: host name, root password, timezone, name service, security policy, terminal type
    root@solaris-sunray # zlogin -C zone1
[Connected to zone 'zone1' console]
...
  1. Log in to the zone
    root@solaris-sunray # zlogin zone1
[Connected to zone 'zone1' pts/4]
Last login: Fri Oct 15 11:22:13 on pts/4
Sun Microsystems Inc.SunOS 5.10GenericJanuary 2005
# exit
[Connection to zone 'zone1' pts/4 closed]

No comments:

Post a Comment