Configure a zone in Solaris under ZFS support

In vir­tua­li­za­tion fie­ld, the­re are a lot of pro­du­cts or tech­no­lo­gies that can ena­ble multi­ple logi­cal servers run­ning on a real machi­ne, like LPAR, vCen­ter, hyper-V. For Sola­ris SPARC, we can use zone within ZFS to crea­te some vir­tual system. With Zone ena­bled, we can sha­re CPU and memo­ry resou­r­ce between seve­ral logi­cal Sola­ris ope­ra­tion system. With ZFS suppo­r­ted, we can easi­ly make a sna­pshot, revert them into some older sta­te and ensu­re data safe­ty by ena­bling RAID 0 or RAID-Z. Using zone and ZFS in Sola­ris SPARC may let us use them more effe­ctive.

Here is some expe­rien­ce about how to con­fi­gu­re a zone with ZFS suppo­r­ted for sha­ring.

User­ful comman­ds:

See what net-infer­fa­ce you will use for the zone:
# ifcon­fig –a

Che­ck machi­ne memo­ry:
# prtconf |grep Memo­ry
Memo­ry size: XXXXX Mega­bytes

List all zones in the system:
# zonea­dm list -cv
ID NAME             STATUS     PATH                           BRAND    IP
0 glo­bal           run­ning    /                              native   sha­red
1 zone1          run­ning    /zones/zone1                 native   sha­red
— zone2             insta­lled  /zones/zone2                    native   sha­red
— zone3            con­fi­gu­red /zones/zone3                   native   sha­red

Atta­ch a zone from exi­sted file­system:
# zonea­dm -z zone1 atta­ch

ZFS pool pre­pa­ra­tion:

# zfs crea­te rpool/zones
# zfs set mountpoint=/zones rpool/zones

Crea­te a zone (named zone1):

# zfs crea­te rpool/zones/zone1
# chmod 700 /zones/zone1
# zone­cfg -z zone1
zone1: No such zone con­fi­gu­red
Use ‘crea­te’ to begin con­fi­gu­ring a new zone.
zonecfg:zone1> crea­te
zonecfg:zone1> set zonepath=/zones/zone1
zonecfg:zone1> set autoboot=true
zonecfg:zone1> add net
zonecfg:zone1:net> set address=1.2.3.4
zonecfg:zone1:net> set physical=e1000g0
zonecfg:zone1:net> end
zonecfg:zone1> veri­fy
zonecfg:zone1> commit
zonecfg:zone1> exit
# zonea­dm -z zone1 insta­ll -x noda­ta­set
Pre­pa­ring to insta­ll zone <zone1>.
Crea­ting list of files to copy from the glo­bal zone.
Copying <11537> files to the zone.
Ini­tia­li­zing zone pro­du­ct regi­stry.
Deter­mi­ning zone packa­ge ini­tia­li­za­tion order.
Pre­pa­ring to ini­tia­li­ze <1896> packa­ges on the zone.
Ini­tia­li­zed <1896> packa­ges on zone.
Zone <zone1> is ini­tia­li­zed.
The file </zones/zone1/root/var/sadm/system/logs/install_log> con­tains a log of the zone insta­lla­tion.
# zonea­dm -z zone1 rea­dy
# zonea­dm -z zone1 boot
# zlo­gin -C zone1
[Con­ne­cted to zone ‘zone1’ con­so­le]

Then we can login to zone1 and make a con­fi­gu­ra­tion for the new system. After well con­fi­gu­ring, we may powe­ro­ff that zone and make a sna­pshot for the zone:

# zfs sna­pshot rpool/zones/zone1@initial

Dest­roy a zone:

# zonea­dm -z zone1 halt
# zonea­dm -z zone1 unin­sta­ll
# zone­cfg -z zone1 dele­te -F
# zfs dest­roy -r rpool/zones/zone1

You may also like...

Leave a Reply

Your email address will not be published.

sixteen − ten =

使用新浪微博登陆