Friday, September 18, 2015

Solaris 11 local repository

On Solaris 11

Solaris is indicated where longevity, reliability, and security is of utmost importance.

I recently migrated a Solaris system to newer hardware - a system commissioned 21 years ago, and which has been migrated to newer hardware at least twice before. The system has been quietly labelling, shipping, and invoicing $1m and $2m of goods per day, seven days per week, on a single server. It's impossible to imagine this longevity and reliability on any other environment outside of a mainframe.

Solaris has always been well ahead of Linux in filesystem and virtualisation technology. While Linux has been getting increasingly complex with each release, Solaris has been getting easier. Solaris documentation is delight compared to Linux.

Solaris is also cheap to run. Grey bearded Solaris administrators like me are still astonished when we see SAP environments (say) with clusters of three or four servers per tier for reliability -- as if this is somehow a good thing. The hassle of clustering is often not just not necessary with Solaris -- you only need a pair of servers for DR, or when you don't have *any* maintenance windows.

For some reason, ICT managers usually can't wait to get rid of Solaris, and the market share of the Solaris operating system continues to plummet in favour of Windows and Linux. For Java or Oracle centric environments like SAP and TM1, this approach is misguided; Substituting Solaris with Windows provides the worst of both worlds.

I plan to do some Solaris posts, and the first one is below. The Solaris docs should always be the first point of call - these notes are primarily here for my own re-consumption. If you happen to pass by I hope you find something useful.

Setting up a Solaris 11.2 Package Server

For anything more than trial install of Solaris 11, you want to have a local package repository server.

Package repositories can share their contents via both NFS and HTTP. This post concentrates on HTTP.

You also want to set it up the package server the right way. Here's how I set one up a local package server for my Solaris 11.2 lab environment.

Create a new zpool


The default location for a package repository in Solaris 11.2 is /var/share/pkg/repositories. This is in the root zpool, which is less than ideal for a number of reasons.

So instead I used a separate disk and zpool for the the package repository. 

First I created the new zpool "repositories" on the device c1t2d0:

# MOUNTPOINT=/export/pkg/repositories
# REPO_ROOT=${MOUNTPOINT}/solaris-11
# mkdir -p ${MOUNTPOINT}
# zpool create -m /export/pkg/repositories repositories c1t2d0
# mkdir -p ${REPO_ROOT}
# zfs set recordsize=16k repositories
# zfs set compression=zle repositories

The last two lines are a little bit of sugar; The files in the package repositories have an average size of about 24kB, which is why I specified the smaller record size of 16k (default in ZFS is 128kB). Since the files themselves are already compressed, only the directory indexes and metadata will benefit from compression. The zle compression method probably the best choice here, but to be honest there is probably not a great deal of benefit from compression, so you can leave it off if you like.

I've also tried zfs de-duplication in the past but the performance hit when updating the repository was so crippling I had to disable it. 

Build the package repository

I created a temporary directory to hold the downloads.

# mkdir /var/tmp/repo-files; cd /var/tmp/repo-files

I then copied the package repository download zip files to this directory. You should end up with the following files. The sol-11_2-repo-*of4.zip files are NOT yo be unzipped before the script is run.

# ls
README-zipped-repo.webarchive.txt sol-11_2-repo-1of4.zip            sol-11_2-repo-3of4.zip            sol-11_2-repo-md5sums.txt
install-repo.ksh                  sol-11_2-repo-2of4.zip            sol-11_2-repo-4of4.zip

I then ran the install-repo script

# ksh ./install-repo.ksh -d ${REPO_ROOT}

And configured the package repository http server:

# svccfg -s application/pkg/server setprop \
  pkg/readonly=true

# svccfg -s application/pkg/server setprop \
  pkg/inst_root=${REPO_ROOT}

I changed the port to 10,000 (default 8080) so as not to clash with other services that I might wish to run on this machine.

# svccfg -s application/pkg/server setprop \
  pkg/port=10000

Fire it up, so the package server is available over http

# svcadm refresh application/pkg/server
# svcadm enable application/pkg/server

Sometimes it can be a pain to remember with the repository root is when doing tasks such as updating the repository. So record it in a Readme file in the repository directory:

# echo "The repository root for future commands is\
  \""${REPO_ROOT}\""" \ 
  > ${REPO_ROOT}/Repository_Root.README.txt

Point clients to the package server

I then ran this command on each Solaris server (global zones only). Make sure you don't forget to run also the command on the repository server itself. 

# pkg set-publisher -G '*' -M '*' \
  -g http://<hostname>:10000/ solaris

Where <hostname> is the FQDN of my package repository server. 

Check that a client can see the package repository correctly:

# pkg publisher
PUBLISHER        TYPE     STATUS P LOCATION
solaris          origin   online F http://<hostname>:10000/

You can connect to the above URL with a browser  verify operation and search for files.

Lastly, clean up:

# cd /root
# rm -rf /var/tmp/repo-files


Installing software from the package repository


With the package server setup and clients configured to use it, installing new software is straight forward. For example, the following commands install and start the ftp server:

# pkg install service/network/ftp
# svcadm enable svc:/network/ftp


Updating clients


Updating clients is easy too. In the  global zone of a client, say the following:


# pkg update
# touch /reconfigure && shutdown -i 6 -g 0 -y


Keywords: Solaris 11, pkg, package, publisher, repository

No comments:

Post a Comment