Showing posts with label Solaris 11. Show all posts
Showing posts with label Solaris 11. Show all posts

Friday, August 10, 2012

Clone Solaris 11 Zone

I have come to a point where creating a Solaris 11 zone from scratch is no longer time efficient. This is a note about the method I employed to quickly clone a zone (either new zone or an existing zone).

If you have not created a zone before, here is a summary of the steps.

1) Login as root (or su - to root)

Create a zone ("stem" zone),

2) zonecfg -z originalzone "create; set zonepath=/zones/originalzone;set autoboot=true;exit"

if you already have an existing zone with other applications installed, and you just want to clone it lock, stock and barrel, do this

2.1) zonecfg -z clonedzone01 "create -t originalzone; set zonepath=/zones/clonedzone01;set autoboot=true;exit"

Before installing the zone, make sure you have the IPS repository configured. I use the "sol-11-1111-repo-full.iso", mount it and set the publisher to this repository.

3) pkg set-publisher -G "*" -g file:///media/SOL11REPO_FULL/repo/ solaris
4) pkg rebuild-index

Install the zone

4) zoneadm -z  originalzone install

Boot up the zone and login to the console at the same time

5) zoneadm -z  originalzone  boot; zlogin -C originalzone

If this is a new zone, once the zone booted up, and finished configuring the services, hit F9 to exit.

Run (or re-run if you have just finished configuring the a new zone) "sysconfig create-profile -o /tmp/sc_profile.xml". As you are now in the local zone, make sure you have access to the sc_profile.xml from the global zone and copy it into the global zone before you shutdown the originalzone. /tmp in the local zone maps to /zone/originalzone/root/tmp in the global zone.

Note that if you run the sysconfig utility in a fully configured zone, you will be prohibited from reusing the same user id and the computer name. I just enter a placeholder USERID for user name and COMPNAME for computer name fields. I have also used a bogus IP address during the configuration. Once the sc_profile.xml is generated, just repalce the tokens with valid values before feeding it to the zoneadm to clone the zone.


6) Shutdown the zone: zoneadm -z  originalzone halt

6.5) Replace the placeholders in the sc_profile.xml with meaningful values

# sed -e 's/USERNAME/admin/g' sc_profile.xml > sc_profile.xml.tmp && mv sc_profile.xml.tmp sc_profile.xml
# sed -e 's/COMPNAME/clonedzone/g' sc_profile.xml > sc_profile.xml.tmp && mv sc_profile.xml.tmp sc_profile.xml
# sed -e 's/55\.55\.55\.55/192\.168\.56\.62/g' sc_profile.xml > sc_profile.xml.tmp && mv sc_profile.xml.tmp sc_profile.xml

7) Clone the zone (the content of the zone).

# zoneadm -z clonedzone clone -c ~/sc_profile.xml originalzone

Progress being logged to /var/log/zones/zoneadm.20120811T004223Z.clonedzone.clone
Log saved in non-global zone as /zones/clonedzone/root/var/log/zones/zoneadm.20120811T004223Z. clonedzone.clone

If you want to find out what was done by the zoneadm util, have a look at the log file, you should notice that the tool actually performed a cloning of the originalzone zfs fs.

This also means that the size of the cloned zone starts with zero, as you make changes to the clonedzone, the size of the zfs fs will grow. Check this out

# zfs list | grep [original,cloned]zone$
NAME                                                       USED  AVAIL  REFER  MOUNTPOINT
rpool/zones/originalzone                              393M  93.4G    33K  /zones/originalzone
rpool/zones/clonedzone                               37.0M  93.4G    35K  /zones/clonedzone

Now boot the clonedzone and you will find that you do not need to perform the configuration and all local users, apps you created in the originalzone are still there.

Happy cloning!

Friday, May 11, 2012

iPlanet in a Solaris 11 zone (Express installation)

Update: iPlanet 7.0.15 is now available for download. The file name is 145844-08.zip. The unzip instruction will be slightly different from what described here.

In the previous article I wrote about creating a Solaris 11 zone. This article will explain the steps to install iPlanet Web Server 7.0.14 in the zone.

1) Obtain a copy of iPlanet Web Server from Oracle website, the file name is Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip. Get the update 14 here. Save the downloaded file into a directory that is accessible from the non-global zone. Best way is to place the file into a NFS share that can be accessed from the non-global zone.
2) Login to the local zone as non-root and copy the file into a temp folder.

admin@websvr01:~$ scp admin@192.168.1.2:~/Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip .
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
RSA key fingerprint is cf:b0:3d:35:a5:be:4a:57:0b:4a:5e:64:94:96:66:1e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.2' (RSA) to the list of known hosts.
Password:
Oracle-iPlanet-Web-S 100% |*****************************|   160 MB    00:06   
admin@websvr01:~$



3) Unzip the file. You may need to perform unzip twice because the setup executable is inside a zip file after the first unzip.

admin@websvr01:~$ pwd
/home/admin
admin@websvr01:~$ ls
Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip

admin@websvr01:~$ unzip Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip 
Archive:  Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip
   creating: 145844-07/
 extracting: 145844-07/Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip  
  inflating: 145844-07/README.145844-07  
  inflating: 145844-07/LEGAL_LICENSE.TXT  
  inflating: 145844-07/145844-07.html  
admin@websvr01:~$ 
admin@websvr01:~$ ls
145844-07
Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip
admin@websvr01:~$ cd 145844-07/
admin@websvr01:~/145844-07$ unzip Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip 
admin@websvr01:~/145844-07$ ls -la
total 329601
drwxr-xr-x   4 admin    staff         10 May 11 21:36 .
drwxr-xr-x   4 admin    staff          7 May 11 21:33 ..
-rw-r--r--   1 admin    staff       8640 Feb 19 17:25 145844-07.html
-r--r--r--   1 admin    staff      18775 Sep 18  2010 LEGAL_LICENSE.TXT
drwxr-xr-x   2 admin    staff          3 Feb 14 17:08 Legal
-rwxr-xr-x   1 admin    staff    168513779 Feb 14 22:42 Oracle-iPlanet-Web-Server-7.0.14-solaris-x86.zip
-rw-r--r--   1 admin    staff       6758 Feb 19 17:25 README.145844-07
-rw-r--r--   1 admin    staff        786 Feb 14 17:08 README.txt
drwxr-xr-x   3 admin    staff         15 Feb 14 18:27 WebServer
-rwxr-xr-x   1 admin    staff      34304 Feb 14 17:08 setup
admin@websvr01:~/145844-07$ 


We are going to install the web server with 'admin' user rather than the 'root'. Run the setup and accept all default answers, the only thing you need to specify is the admin server password. The installer will detect if you have an X11 environment to bring up the GUI otherwise it will fall back to the console mode. So don't bother specify any command-line option for the setup command.



admin@websvr01:~/145844-07$ ./setup

Welcome to the Oracle iPlanet Web Server 7.0.14 installation wizard.

Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
Other names may be trademarks of their respective owners.

You will be asked to specify preferences that determine how Oracle iPlanet Web
Server 7.0.14 is installed and configured.

The installation program pauses as questions are presented so you can read the
information and make your choice. When you are ready to continue, press Enter
(Return on some keyboards).

Some questions require that you provide more detailed information. Some
questions also display default values in brackets []. For example, yes is the
default answer to the following question:

   Are you sure? [yes]

To accept the default, press Enter.

To provide a different answer, type the information at the command prompt and
then press Enter.

Hit enter to continue, accept default value for the Installation Directory, which will be /home/{user}/oracle/webserver7. At the Select Type of Installation, press enter to accept Express installation option. Accept the default Administrator user name [admin] and proceed to specify your password for this web server Administrator account. Accept the default [yes] when asked to install the server components. Hit Enter again to start installing.

When the progress indicator hits 100%, your installation is complete.

Installing Oracle iPlanet Web Server
|-1%--------------25%-----------------50%-----------------75%--------------100%|
Installation Successful.

Refer to the installation log file at:
/home/admin/oracle/webserver7/setup/install.log for more details.

Next Steps:

- You can access the Administration Console by accessing the following URL:
https://websvr01:8989
admin@websvr01:~/145844-07$ 


Try accessing https://websvr01:8989 you should see the Web Server Admin Console login screen.


Try logging in using the credential you created during installation; User Name=admin and Password=yourpassword you should see the configuration main screen.


The installation procedure has actually created an instance of a virtual server called 'websvr01' (or your hostname), but would not start it. You need to start it if you want to see how it look for the virtual server.

To start the virtual server, either use command line:

admin@websvr01:~$ cd ~/oracle/webserver7/https-websvr01/bin/
admin@websvr01:~/oracle/webserver7/https-websvr01/bin$ ./startserv 
Oracle iPlanet Web Server 7.0.14 B02/13/2012 21:44
info: CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.6.0_24] from [Sun Microsystems Inc.]
info: HTTP3072: http-listener-1: http://websvr01:8080 ready to accept requests
info: CORE3274: successful server startup
admin@websvr01:~/oracle/webserver7/https-websvr01/bin$ 

Or through the admin console, go to the configuration->instance tab and start the server there.


Browse to the http://websvr01:8080 you should see your new shiny iPlanet landing page.


Well that is it, an iPlanet (formerly Sun Java Web Server) installed in a Solaris 11 zone.

Cheers,

Thursday, May 10, 2012

Bare Minimal Solaris 11 Zone

Creation and administration of local zones on Solaris 11 has become simpler since its public release in Solaris 10. This short article demonstrates the minimal steps required to create your own zone(s) in a global-zone.

1 Create the zone
First what you need is a running Solaris 11 installation, either on VMware, VirtualBox or running on native hardware. I used Oracle VirtualBox in this demonstration.

Log in with the id you created during the Solaris 11 installation. su to root as you may need more than a root role to complete the creation of a zone.

In its simplest form, a zone can be had with the following command:

# zonecfg -z webzone01 "create;set zonepath=/zones/webzone01;exit"

1.1 sub-commands explained

create: This creates a Solaris 11 zone called 'webzone01'

set zonepath=/zones/webzone01: This specifies the storage of the zone in a ZFS pool visible to the global zone.

exit: Exits the zonecfg configuration mode (and finishes up).

There are other configurations involved during zone creation. See man zonecfg (1M).

1.2 List the newly created zone

# zoneadm list -cv


  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              solaris  shared
   - webzone01        configured /zones/webzone01               solaris  excl 
See man zoneadm (1M) for more infomation.

1.2 The resultant 'webzone01' zone
Use the following command to inpect the configuration of the newly created zone.

# zonecfg -z webzone01 info

zonename: webzone01
zonepath: /zones/webzone01
brand: solaris
autoboot: false
bootargs:
file-mac-profile:
pool:
limitpriv:
scheduling-class:
ip-type: exclusive
hostid:
fs-allowed:
anet:
 linkname: net0
 lower-link: auto
 allowed-address not specified
 configure-allowed-address: true
 defrouter not specified
 allowed-dhcp-cids not specified
 link-protection: mac-nospoof
 mac-address: random
 mac-prefix not specified
 mac-slot not specified
 vlan-id not specified
 priority not specified
 rxrings not specified
 txrings not specified
 mtu not specified
 maxbw not specified
 rxfanout not specified

The highlighted fields are those we specified during creation, the rest are default values. The 'anet' and 'ip-type' resource types deserve another article of explanation. I will write about it later.

Now you should have a zone in the 'configured' state. In summary, the typical state transition for a zone from its creation to its deletion can be depicted as follow. See man zoneadm (1M) for more information.

configured --> installed --> running
     |             |
incomplete        down
     |             |
configured        installed

2 Install the zone
Before install a zone, make sure that you have the IPS repository is configured. The zoneadm requires package from the IPS for zone installation. See this article for setting up a local IPS repository. Alternatively, you can mount the ISO image sol-11-1111-repo-full.iso directly and set-up the publisher to point directly to the file location.

# zoneadm -z webzone01 install

A ZFS file system has been created for this zone.
Progress being logged to /var/log/zones/zoneadm.20120509T131933Z.webzone01.install
       Image: Preparing at /zones/webzone01/root.

 Install Log: /system/volatile/install.3582/install_log
 AI Manifest: /tmp/manifest.xml.LCaG.g
  SC Profile: /usr/share/auto_install/sc_profiles/enable_sci.xml
    Zonename: webzone01
Installation: Starting ...

              Creating IPS image
              Installing packages from:
                  solaris
                      origin:  http://localhost:1008/solaris/5253829a2447d746e843a409669e9ab0ad8bf9f0/
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                              167/167 32062/32062  175.8/175.8

PHASE                                        ACTIONS
Install Phase                            44313/44313 

PHASE                                          ITEMS
Package State Update Phase                   167/167 
Image State Update Phase                         2/2 
Installation: Succeeded

        Note: Man pages can be obtained by installing pkg:/system/manual

 done.

        Done: Installation completed in 229.231 seconds.


  Next Steps: Boot the zone, then log into the zone console (zlogin -C)

              to complete the configuration process.

Log saved in non-global zone as /zones/webzone01/root/var/log/zones/zoneadm.20120509T131933Z.webzone01.install

Read the stdout carefully to ensure no error has occurred. Proceed with booting up the zone and complete the configuration as instructed.

3 Booting up
This step is accomplished with the following command

# zoneadm -z webzone01 boot

The boot process should be quick. I have not researched how a booting process can fail, if you don't see anything in stderr then your booting process has probably gone well.

A non-persistent vnic (most likely to be named after the name and interface name of your zone; example: webzone01/net0) will be created for you when the system booted so you don't need to worry about that for now. The vnic will be delete after the zone shuts down. We will explore the relationship between vnic's and zone in another article.

4 Configure the zone
Login to the zone by using this command

# zlogin -C webzone01
[Connected to zone 'webzone01' console]

You will be presented with the configuration screen as you would the global zone. Follow the steps and complete the configuration. It is a normal production practice to assign an IP address to the zone so it resides in the same subnet as the global zone. This reduces the network administration chore.



Configure the network manually. A static IP address for a web server is good for you. Don't worry about the /29 subnet, use anything you like.



No DNS for now, will be covered in another article when we hook this machine up to a Windows 2008 R2 DNS server.



Hit F2 to apply the configuration!

Upon completing the steps above, you will be presented with a login screen.

Exiting System Configuration Tool. Log is available at:

/var/tmp/install/sysconfig.log

Hostname: websvr01

May 10 00:03:27 websvr01 sendmail[7721]: My unqualified host name (websvr01) unknown; sleeping for retry
May 10 00:03:27 websvr01 sendmail[7724]: My unqualified host name (websvr01) unknown; sleeping for retry

Login using the id you supplied in one of the configuration step, perform a 'uname -a' you should see this

websvr01 console login: admin
Password:
Oracle Corporation      SunOS 5.11      11.0    November 2011
admin@websvr01:~$ uname -a
SunOS websvr01 5.11 11.0 i86pc i386 i86pc
admin@websvr01:~$

Try the ipadm and dladm command and you shall see the plumbing all done for you.

Alright, that's all for now, in the next article we will install iPlanet web server into this brand new zone.

Cheers,

Tuesday, October 11, 2011

Setting up a Solaris 11 Express Local Package Repository

As part of the exercise to upgrade my entire infrastructure from ESXi 4 to ESX 5, and adding a few Solaris Global Zones into the mix, I started with setting up a Solaris 11-based utility server. The shared, utility server is envisioned to provide the following services to other nodes in the infrastructure without introducing too many individual servers in the lab environment:

1) Local network IPS repository server for other clients
2) ZFS-based iSCSI target for other Solaris zones
3) ZFS-based NFS for shared storage in Solaris zones
4) LDAP services
5) DNS services
6) and more...

This article will address the topic of setting up a shared repository.

Pre-requisite:
- Solaris 11 Express VM. Download text installer here. I choose VMware workstation, you can obtain the entire VirtualBox image of Solaris 11 Express from Oracle website.
- Solaris 11 Express  full repository CD (sol-11-exp-201011-repo-full.iso). Download from Oracle website.

Concept
A repository is a location where clients publish and retrieve IPS packages. Clients that publish IPS packages are called publisher. A repository contains packages published by a single publisher. A repository is described by a Universal Resource Identifier (URI) such as http URL or a file location. The publisher name of all packages in the Solaris 11 Express full repository CD is 'solaris'. If you create software and publish the packages, you give yourself a publisher name, such as 'mycompany'.

A repository can be either an 'origin' or a 'mirror'.

An IPS package is a collection of software artefacts in a defined format. A package is represented by a Fault Management Resource Identifier (FMRI).

For detailed description of IPS concept, refer to Oracle documentation.

Setting up the IPS repository
In summary, the following components are required in order to setup a network based IPS repository.

- IPS Contents. We will copy all the packages from the Oracle repository CD into a local file system. You can simply create a local directory under the default ZFS pool (rpool) of your Solaris 11 Express installation. Alternatively, you can create a new ZFS pool to host the files.

In this exercise, I used the existing root file system rpool and make a directory under the root mountpoint.

root@sol11util:/rpool# cd /
root@sol11util:/# mkdir -p ips/repo
root@sol11util:/#

Copy all contents under the repo folder in the CD into the /ips/repo

root@sol11util:/# rsync -aP source dest

This is going to take a while as every files under the repo is copied.

After completion, check that the directory is there. You should see under the ips/repo the following files

root@sol11util:/ips/repo# ls -la
total 7
drwxr-xr-x 3 root root   4 2010-11-11 08:40 .
drwxr-xr-x 3 root root   3 2011-10-23 08:33 ..
-rw-r--r-- 1 root root 250 2010-11-11 08:40 pkg5.repository
drwxr-xr-x 3 root root   3 2010-11-11 08:39 publisher

- IPS server. We have the content in /ips/repo now. We need to setup a server to serve the contents of this folder to the clients on the LAN. Solaris 11 Express allows you to manage services with simple commands.

svcs - This command is used to list currently running services managed by the smf (Service Management Facility). To find out if an instance of pkg package server already running, issue the following command

root@sol11util:/tank/repo# svcs \*pkg\*
STATE          STIME    FMRI
disabled        6:48:32 svc:/application/pkg/server:default
disabled        6:48:32 svc:/application/pkg/dynamic-mirror:default
online          6:48:43 svc:/system/pkgserv:default
root@sol11util:/tank/repo#

The /application/pkg/server is not enabled by default in a fresh Solaris 11 installation. This is the service that will serve the client and provide access to the packages published by a publisher.

Let's examine this service by another command called 'svccfg'. The following command line lists all the properties of the application/pkg/server service to the console.

root@sol11util:/tank/repo# svccfg -v -s application/pkg/server listprop

pkg                                                        application
pkg/cfg_file                                               astring 
pkg/content_root                                           astring  usr/share/lib/pkg
pkg/debug                                                  astring 
pkg/file_root                                              astring 
pkg/inst_root                                              astring  /var/pkg/repo
pkg/log_access                                             astring  none
pkg/log_errors                                             astring  stderr
pkg/mirror                                                 boolean  false
pkg/pkg_root                                               astring  /
pkg/port                                                   count    80
pkg/proxy_base                                             astring 
pkg/readonly                                               boolean  true
pkg/socket_timeout                                         count    60
pkg/sort_file_max_size                                     astring 
pkg/ssl_cert_file                                          astring 
pkg/ssl_dialog                                             astring  smf
pkg/ssl_key_file                                           astring 
pkg/threads                                                count    60
pkg/writable_root                                          astring 
pkg_bui                                                    application
pkg_bui/feed_description                                   ustring 
pkg_bui/feed_icon                                          ustring  web/_themes/pkg-block-icon.png
pkg_bui/feed_logo                                          ustring  web/_themes/pkg-block-logo.png
pkg_bui/feed_name                                          ustring  "package repository feed"
pkg_bui/feed_window                                        count    24
pkg_secure                                                 application
pkg_secure/read_authorization                              astring  solaris.smf.read.pkg-server
pkg_secure/ssl_key_passphrase                              astring 
fs                                                         dependency
fs/entities                                                fmri     svc:/system/filesystem/local
fs/grouping                                                astring  require_all
fs/restart_on                                              astring  none
fs/type                                                    astring  service
autofs                                                     dependency
autofs/entities                                            fmri     svc:/system/filesystem/autofs
autofs/grouping                                            astring  optional_all
autofs/restart_on                                          astring  none
autofs/type                                                astring  service
ntp                                                        dependency
ntp/entities                                               fmri     svc:/network/ntp
ntp/grouping                                               astring  optional_all
ntp/restart_on                                             astring  none
ntp/type                                                   astring  service
network                                                    dependency
network/entities                                           fmri     svc:/milestone/network
network/grouping                                           astring  require_all
network/restart_on                                         astring  none
network/type                                               astring  service
manifestfiles                                              framework
manifestfiles/var_svc_manifest_application_pkg-server_xml  astring  /var/svc/manifest/application/pkg-server.xml
startd                                                     framework
startd/duration                                            astring  child
general                                                    framework
general/entity_stability                                   astring  Unstable
start                                                      method
start/exec                                                 astring  "%{pkg/pkg_root}/lib/svc/method/svc-pkg-depot %m"
start/timeout_seconds                                      count    0
start/type                                                 astring  method
stop                                                       method
stop/exec                                                  astring  "%{pkg/pkg_root}/lib/svc/method/svc-pkg-depot %m %{restarter/contract}"
stop/timeout_seconds                                       count    30
stop/type                                                  astring  method
tm_common_name                                             template
tm_common_name/C                                           ustring  "image packaging repository"
As you can see, this is a huge list of service properties. Fortunately, we are only interested in 2 properties, namely the pkg/inst_root and pkg/port. The default values of these properties are /var/pkg/repo and 80 respectively.

We will update the pkg/inst_root to point to /ips/repo (the local copy of the repo folder in the Solaris package CD), and the port number to an unused port 9999.

root@sol11util:/tank/repo# svccfg -v -s application/pkg/server setprop pkg/inst_root=/ips/repo

root@sol11util:/tank/repo# svccfg -v -s application/pkg/server setprop pkg/port=9999

Make sure the props are set.

root@sol11util:~# svccfg -s /application/pkg/server listprop | grep '\(port\)\|\(inst_root\)'

pkg/inst_root                                              astring  /ips/repo/
pkg/port                                                   count    9999

So far so good. We need to start the service.

root@sol11util:~# svcadm enable /application/pkg/server
root@sol11util:~# svcs /application/pkg/server
STATE          STIME    FMRI
online         16:24:28 svc:/application/pkg/server:default

The service is up, good. By now we should be able to use web browser to explore the repository from the network.


To start using this repository, we will need to set the client up to point to this repository. For now, we will set up the host to use the repository it is hosting.

Before doing that, let's see what repository is currently available to the host.

root@sol11util:/usr# pkg publisher

PUBLISHER                             TYPE     STATUS   URI

solaris                  (preferred)  origin   online   http://pkg.oracle.com/solaris/release/

Ok, we currently have an internet based Oracle repository. We are going to replace that with our local (LAN based) one.

root@sol11util:/usr# pkg set-publisher -g http://192.168.12.135:9999 -G http://pkg.oracle.com/solaris/release/ solaris

results in

root@sol11util:/usr# pkg publisher
PUBLISHER                             TYPE     STATUS   URI
solaris                  (preferred)  origin   online   http://192.168.12.135:9999/
root@sol11util:/usr# 


Rebuild the repository index

root@sol11util:~# pkg rebuild-index

Try installing firefox from this default (preferred) repository.

root@sol11util:/usr# pkg install firefox Packages to install: 15 Create boot environment: No Services to restart: 3 DOWNLOAD PKGS FILES XFER (MB) Completed 15/15 5628/5628 34.2/34.2 PHASE ACTIONS Install Phase 6514/6514 PHASE ITEMS Package State Update Phase 15/15 Image State Update Phase 2/2

That is it.

Cheers