manu's blog


« Previous day (Aug 13, 2008) | Main | Next day (Aug 14, 2008) »
jeudi août 14, 2008

tiny zone to run apache

Even if communities around Solaris Zones and available documentation
are great


I had difficulties to answer this simple question :


How to create a zone a small as possible to run only Apache/MySQL in it ?




I've just needed a web server (and MySQL) to run a site with very limited activity.


All this contained in a zone.
So I needed a zone with a minimum footprint which won't disturb me


on my host which is not a beast.




After trying to aggregate all I've read, I am not pretending
that this is the perfect answer but


here what I've done :
(I used a ZFS pool present on my host)










































































#zfs create tank/tinyzone
#zfs set mountpoint=/tinyzone
#zfs set quota=500M tank/tinyzone
...
#dispadmin -d FSS   (need a reboot/init 6)
...
#zonecfg -z tinyzone
zonecfg:tinyzone> create
zonecfg:tinyzone> set zonepath=/tinyzone
zonecfg:tinyzone> set autoboot=true
zonecfg:tinyzone> set scheduling-class=FSS
zonecfg:tinyzone> set ip-type=shared
(on my host /opt contains lots of packages)

zonecfg:tinyzone> add inherit-pkg-dir

zonecfg:tinyzone:inherit-pkg-dir> set dir=/opt

zonecfg:tinyzone:inherit-pkg-dir> end
zonecfg:tinyzone> add net

zonecfg:tinyzone:net> set address=x.x.x.x

zonecfg:tinyzone:net> set physical=bge0

zonecfg:tinyzone:net> set defrouter=x.x.x.x

zonecfg:tinyzone:net> end
(global zone will receive a lot more shares)

zonecfg:tinyzone> set cpu-shares=1
zonecfg:tinyzone> add capped-memory

zonecfg:tinyzone:capped-memory> set physical=512M

zonecfg:tinyzone:capped-memory> set swap=512M

zonecfg:tinyzone:capped-memory> end
zonecfg:tinyzone> verify
zonecfg:tinyzone> commit
zonecfg:tinyzone> exit
...
#chmod 700 /tinyzone
#zonecfg -z tinyzone info

zonename: tinyzone

zonepath: /tinyzone

brand: native

autoboot: true

bootargs:

pool:

limitpriv:

scheduling-class: FSS

ip-type: shared

[cpu-shares: 1]

inherit-pkg-dir:

        dir: /lib

inherit-pkg-dir:

        dir: /platform

inherit-pkg-dir:
       dir: /sbin

inherit-pkg-dir:

        dir: /usr

inherit-pkg-dir:

        dir: /opt

net:

        address: 1.2.3.4

        physical: bge0

        defrouter: 1.2.3.1

capped-memory:

        physical: 512M

        [swap: 512M]

rctl:

        name: zone.cpu-shares

        value: (priv=privileged,limit=1,action=none)

rctl:

        name: zone.max-swap

        value: (priv=privileged,limit=536870912,action=deny


Once the zone is installed we can see that disk space is quite small









zfs  get available,used tank/tinyzone
NAME            PROPERTY   VALUE           SOURCE
tank/tinyzone  available  381M            -
tank/tinyzone  used       119M            -


Now use a SMF profile to disable all unused service (i.e in my case all but apache and MySQL)















#svccfg extract > /tmp/tinyprofile
... go through the list inside /tmp/tinyprofile to disable everything not needed
#cp /tmp/tinyprofile /tinyzone/root/var/svc/profile/site.xm


Once zone is booted and configured (using sysidcfg)
check Apache and MySQL web site


for performance tuning
et voila :-)









prstat -Z

-----------------------------------------------------------

ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE                       

     0      131  704M  847M    33%   1:42:30  15% global                     

     4       32  126M   85M   3.3%   0:00:18 0.1%
tinyzone


Today's Page Hits: 9