All proceeds from Ad Clicks goes to the author of this site.

 

Monday, November 20, 2006

Equalzing Full Zones & Shared Zones

If you have the need for a full zones one where nothing is inherited from the global filesystem so you are free to change/patch any of the core files in the zone besides the kernel that is not part of the zone and is shared with all zones. A typical zone with inherited filesystems uses about 100MB of disk space; you can reduce it to 50MB using a compressed ZFS filesystem. The full zone on the other hand uses a lot more disk space, in my example it uses 3.43 GB each, even compressed. but if you use the power and features of ZFS you can reduce even full zones to just a few hundred kilobytes, Your mileage may vary since I have more than a base configuration on the box I used to test. So lets look at what happened when cloned using the power of ZFS.

Setup the ZFS filesystem

zfs create data/zone_test
zfs set compression=on data/zone_test


Create a Full Zone

zonecfg:fz_1> export
create -b
set zonepath=/data/zone_test/fz_1
set autoboot=false
add net
set address=192.168.1.110
set physical=hme0
end
zonecfg:fz_1>

Install the Zone

enterprise:data# time zoneadm -z fz_1 install
A ZFS file system has been created for this zone.
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <154355> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1261> packages on the zone.
Initialized <1261> packages on zone.
Zone is initialized.
Installation of these packages generated errors:
The file contains a log of the zone installation.

real 48m39.784s
user 11m14.189s
sys 23m0.554s
enterprise:data#

Wow it takes a while to create a full zone.

now let’s get ready to clone the zone.
Configure our second zone using the configuration from the first zone

enterprise:data# zonecfg -z fz_1 export|sed -e 's/fz_1/fz_3/'|zonecfg -z fz_3
fz_3: No such zone configured
Use 'create' to begin configuring a new zone.
enterprise:data#

Clone the first filesystem and create a second.

time zoneadm -z fz_2 clone fz_1
WARNING: network address '192.168.1.110' is configured in both zones.
Cloning snapshot data/zone_test/fz_1@SUNWzone1
Instead of copying, a ZFS clone has been created for this zone.

real 0m9.954s
user 0m0.314s
sys 0m0.934s

9.9 seconds a much faster way to make zones.

Let’s compare with a standard zone.

enterprise:data# time zoneadm -z pz_1 install
A ZFS file system has been created for this zone.
Preparing to install zone .
Creating list of files to copy from the global zone.
Copying <15748> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1261> packages on the zone.
Initialized <1261> packages on zone.
Zone is initialized.
Installation of these packages generated warnings:
The file contains a log of the zone installation.

real 27m51.243s
user 7m58.771s
sys 14m58.229s
enterprise:data#

enterprise:data# time zoneadm -z pz_3 clone pz_1
WARNING: network address '192.168.1.192' is configured in both zones.
Cloning snapshot data/zone_test/pz_1@SUNWzone1
Instead of copying, a ZFS clone has been created for this zone.

real 0m14.031s
user 0m2.060s
sys 0m1.039s
enterprise:data# zfs list data/zone_test_pz_3
cannot open 'data/zone_test_pz_3': no such filesystem

Diskspace used


enterprise:data# zfs list -r data/zone_test/
cannot open 'data/zone_test/': invalid filesystem name
enterprise:data# zfs list -r data/zone_test
NAME USED AVAIL REFER MOUNTPOINT
data/zone_test 3.72G 815M 57K /data/zone_test
data/zone_test/fz_1 3.44G 815M 3.43G /data/zone_test/fz_1
data/zone_test/fz_1@SUNWzone1 18.4M - 3.43G -
data/zone_test/fz_2 143K 815M 3.43G /data/zone_test/fz_2
data/zone_test/pz_1 283M 815M 283M /data/zone_test/pz_1
data/zone_test/pz_1@SUNWzone1 145K - 283M -
data/zone_test/pz_3 130K 815M 283M /data/zone_test/pz_3
enterprise:data#

[fz == full zone] [pz=shared zone]

Thanks to ZFS, compression and cloning, you can see that the use of disk per zone is less than 150K, 143K for the full zone, and 130K for the shared zone. Of course changing files in the core install will increase the amount of disk space used on full zones, but you can’t have everything. ZFS also equalizes the time to create the zones, reduces it from 45 minutes to less than 10 seconds even for full zones.

6 Comments:

Anonymous Anonymous said...

How is it - can Solaris still share the zones' executables and libraries in ram in such a setup?

Having shared zones isn't just to save hard disk (in fact, there's plenty of it), but also a neat way to avoid having 200 copies of libc, init, sh, apache, postgres, ... in memory.

with zfs clones, I'm not sure if solaris still manages to figure out that it's the same file and the read-only sections can be shared.

12:41 AM  
Anonymous Anonymous said...

Based on previous comments you've made, you seem to think making an potentially irresponsible recommendation without full disclaimers is worthy of job loss. So, I say:

You should be fired!

From docs.sun.com:

Solaris 10 6/06: Do Not Place the Root File System of a Non-Global Zone on ZFS

The zonepath of a non-global zone should not reside on ZFS for this release. This action might result in patching problems and possibly prevent the system from being upgraded to a later Solaris 10 update release.

8:07 AM  
Blogger jamesd_wi said...

"How is it - can Solaris still share the zones' executables and libraries in ram in such a setup?"

I didn't look at ram utilization, I'm not sure if Solaris is smart enough to cache the files, because all the zones start out sharing the same blocks on the disk, but not sure that Solaris is smart enough to cache between file systems.

8:07 AM  
Anonymous David Comay said...

James, interesting post. Just a clarification that the proper name for such zones is "whole-root zones".

In answer to one of the anonymous comments - Solaris will not share the text segments of the executables and the libraries if the zone has its own copies of these components. That's true whether or not ZFS is involved. Only so-called "sparse-root zones" benefit from the VM sharing of text segments in this way.

3:04 PM  
Anonymous Anonymous said...

Thanks for the interesting post. ZFS and zones is definitely a very powerful combination. One comment I had about your (apparent) zone configuration is that you are using IP addresses in the net/address resources. If you use a hostname there instead of an IP, then you won't hit the duplicate address errors during your search/replace when initially cloning a new zone.
-Bill Hathaway

7:40 AM  
Blogger ATField said...

runescape money
runescape gold
runescape money
runescape gold
buy runescape gold buy runescape money runescape items
runescape accounts
runescape gp
runescape money
runescape power leveling
runescape money
runescape gold
dofus kamas
cheap runescape money
cheap runescape gold
Guild Wars Gold
buy Guild Wars Gold
lotro gold
buy lotro gold
lotro gold
buy lotro gold
lotro gold
buy lotro gold

Hellgate Palladium
Hellgate London Palladium
Hellgate money
Tabula Rasa gold tabula rasa money
Tabula Rasa Credit
Tabula Rasa Credits
Hellgate gold
Hellgate London gold
wow power leveling
wow powerleveling
Warcraft PowerLeveling
Warcraft Power Leveling
World of Warcraft PowerLeveling World of Warcraft Power Leveling runescape power leveling
runescape powerleveling
eve isk
eve online isk
eve isk
eve online isk
tibia gold
Fiesta Silver
Fiesta Gold
Age of Conan Gold
buy Age of Conan Gold
aoc gold

呼吸机
无创呼吸机
家用呼吸机
呼吸机
家用呼吸机
美国呼吸机
篮球培训
篮球培训班
篮球夏令营
china tour
beijing tour
beijing travel
china tour
tibet tour
tibet travel
computer monitoring software
employee monitoring

9:29 PM  

Post a Comment

<< Home