- Let's use ZFS for storage of zones to help better disk management
zpool create -f zones c0d1
zfs create zones/apache
mount
/zones on zones read/write/setuid/devices/exec/atime/dev.......
/zones/apache on zones/apache read/write/setuid/devices/exec/atime/dev.......
- Change the mode of directory because of need of zone management software
bash-3.00# chmod 700 /zones/apache
- Create zone, named apache
bash-3.00# zonecfg -z apache
apache: No such zone configured
Use 'create' to begin configuring a new zone.
- * we start with initial creation of zone
zonecfg:apache> create
- * set the path where zone will reside
zonecfg:apache> set zonepath=/zones/apache
- * set autoboot flag to boot when server boot
zonecfg:apache> set autoboot=true
- * add network IP and physical interface. Do not forget to set netmask
zonecfg:apache> add net
zonecfg:apache:net> set address=192.168.30.100/24
zonecfg:apache:net> set physical=pcn0
zonecfg:apache:net> end
- * add external directory /opt to be part of zone (just in case)
zonecfg:apache> add inherit-pkg-dir
zonecfg:apache:inherit-pkg-dir> set dir=/opt
zonecfg:apache:inherit-pkg-dir> end
- * get the config info about the zone (on screen)
zonecfg:apache> info
zonepath: /zones/apache
autoboot: true
pool:
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: 192.168.30.100/24
physical: pcn0
- * commit all the changes we made
zonecfg:apache> commit
- * export the config for future usage or just for backup. Do not put it in /tmp, because on each boot this filesystem is purged
zonecfg:apache> export -f /zones/apache-zone.cfg
- * and exit from the program
zonecfg:apache> exit
- Now let's install the software in zone (this operation will take a while)
bash-3.00# zoneadm -z apache install
Preparing to install zone <apache>.
Creating list of files to copy from the global zone.
Copying <2361> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <968> packages on the zone.
Initializing package <372> of <968>: percent complete: 38%......
- Little check of situation
- * diskspace
bash-3.00# df -k /zones/apache/
Filesystem kbytes used avail capacity Mounted on
zones/apache 12321792 70034 12251635 1% /zones/apache
bash-3.00# zoneadm list -v
ID NAME STATUS PATH
0 global running /
bash-3.00# zoneadm -z apache boot
- * and check again zones status
bash-3.00# zoneadm list -v
ID NAME STATUS PATH
0 global running /
2 apache running /zones/apache
- Some preparation tasks
- * login in to the zone
bash-3.00# zlogin apache
[Connected to zone 'apache' pts/2]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
- * create some directories where we will place web server
(we aware directories /lib, /opt, /platform, /sbin and /usr are mounted
from global zone as readonly, but / (root) not so we put there our
apache)
# mkdir -p /www/src
- * copy the software (from other terminal :-)
bash-3.00# cd /zones/apache/root/www/src/
bash-3.00# cp /tmp/httpd-2.2.4.tar.gz .
- * decompress and untar the archive (from with in zone)
# cd /www/src
# gzip -d httpd-2.2.4.tar.gz|tar
# tar xvf httpd-2.2.4.tar
- * configure and compile the software (its take a while)
# cd httpd-2.2.4
# ./configure --prefix=/www --enable-so –enable-mods-shared=all
<cut long listing>
# make
<cut long listing>
# make test
`test' is up to date.
# make install
<cut long listing>
- * create user to manage files
# groupadd w3
# useradd -g w3 w3
# chown -R w3:w3 /www/htdocs
- * edit /www/conf/httpd.conf to change User and Group from daemon to w3
- * edit /etc/hosts to add line like this
192.168.30.100 apache.example.net apache
- let's run the http server
# /www/bin/apachectl start
- check if the server is running
- * check process
# ps -efl|grep htt
0 S w3 22380 22377 0 40 20 d39c2008 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22381 22377 0 40 20 d4e80940 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22378 22377 0 40 20 d4e73270 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S w3 22379 22377 0 40 20 d4e70890 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
0 S root 22377 5541 0 40 20 d4e70030 1103 d49abb16 01:24:40 ? 0:00 /www/bin/httpd -k start
0 S root 22384 15053 1 50 20 d5182a18 253 d6880300 01:25:21 pts/2 0:00 grep htt
0 S w3 22382 22377 0 40 20 d5181958 1136 d54cfd5c 01:24:41 ? 0:00 /www/bin/httpd -k start
# telnet 192.168.30.100 80
Trying 192.168.30.100...
Connected to 192.168.30.100.
Escape character is '^]'.
GET
<html><body> It works!</body></html>Connection to 192.168.30.100 closed by foreign host.
- So our apache is running and working :-)
- for next example let's create another zone, named apache2,
but this time we will use apache server from Solaris and config file
from previous zone
# cp /zones/apache-zone.cfg /zones/apache2-zone.cfg
- edit file and change zonepath and IP address
- next will use this config file to initialize new zone
# zonecfg -z apache2 -f /zones/apache2-zone.cfg
# zoneadm -z apache2 install
# zoneadm -z apache2 boot
- add own users w3 with group w3 and create and edit config
file. Do not forget to change IP address apache will listen and
/etc/hosts for FQDN of host
# cp /etc/apache2/httpd.conf-example /etc/apache2/httpd.conf
# groupadd w3
# useradd -g w3 w3
- create directory /var/run/apache2, because it do not exist,
but it's need to keep apache pid file or make some changes in apache
config file
mkdir -p /var/run/apache2
- start server and test if it's work
# /usr/apache2/bin/apachectl start
# ps -efl|grep http
0 S root 4520 4062 0 50 20 dbbabae0 253 d6860820 09:44:33 pts/2 0:00 grep http
0 S w3 4516 4513 0 40 20 dbbaaa20 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S root 4513 3924 0 40 20 dbba9100 1421 d5ebbd16 09:44:22 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4517 4513 0 40 20 e8df5ae8 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4518 4513 0 40 20 e8df5288 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4514 4513 0 40 20 e8df4a28 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
0 S w3 4515 4513 0 40 20 e8df41c8 1456 d5465384 09:44:23 ? 0:00 /usr/apache2/bin/httpd -k start
# telnet 192.168.30.101 80
Trying 192.168.30.101...
Connected to 192.168.30.101.
Escape character is '^]'.
get
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
Method Not Implemented
get to /index.html.en not supported.
<address>Apache/2.0.55 (Unix) DAV/2 Server at 192.168.30.101 Port 80</address>
</body></html>
Connection to 192.168.30.101 closed by foreign host.
- and now we have 2 zones and 2 different web servers
More information on Solaris at ITtoolbox
Related Content | White Papers and Webcasts
Jobs
Community Content
|
Browse IT Wiki
Disclaimer: Toolbox for IT Wiki is a service that allows content to be
created and edited by anyone in the community. Content posted to this
site is not reviewed for correctness and is not supported by Toolbox
for IT or any of its partners. If you feel a wiki article is
inappropriate, you can either correct it by clicking "Edit" above or
click here to notify Toolbox for IT. |