DLNA and the Media Center of Doom

In my never-ending quest to rid the house of anything to do with Microsoft, I decided time was up for the Core 2 Duo, circa 2006, that had been doing Sterling service as our Media Center, first running Windows 7 Media Center and then upgrading to Windows 8 (plus the paid-for Media Center addition).

It’s worked quite well, but has occasionally hung (and inevitably, it hangs just when a really good TV program needs to be recorded). and exhibited other, sporadic and quite rare, weird behaviours. The PC itself was an old rack-mounted monster and was beginning to show signs of its age. All things considered, therefore, I felt it was time to put it out to pasture.

What to replace it with? Well, my first choice might have been another PC running something like MythTV… but ToH has to be taken into account, which rather rules out anything requiring more than an on/off switch, to be honest. I wouldn’t call myself a MythTV expert, either; and the one thing I know about it for sure is that it can be scarily complicated… so no thanks! Something more “consumer electronic good”-like, and less PC-ish. Something that just works. Something that doesn’t cost the earth.

Well, the picture at the top of this post gives the game away: after exhaustive minutes of online research, we bought a Panasonic DMR-HW220. It comes with WiFi built-in, plays MKVs, has a 1TB hard drive, twin HD tuners… and thus seemed to fit the bill perfectly, especially because it was only $340.

If only I’d read the small print (or the online reviews that spell it out!): whilst the machine is Wifi-aware, it has no concept of mapping network drives. It can’t see Samba shares. It’s network capabilities are, in fact, limited to acting as a DLNA server and/or client.

DLNA?? Someone of my age and upbringing probably thinks it’s a splinter Irish terrorist organisation, but in fact it stands for “Digital Living Network Alliance”, and it’s a set of standards built around UPnP to determine how different electronic media devices play nice with each other. In my home media center context, it means that the Panasonic is a DLNA Client, and that means something on the PC has to be running as a DLNA Server (and Samba or NFS don’t count).

Immediately, therefore, things are more complicated than I’d like: how to run a DNLA server on the CentOS box that’s hosting all my movies, music and photos?

Happily, such a beast does exist and it’s relatively painless to set up: MediaTomb. I could also have installed miniDNLA, which works very simply, too. You can obtain it with a simple “yum install mediatomb” once the RPMForge repository has been added to your list of software sources. Once it’s installed, you need to start the thing with a service mediatomb start -and a chkconfig mediatomb on to make it re-start automatically at every subsequent server reboot. Once it’s running, do a service mediatomb status to find out what port it’s running on: by default, it’s 49152, but a status check will make certain.

Once you know the port, just fire up a browser and type in an address of http://<server IP>:49152 (or whatever port you’ve determined is in use). You should see a pretty bare-bones interface. Select the Filesystem link and you’ll see a tree-like representation of your server’s hard disk structure. Navigate to where your media files are then click the ‘Plus-in-a-Circle’ button on the top right:

Here’s where you get to mark a directory (and it’s sub-directories, if you tick that ‘Recursive’ option) for inclusion in the list of what this DLNA server can, er, serve. Scoot on over to the Panasonic, select the correct option to act as a DLNA client and… bingo! The appropriate directories are now browseable.

Erm… except that none of my MKV files were actually playable! I could certainly see them on the Panasonic, but they were greyed out. I checked the box: “MKV Playback” was definitely there in big, bold letters. So why my MKVs couldn’t be played, I couldn’t quite fathom. Until I read up on DLNA a bit more and discovered that MKV is not a supported container format for DLNA. Some clients can deal with them, but most can’t… and the Panasonic certainly doesn’t.

Had I read the ‘Cons’ column at the top of this product review before purchase, I don’t think I’d have bothered with the Panasonic at all, to be honest: “Can’t play MKV over network”. Plain and simple.

My plans to workaround this awful limitation consisted of copying my MKVs onto a USB hard disk, plugging that in and having the media play from there. Except that when you plug in a USB disk like that, you have to “register” it with the Panasonic device …which means “format” it, and with some sort of file system the likes of which none of my Windows or Linux boxes have ever met before. Once the Panasonic has touched the disk, nothing else can, basically. Too late I discovered that the ability to plug in USB devices is intended to get stuff off the internal 1TB hard disk by way of backup, but not to let you put stuff on to it via a PC, for example. DRM rears its ugly head, therefore, and makes an obvious way of media ‘injection’ non-viable.

(I believe that the on-box claim for MKV playback relates to the ability to play from an SD card. Not exactly what I had in mind, though).

At this point, I fear it’s obvious that I haven’t done my homework, and I am accordingly saddled with a machine which barely meets any of my functional requirements (it can record two TV channels at a time in HD, but that’s about it).

There is one saving grace: MKV is a container, not a video encoding. It’s therefore possible to extract the contents of an MKV and re-pack it in an MP4 container (which the Panasonic does play over the network, because the DLNA spec says it must), without any re-encoding effort. (That’s important, because with a couple of thousand video files to deal with, re-encoding is not an option!)

Various tools can do this re-packing trick: on my Fedora box, perhaps the simplest is Avidemux. You open your MKV, set the Video and Audio Outputs to “Copy”, select “MP4v2 Muxer” as the output format and then click Save. Done locally, a video file is thereby converted from unplayable MKV to playable MP4 in a matter of seconds. Done by pointing Avidemux to my network shares over the wire, however, and it takes a couple of minutes per movie… which is too long to be practical.

The obvious trick is to perform the re-packing on the server itself, for which a command line tool would be good. There is actually an Avidemux command line tool (avidemux3-cli, if you’re trying to yum install it), but scripting it is a nightmare and even invoking it file-by-file is a pain in the butt. So, in the end, I created this little shell script as a file called movieconvert.sh:

IFS=$(echo -en "\n\b")
f=`ls *.mkv`
ffmpeg -i "$f" -vcodec copy -acodec copy `basename "$f" .mkv`.mp4

The …IFS… lines are there to deal with the fact that a lot of my movie files have spaces in their names, which would result in ffmpeg trying to convert files called “2001″, “A”, “Space” and “Odyssey” instead of a single file called “2001 A Space Odyssey” (which would be wrong, of course, and thus just lead to runtime errors). Otherwise, the main action is done by invoking ffmpeg with a bunch of switches which demand the video file be copied, not re-encoded, but re-packed as an MP4, not an MKV.

I stuck that in /usr/bin (so it’s in my path), and now I can cd to any directory containing a movie file and do ./movieconvert.shand everything then just happens automatically. Sure enough, the Panasonic can play the MP4s just fine, too.

So we settle down for the evening to watch one of the movies I’d converted into MP4, and all was going swimmingly. Until suddenly a pop-up appeared informing me that a scheduled TV recording was about to start and therefore the DLNA connection would have to be terminated. What??? Yup. It turns out that you can’t record a program in the background whilst watching a film over the network. Which makes this particular Panasonic a piece of crapola that got taken back to the store that sold it the very next day. Happily, a full refund was received with not too many questions asked.

So what am I using now? Funnily enough, exactly the same kit that the Windows Media Center originally replaced: a Western Digital WD TV Live, which does movies and music very well, using plain old Samba shares to which it connects without drama. And for the live and recorded TV, a relatively ancient Topfield TF-7100 (now about 4 years old, upgraded by yours truly to a 500GB hard disk some years ago, still going strong).

The only pain points in going back to this arrangement are that it would require 4 remote controls (WD TV LIve, the TV, the receiver/amplifier and the Topfield). Happily, a Logitech Harmony all-in-one remote control takes care of that. Which leaves just one real pain-point: the TV listings in Windows Media Center are clear and speedy to navigate. The Topfield equivalent is hopeless, displaying just one channel at a time and taking an age to load or move through. A many-channels-at-a-glance view would be good, but no such beast exists. Not even the paid-for ICE TV gives what is needed. For the moment, I have no answer to this one, then.

Whether we persist with this retro setup, I can’t say. However, I can say that the Panasonic DMR-HW220 is completely hopeless -and, indeed, that anything relying on DLNA is not something I’ll be letting into my house again any time soon! I am really surprised that there isn’t a single box which can do dual-channel live TV, multi-channel recording, Samba connections, MKV and FLAC playback, with a decent, synoptic program guide. But as far as I can tell, there simply isn’t: and that seems a curious gap in the market at this stage of the game!

Rolling in some changes to the production system the other day required me to work through the evening and into the early hours. I finally left the office at 2.00AM, meaning that I was in need of a taxi ride home (104KM away). Two cabs turned me down; the third agreed to take me: it’s a long way out of anyone’s way, so I was grateful.

Being extremely tired, I had hoped to snooze whilst the taxi worked its way to deepest southwest Sydney, but I hadn’t reckoned on the fact that I had somehow managed to pick the worst taxi driver in Christendom. Straight bits of road he could mostly do, but anything involving the slightest curve seemed to compel him to cross the lane dividing line, so that one or more wheels continually bumped as the white dashes stopped and started. In this lane-straddling fashion, we’d limp our way home for long, bouncy minutes at a time.

I could have lived with that, I suppose, but that would have been to ignore the drivers strange desire to brake and accelerate, more or less at random, and never with any warning. If the road curved ever-so-slightly, we slowed -abruptly- to around 60km/h. If the road straightened out so he could see which way the lane was going (i.e., straight ahead!), then 130km/h seemed more his sort of thing, with heavy application of foot-to-pedal. And this was on a well-lit motorway, not the country lanes we get to as we near my house. The less said about his capabilities on them the better!

I’ve seldom spent an hour and a half in such fear, to be honest. But if you’re stranded miles from home in the middle of the night, what else are you going to do?

The final fare ($357) was enough to have hired a helicopter for the evening, I think.

Never again!!

Salisbury, plain

Way back in October last year, I announced that I wouldn’t be developing my Gladstone pre-installation script for Oracle any further, although the script itself would remain available (and it still is).

Back then, I promised a “son of Gladstone” replacement, “soon enough”. Little did I think it would take me six months to honour that promise! Such is life, I fear…

But Gladstone’s successor is now here… and, in keeping with (near) historical fact, that successor is to be called “Salisbury”. (That’s him on the right, looking suitably Victorian and bushy-bearded).

So, what exactly is Salisbury and how does he work?

Well, it’s a slight extension of the work I’ve been documenting in the previous dozen or so posts here: the idea of using Kickstart to automate the construction, the correct configuration and the Oracle software installation of Oracle servers. Additionally, it’s the use of a Kickstart-built server to supply all necessary network and shared-storage capabilities that Oracle Servers might need -especially if they run RAC.

In terms of tangible ‘product’, Salisbury actually consists of a single ISO download, just 27MB in size.

You use that ISO to kickstart the building of a Salisbury Server -a small server running RCSL that I’ve referred to in previous weeks as a ‘Linux toolbox’. Once your Salisbury Server is up and running, you use it to build your Oracle Servers. Those Oracle servers can run Oracle versions or in standalone or RAC mode. If you choose a standalone build, the Salisbury Server will automatically install the Oracle software for you, and create a simple shell script that will create a database when run post-install. If you instead choose to create a RAC-capable server, Salisbury will copy across all necessary software (and get users, groups, kernel parameters and so on correctly configured), but it won’t attempt to install anything automatically (because working out whether all the component parts of a cluster are up and running is a bit tricky!)

I present Salisbury here as, more or less, a fait accompli -but how it works and why are all things I’ve discussed in considerable detail over recent weeks, so if you’ve been following along, there shouldn’t be too many surprises (and if you haven’t, you can always step back to this post, which started it all, and read forward from there). I will try to pull it all together into a single, long article before long, though.

Building a Salisbury Server

The quick version of getting the Salisbury Infrastructure™ to work for you is this:

  • Build a new server with at least 512MB RAM and 60GB free hard disk space. Ensure it has two DVD drives.
  • Load your distro-of-choice’s full installation disk into the primary drive
  • Load the Salisbury ISO into the secondary drive
  • Boot your server and hit <TAB> at the boot menu. Make your build process Kickstart-defined by adding ks=hd:sr1/salisbury.ks to the bootstrap line.
  • Sit back and let the installation process complete.

Your new Salisbury Server will have only a root user account (password: dizwell). You can change that password with the passwd command, of course.

The Salisbury Server will automatically be a web server, complete with all sorts of useful files and packages which it can distribute to client Oracle Servers. However, the really important stuff is Oracle’s database server software -and, much as I’d like to, licensing restrictions mean I can’t provide that for you. Instead, you have to source that yourself, either from OTN (for free, but only at version, or from edelivery (if you have a proper, paid-for subscription and want to download version or better).

However you source it, you should obtain both database zips AND the grid zip and copy all three files to the /var/www/html directory of your Salisbury Server (FTP transfer with Filezilla or a similar tool is probably the easiest way of doing that).

In their wisdom, Oracle Corporation saw fit to name their software multiple different ways, depending on how you sourced it and what version you’re dealing with. This is a recipe for Salisbury Confusion™ -but it’s easily avoided by renaming whatever you download in a consistent way, as follows:

  • oradb-1120x-1of2.zip
  • oradb-1120x-2of2.zip
  • oragrid-1120x.zip

Replace the “x” in those names to reflect the actual version in use, of course. There is no flexibility about this: the Oracle software components must end up being named in this way if the Salisbury Server is to be of any future use to you in building Oracle Servers.

By renaming files in this way, it’s perfectly possible to have one Salisbury Server be able to create both versions of Oracle database: just download all 6 files (the 11201 three and the 11203 equivalents), and rename them all according to the above-mentioned scheme. When both versions are possibilities, you’ll be able to specify which one to use for any particular Oracle Server at build time, as I’ll explain shortly.

So, after building your Salisbury Server, you just have to copy Oracle software to it (and rename it as appropriate), just once. After that, it’s ready for duty.

Note that the Salisbury Server build involves copying its own installation media to disk. If you build your Server using OEL 6.3, for example, then a /var/www/html/oel/63 directory will be created and populated on it automatically. Such a server can then only help build other OEL 6.3 servers. If you want to be able to build CentOS or Scientific Linux Oracle Servers, maybe mixing up versions 6.3 and 6.4 as the mood takes you, you can do that provided you create /var/www/html/centos/63, /var/www/html/sl/64 and similar directories yourself. The directory names have to be of the form /centos, /sl or /oel and the version directories have to be either /63 or /64. After creating any additional directories in this way, you can then simply copy over the contents of the full install media for that distro/version combination. Make sure you use the full installation media, not the “Live CD” versions. There is, however, no need to copy the second DVD into the directories where one is available: disk 1 will suffice.

Build an Oracle Server with Salisbury

Once your Salisbury Server is up and running, you can use it to construct new Oracle servers. An Oracle Server must have at least 2GB RAM and 25GB of free hard disk space.

You boot a new Oracle Server with the netinstall boot disk of your distro of choice. At the boot menu, you invoke the Kickstart process by pressing <TAB> and then adding a ks=<URL> string to the bootstrap line. That <URL> element will be formed from the following elements:

  • Salisbury Server’s IP address
  • kickstart.php filename
  • five possible URL variables
  • Two possible Kickstart parameters

It is assumed that your Salisbury Server has an IP address of (if not, you’ll have to edit various files on the Salisbury Server itself).

The Kickstart filename is simply kickstart.php

The seven possible URL variables are:

  • distro (one of either centos, sl or oel)
  • version (one of either 63 or 64)
  • hostname (pretty much anything you like, so long as it’s a valid host name)
  • domain (pretty much anything you like, so long as it works as a domain name)
  • rac (one of either y or n, depending on whether you expect to be running a RAC or standalone database on the finished server)
  • ip (the IP address of the server, in a.b.c.d form)
  • ic (the IP address of the cluster interconnect, in a.b.c.d form, assuming one exists)

The two possible Kickstart parameters are:

  • ksdevice=<name of network interface to use initially, if there are 2 or more network cards present, such as eth0 or eth1>
  • oraver=<11201 or 11203, depending on which version of the Oracle software you want to use; can also be set to none to mean ‘don’t copy any Oracle software at all’… useful for second and subsequent nodes of a cluster>

You must supply a distro and version, but if you miss out any of the other parameters or variables, defaults will kick in. If you fail to supply an “oraver”, for example, will be assumed; if you don’t say whether “rac” should be ‘y’ or ‘n’, a standalone, non-RAC installation will ensue, and so on.

At a minimum, therefore, you will initiate your Oracle Server build by typing something like the following at the bootstrap line:


A complete bootstrap line, leaving nothing to chance, would look more like this:

ks= ksdevice=eth0 oraver=11203

Notice that the URL variables are present as one, continuous string, begun with a “?”, separated by “&” and without any spaces. The Kickstart parameters, however, are supplied as space-separated keyword/value pairs at the end of the URL.

Of course, if you specify variables which imply software choices that your Salisbury Server does not have available to it, you can expect the Oracle Server build to fail. If you say oraver=11203, for example, when you’ve only stored software on the Salisbury Server, then your finished server will have no Oracle software on it at all. If you’ve prepped your Salisbury Server to host all possible distro and Oracle versions, though, then you can specify any of the available options in whatever combination and expect a completely automated O/S and Oracle software installation accordingly.

Oracle Servers built via Salisbury will end up with a root user (password dizwell) and an oracle user (password oracle). You can change either or both of these passwords after installation, of course.

Non-RAC Oracle Servers will have a version of the Oracle software installed. No database will exist, but a createdb.sh shell script will have been created in the /home/oracle directory. Running that (as the oracle user) will result in the automatic creation of a database called orcl. SYS, SYSTEM and other administrative passwords will be set to oracle, but these can be changed using standard database commands at any time.

RAC Oracle Servers will have no software automatically installed, but an /osource directory will have been created, within which are database and grid directories containing the appropriate unpacked Oracle software. The software is therefore immediately ready for installation, whenever you’re satisfied that the entire cluster is up and running.

All Oracle Servers will be built with mounts of NFS shares made available by the Salisbury Server itself. There are two such mounts: /gdata and /ddata, which correspond to the Salisbury Server’s /griddata and /dbdata directories. Non-RAC Oracle Servers can just ignore the existence of these shares, but RAC Oracle Servers can make use of them during the Grid and Database software installs to store grid and database components on a shared file system. It is assumed that RAC Servers will use their own, local, non-shared file systems for storing the Oracle software components.

Both Salisbury and Oracle Servers can be managed remotely with Webmin (point a browser to it at port 10000). Both can also be monitored at the command line with nmon.

Oracle Servers will have rlwrap capability baked-in, so local SQL*Plus sessions will make use of it to provide a scroll-able command line history (that is, you can hit the up- and down-arrow keys in SQL*Plus to retrieve previously-typed SQL statements). Should anyone have ideas for what other software components would be useful to add to either the Salisbury or Oracle servers (or both), please feel free to drop me a line. If it’s useful and do-able, I’ll do it!

Note that both the Salisbury and Oracle Server builds are fatal to anything that might already be sitting on the hard disk of the servers involved: Kickstart is used to simply wipe all partitions it finds. Don’t point Salisbury at pre-loved servers that contain vitally-important data, therefore: you will lose it all if you do.


Salisbury is obviously a lot more complicated to describe than Gladstone! In practice, though, you should find it hands-free, highly automatic and, basically, a piece of cake to use.

The complexity arises because it’s an infrastructure, not a script -though it’s an infrastructure that bootstraps itself into existence courtesy of Kickstart scripts.

It depends on several version-dependent components, of course: Kickstart scripts designed for version 6.x RCSL distros won’t work with version 5.x RCSL distros, for example. Similarly, response files that perform perfect Oracle installs blow up spectacularly when confronted with software. I don’t expect Salisbury to cope with arrival of Red Hat 7 and Oracle 12 without a degree of pain, therefore! I do believe, though, that its underlying techniques and technologies are flexible and extensible enough to be able to cope as the future does its worst.

It’s taken quite some weeks to get it to this state: I hope someone out there finds it as useful as I have!

Conditional Kickstart (Part 2)

Last time, I discussed how you can make different bits of the %post section of a Kickstart file behave conditionally, by specifying key/value pairs on the bootstrap line when starting a Kickstart-managed O/S install.It works nicely and lets me do different things depending on what version of Oracle I’m installing at the time.

I pointed out, however, that you couldn’t use this capability to get different parts of the command section of the Kickstart script to behave conditionally. And that’s a nuisance because the command section is where you include things like the url command that tells your Kickstart script where its source O/S can be found -so, if you have half a dozen OSes to choose from, you can’t just create one Kickstart script with a conditionally-evaluated url bit in it.

So much remains true.

However, as one of the regulars here was quick enough to point out, it ought to be possible to get the Kickstart server to do conditional evaluation and to dynamically construct a Kickstart file accordingly. Indeed, I wrote a PHP script for my Kickstart Configurator on this very site not so long ago that did precisely that; so good point, Colin!

So let me explain how I ran with this idea of getting the Kickstart server to do some dynamic, conditional evaluation, particularly of this annoyingly-important url bit of the command section. First thing was to add PHP to my Kickstart server. Because it has no Internet connection, I had to install the necessary software from the CentOS install DVD, mounted at /media:

cd /media/Packages
rpm -Uvh php-5.3.3.-22.el6.x86_64.rpm php-cli-5.3.3-22.el6.x86_64.rpm php-common-5.3.3-22.el6.x86_64.rpm

That’s three packages installed in one hit, because they’re dependent on each other.

Next, I had to get the toolbox’s Apache web server to realise it ought to be handling PHP:

nano /etc/httpd/conf/httpd.conf

Scroll through that file and around about line 202, you can add this:

LoadModule php5_module modules/libphp5.so

And around line 788, you add this:

AddType text/html .php

This just tells Apache where to find the php software and that it’s able to handle files with a .php extension. Save the modified file, then re-start Apache like so:

service httpd stop
service httpd start

Now, take the alpher-sl64.ks file I talked about last time and copy/rename it:

mv /var/www/html/alpher-sl64.ks /var/www/html/alpher.php

This just means that your original Kickstart file is now regarded as a PHP file. Of course, it doesn’t contain any PHP code just yet, but that’s not important.

Around line 25-33 in the copied/renamed file, you’ll see this:

#  =======================================================================
#  The source distro software (obviously distro and version specific) 
#  =======================================================================
url --url
#url --url
#url --url
#url --url
#url --url
#url --url

This can now be replaced as follows:

#  =======================================================================
#  The source distro software (obviously distro and version specific)
#  =======================================================================
url --url<?php echo $_GET["distro"]; ?>/<?php echo $_GET["version"]; ?>

Instead of 6 lines of code, 5 of which need to be commented out to leave just one, distro-specific “active” line, we now have just one line of code that includes some PHP code. The code simply parses the URL by which this file is called for two arguments: the first is the distro being used and the second is the version of that distro.

In other words, if you simply opened up a browser and entered in the URL:

…you would see the garbled text of the Kickstart file displayed -but, if you looked closely enough, you’d see that there is now a properly-formed, but dynamically-constructed url –url http… line of text in it, like so:

And the point is that if your browser can get this result, so can a Kickstart bootstrap line when constructing a new Oracle server. I’m still using the conditional execution I discussed last time, of course, so adding this new sort of conditionality to the mix means my complete Kickstart bootstrap command now looks like this:

By simply altering the value of the distro and version components of the URL that’s pointing to the Kickstart script, plus supplying different values for the separate oraver=xxxx parameter, I can now have a single Kickstart file to do duty for any combination of RCSL distro and Oracle 11gR2 I can think of. Handy!

It would be possible to use the same technique to make all sorts of other bits of the original Kickstart scripts behave dynamically: you could pass in IP address parameters, for example, or passwords for the root user, or specific disk partitioning instructions. But my needs are simple and, at this stage, all I really need is the ability to create that pesky url… command, which this does nicely. I also don’t want it to become a pain in the neck typing in the Kickstart bootstrap line in the first place, which adding a fistfull of parameters would, inevitably, do.

So, after several weeks of telling this particular story bit-by-bit, and building up the necessary components layer by layer, I think we’re finally in a position to pull all these threads together into a single, coherent package. Watch this space!!

Conditional Kickstart

Consider lines 25 to 30 from the Kickstart script I linked to in the last post:

#url --url
#url --url
#url --url
#url --url
url --url
#url --url

There are six possible combinations of distro and version, and therefore there are six possible values for the ‘url’ parameter. It happens that 5 of the 6 have been commented out and are thus inoperative, leaving a single ‘real’ line that does a job of work.

But the obvious question then arises: Is there a way to have a Kickstart file say (for example) “install from this URL if you are Scientific Linux 6.4, but that URL if you are CentOS 6.3″? That is, could you leave all 6 lines ‘operative’ and have Kickstart look at the environment it’s running in and decide which of the six to apply at any given time?

The answer is,sadly, no. Not like that, anyway. Kickstart can’t do “self-evaluation” like that.

But what you can do is tell it ahead of time what its environment is going to be and have it react accordingly. You can do that by passing a parameter value to the installer at the bootstrap command line; you then parse that in a “%pre” section of the Kickstart script and then you can conditionally execute stuff depending on what you parse by using an %include directive.

For example, instead of booting a server with a bootstrap line of ks=, you could boot it with ks= distro=sl64. Then, you stick this sort of stuff in the %pre section of the Kickstart file:

if grep -i -q "distro=[a-z0-9]" /proc/cmdline
    MYDIST=`cat /proc/cmdline | sed 's/.*distro=\([^ ]*\).*/\1/'`

Variables and their values which you pass on the bootstap line are readable from /proc/cmdline. This code simply uses sed to split the variable from its value, then assigns a value to the $MYDIST environment variable depending on what bootstrap value it finds has been passed.

The theory is that you’d then be able to do this sort of thing:

if [ $MYDIST == "sl64" ]; then 
  echo "url --url" > /tmp/urlfile
  echo "url --url" > /tmp/urlfile

So you output different things to a file in the /tmp directory, depending on the value your environment variable has been set to. Instead of then having the url section of the Kickstart file I showed earlier, you would then replace that with:

%include /tmp/urlfile

This causes the Kickstart file to read in the contents of that urlfile, and thus pick up the distro-specific URL value I desire.

Brilliant …except it doesn’t work. The reason is simple: the bit of the Kickstart file which contains the url… directive (usually called the “command section”) is evaluated before the %pre section. The documentation is quite explicit about it, too:

Note: The pre-installation script section of kickstart cannot manage multiple install trees or source media. This information must be included for each created ks.cfg file, as the pre-installation script occurs during the second stage of the installation process.

So, as far as I know, there’s no way to conditionally determine the source of the software you’re about to install on your new server using this key/value pair technique. Shame: it means that if there are 6 different distro/version combinations, you need six different Kickstart files, each with the url directive set uniquely to one particular software source.

However, you are not so constrained if there are bits of the %post section you want to perform conditionally, because that’s definitely evaluated after the %pre section. For example, you know that an Oracle response file is highly version-specific: an response file won’t work for an Oracle install. So why not pass in the Oracle version as a bootstrap keyword/value pair, evaluate it in a %pre script, then do stuff differently in the %post section depending on the value passed?

For example, in my Alpher Kickstart script I linked to last time, I have line 473 as this:

wget -O /osource/standalonedb.rsp

But suppose on the Kickstart server, I have two different response files, called standalonedb-11203.rsp and standalonedb-11201.rsp.

I add this to the beginning of the Kickstart script:

if grep -i -q "oraver=[a-z0-9]" /proc/cmdline
    ORCVER=`cat /proc/cmdline | sed 's/.*oraver=\([^ ]*\).*/\1/'`
if [ $ORCVER == "11201" ]; then
    echo "wget -O /osource/standalonedb.rsp" > /tmp/standalone
elif [ $ORCVER == "11203" ]; then
    echo "wget -O /osource/standalonedb.rsp" > /tmp/standalone

So we create a /tmp/standalone file which contains the instructions to download a version-appropriate response file, depending on the value of the oraver=<something> parameter we supply on the bootstrap command line.

Instead of the original line 473, therefore, I now have this:

%include /tmp/standalone

…so that we read in the version-dependent command to execute from the temporary file previously created. All I have to do to get this functionality to work is type something like:

ks= oraver=11203

…when I boot the server. There’s no practical limit to the number of these key/value pairs you can pass to a Kickstart script, providing only that you have code in your %pre section that can parse them out, write different files to /tmp depending on the values passed, and use %include commands wherever conditional execution needs to take place.

Hands-free Oracle Installs

OK: if you’ve been following along the last dozen or so posts, you will have by now automatically built yourself a “Linux toolbox” -a minimalist server running a variety of network services. You would then also have dropped a bunch of additional rpms onto its /var/www/html document root. And now it’s sitting there, waiting to be useful.

Time, therefore, to make it so. We need just four additional things: a network boot ISO for your chosen RCSL distro; a Kickstart file that’s suitable for building Oracle servers; a response file that’s suitable for automating the Oracle software installation; and a bunch of scripts that can automate the creation of an Oracle database.

Taking each of those in turn, therefore:

1. The O/S Network Boot ISOs

If your toolbox server runs Scientific Linux, you’ll need the Scientific network boot ISO; if it runs CentOS, you’ll need the CentOS network boot ISO… and so on. You also need to match versions: a 6.3 netboot ISO won’t be any use if your source distro is version 6.4, and vice versa. Here are where I source my network boot ISOs from:

Download the appropriate boot ISO and burn it to DVD or CD (or just use it in its ISO form if you’re booting a virtual machine).

2. The Kickstart File for an Automated, Standalone Oracle Server

Any Oracle server you build needs at least 2GB memory and around 25GB of hard disk -so any Kickstart file you use to automate its build should assume those resources are available to it. A suitable Kickstart file is extremely long and would look entirely out of place if I pasted it in here… so here’s a link to one I made earlier.

The name of that specific download is “alpher-sl64.ks”, because it’s been written to look for software in the /var/www/html/sl/64 directory -you can tell I’m using Scientific Linux 6.4 for this post! The exact same file can be used for CentOS and OEL installs though: just edit lines 25 to 30, uncomment out the one line that describes where your distro software has been copied to and comment out all the others. You’d probably then want to rename the Kickstart file suitably, too (so you might end up with alpher-centos63, or alpher-oel64 and so on).

I’ll go through that file in detail at the end of this post, but for now, just copy it to your toolbox’s /var/www/html directory (maybe via ftp transfer; otherwise, burn it onto a CD/DVD (or an ISO), mount it and copy it from there).

3. An Installation Response File

When you install Oracle’s database software by hand, you usually use the GUI Oracle Universal Installer (OUI), which involves clicking [Next] lots of times and typing in various things like passwords and installation paths as required. For many years, though, it’s been possible to save the outcome of making all these choices in a response file -and then point the OUI at that response file on second and subsequent servers. In this way, it’s possible to achieve an automated, GUI-less installation that’s identical to your first.

You could create your own response file in exactly this way, therefore: do one manual Oracle installation and save the results.

Naturally, I’ve done this for you already, so you can simply download an appropriate response file now. Unfortunately, response files are highly version-specific, so if you’re intending to install, this is the file you want; if you’re intending to install, though, you’ll want this one instead.

In either case, rename the download to be just standalone.rsp and then copy it to your toolhox’s /var/www/html directory.

4. Database Creation Scripts

When you manually create an Oracle database, you generally do so with the GUI (and Java-based) Database Configuration Assistant (DBCA). You click [Next[ lots of times, pick the various options you want your database to use, type in things like database names and then it goes off and does the magic.

It’s long been possible, though, to save the set of instructions it follows as a bunch of database creation scripts -and then to execute those scripts from the command line. The DBCA then executes in silent, non-GUI mode, yet still performs exactly the same steps as before, resulting in the creation of an identical database each and every time.

So, to automate database creation, you could do it manually yourself once, and save the necessary scripts… or you could just download the set of scripts I’ve already created for you and zipped up. Note that my script defines the SYS, SYSTEM, DBSNMP and SYSMAN passwords identically as oracle: you can change passwords after the database has been created, of course.

Just transfer that zip file over to the /var/www/html directory of your toolbox server. If you build your own scripts, zip them up into something called “scripts.zip” and do the same.

So, when you’ve got this far, what does your toolbox’s /var/www/html directory now look like? Well, here’s mine:

Taking that lot in the order shown:

  • sl → the directory where the full distro software is stored (could be “centos” or “oel”, of course, depending on which RCSL distro you’ve decided to use)
  • alpher-sl64.ks → the Kickstart script for the soon-to-be Oracle server
  • oradb… → two files which are the Oracle 11g software, in zip form
  • pdksh → the public domain Korn shell rpm
  • rlwrap → the read-line wrapper rpm
  • scripts.zip → the bunch of scripts needed to create a database at the command line
  • standalone.rsp → the response file needed to install Oracle
  • webmin → the webmin rpm that gives you a browser-based server admin tool

If all those things are there, then we can begin…

5. Boot the Server

I’ll assume you’ve already built your Oracle server (or created a virtual machine that will do duty as one, anyway): so long as it’s got a 25GB hard disk and (a minimum of) 2GB memory, it will do fine. Just boot it up using the network boot ISO you downloaded at Section 1 earlier …and then press <Tab> when the boot menu appears.

That causes a command prompt to appear, already containing some textual commands. You add on to the end of what’s there just this:


That is, you tell the boot process that you’d like O/S installation to be governed by a Kickstart file called “alpher-sl64.ks” which is available from the server acting in its capacity as a web server. (If you’d renamed the file as I mentioned earlier, so that you could use CentOS or OEL, then obviously change the command here to match).

The whole thing looks like so:

Press Enter, sit back and watch.

If your hard disk is brand new and has never been partitioned before, you will see a screen that prompts you to re-initialise it:

As you can see, the correct response is to agree to ‘Re-initialize all’. If your hard disk already has partitions, then you won’t be asked about this: they will all be automatically wiped without intervention from you (so don’t try this out on a computer whose disk contents are in any way important to you!)

6. What Happens Next…

If all goes according to plan, the O/S will now be installed without prompting you in any way. It’s a minimal sort of install (no GUI, for example), but with networking set up correctly and with all the software prerequisites required for a successf4ul Oracle install taken care of. On my laptop (which is pretty modern with a decent i7 processor and lots of RAM, but no solid-state hard disk), that takes all of 5 minutes to complete.

Immediately the basic OS is installed, the “post-install scripts” will be run:

During this phase of the installation, the Oracle software is being copied across from the toolbox and being unzipped. Since that’s about 3GB-worth of data to transport and unpack, it can take quite a while to complete! You’ll just have to be patient about it, since no progress indicator is displayed. (On my laptop, it took another 5 minutes).

After that, the screen will go black and the Oracle software installation will start:

This phase takes the longest time: on my laptop, around 15 minutes. At the end of it, the installer will switch back to “blue mode” and ask you to reboot the server: the job is almost done!

The final thing you do, once the server reboots, is to log on as the oracle user (using my Kickstart file, the password for that user is oracle; the root password is dizwell). Now comes only the second bit of typing you’ll have been asked to do for the past 30 minutes: you invoke the database creation script, like so:


This will scroll quite a bit of text up the screen as it runs, but crucially it will ask you what the SYS password is: remember, that’s been defined in my script as being oracle, so type that in when prompted and then the whole database creation process will begin. Lots of instance bounces later, you’ll be prompted to supply the same password as part of the EMCA (Enterprise Manager) configuration process. At that point, too, you’ll be asked to type in the same password for both the DBSNMP and SYSMAN users. Again, it’s oracle in the script I’ve supplied, so if you’re using that, wait until after the database creation process has finished before trying to change them.

The entire database configuration process completes in about 10 minutes on my laptop. At the end of it, you’ll see a text message appear like this:

And at that point, you’re really all done. You might like to type reboot and get the server to do one last bounce: when it’s back up, you should be able to log on as the oracle user, fire up SQL*Plus and connect immediately to a running database -proving that auto-startup of instances is working OK.

7. Conclusion

So, 40 or so minutes after you began, you’ve typed one command to launch the O/S installation process; you’ve possibly had to say to re-initialise a disk; and you’ve had to invoke a createdb shell script.In return for that minimal investment of keyboard prowess, you get a complete RCSL server, configured properly; a complete and proper Oracle 11gR2 installation; and a fully-functional database called “orcl”,that can be managed remotely by opening a browser on a client PC and visiting

It’s not completely hands-free, then. But it’s pretty close …and not bad for a morning’s work.

By the way, because the Kickstart script installs rlwrap, you’ll also find that you can simply up- and down-arrow in SQL*Plus to recall a command line history, which is a neat trick ever since I first wrote about it in 2003. :-)

Of course, you may now want to spend some time altering the root and oracle passwords. But those things are pretty trivial, so this remains (in my view) a painless way of quickly and reliably creating pre-configured Oracle database servers.

Detailed Explanation of the Kickstart File

Lines 1 – 18 : Standard stuff simply indicating that the text-mode installer should be used.

Line 23 : How the new server will have its network configured. In this case, it will be assigned a static IP address and be called “alpher” (if you’re interested, here’s why).

Lines 25 – 30 : The same Kickstart script can be used to build a CentOS, OEL or Scientific Linux server …except that the source path of the necessary distro software on the toolbox server will be different in each case. This section lets you comment out those directories which don’t apply and leave active the one line which does.

Lines 36 – 41 : The root password is set to the encrypted form of the word dizwell. SELinux is switched off, as is the Firewall. The server ends up in the Australian time zone.

Lines 43 – 45 : These lines will, without warning, cause the new O/S installation to wipe the existing disk partitions and set up new ones: a 4GB swap partition and the rest of the disk will be assigned to the root mountpoint.

Lines 47 – 135 : These lines govern what software will be installed. It’s pretty minimal, in fact, but all the stuff needed to run Oracle properly. Of course, you may now want to spend some time altering the root and oracle passwords. But those things are pretty trivial, so this remains (in my view) a painless way of quickly and reliably creating pre-configured Oracle database servers. gets added to the mix.

Lines 144 – 156 : Gets a bit of NFS stuff organised, though this isn’t used by the subsequent Oracle installation.

Lines 162 – 170 : Gets NTP settings correct, making this new server look to the toolbox as its source of reliable time.

Lines 176 – 182 : Copies Oracle database software off the toolbox server and onto the local disk, in a directory called /osource. Then unzips the software and tidies up.

Lines 188 – 194 : Gets the /etc/hosts file right and also edits a couple of other network-related files (possibly redundantly in the case of /etc/selinux/config, but you can never be too careful!)

Lines 201 – 221 : Creates an oracle user (called “oracle”, password “oracle”), assigns him to appropriate groups and gets his local environment variables set correctly.

Lines 227 – 242 : Configures pluggable authentication modules to set security and resource limits for the oracle user, as recommended by Oracle.

Lines 248 – 455 : A long section which is simply setting kernel parameters to Oracle’s recommended values. We could hard-code minimum values in just a few lines, but that would be a bit redundant, since many parameters are set to defaults which are already perfectly adequate. So these lines first tests a parameter to see what it’s already set to.Only if it’s below the minimum recommended by Oracle does the script them set it to a recommended minimum. If it’s already at or above the recommended minimum, we just skip it.

Lines 461 – 467 : Installs rlwrap and pdksh. Pdksh is not really needed these days (though the Oracle Universal Installer gets upset if it doesn’t find it), but rlwrap is certainly useful when you’re using rman or SQL*Plus. It gives you a scrollable command line history for those tools.

Lines 473 – 484 : The real meat of the business! Here is where we perform the Oracle software installation. This takes a long time to complete, of course, and if we did nothing special, you’d be stuck looking at a ‘running post-installation scripts’ message for long minutes on end, with no clue as to what was going on. So, instead, we chuck in a chvt command to change the virtual terminal you’re looking at. That is why the screen flips to black when this starts, which is a bit awkward… but at least you can see the Oracle Universal Installer’s output and know (roughly!) what’s going on.

When the Oracle software install is finished, at line 558, we change terminals back to terminal 1 -the blue one, which will then display a message telling you to reboot.

Lines 490 – 539 : This just creates an init script that ensures that the listener, the database and the Enterprise Manager console is automatically re-started whenever the server itself reboots.

Lines 541 – 555 : It’s a shame that you can’t actually create a database at this point, but we’re in the wrong run-level and DBCA will crash out if you were to try running it now. Therefore, at this point the Kickstart script simply creates a little shell script which, when it is invoked manually post-O/S-install, will run DBCA in silent or non-interactive mode. It’s this shell script you invoke once you’ve rebooted the new server and logged on as the oracle user.

Add a dash of software…

In my last-but-one post, I explained how you could build a ‘Linux toolbox’: a RCSL server that acts as web server, DNS lookup server, NFS server and more. I also showed how you could do all of that with barely any manual intervention, thanks to the magic of Kickstart scripts.

Well, now I want to suggest a couple of additions to really round out your toolbox’s functionality. These can’t really be automated, because they involve agreeing to licences and export restrictions and so forth.

1. Add some useful binaries

Your toolbox server is lacking a GUI, so monitoring its CPU, disk I/O and memory usage might be tricky. Fortunately, nmon is a command-line utility that monitors all these things easily. So adding that to your toolbox server might be a good idea. It can be obtained as an rpm suitable for all of the RCSL 6.x, 64-bit distros from this site.

You may also feel you need a graphical way of re-configuring things like hostnames, IP addresses, DNS settings and so on. A useful tool for that is webmin, which is a browser-based way of doing precisely that. There’s an rpm suitable for all RCSL distros available on this page.

Once you install it, just fire up a browser in a client PC and point it at your toolbox server’s IP address, specifying port 10000. In my case, that means typing into a browser’s URL bar something like

After that, it’s just a matter of logging on (as root) and then clicking around seeing what is available.

I’m going to suggest two additional binaries you might want to download and store in the toolbox’s /var/www/html directory -not because they are useful to the toolbox itself, but because they might prove useful later on. First, the public domain korn shell is largely redundant these days, but happens to be a prerequisite for Oracle installs on RCSL distros, If you don’t install it, you can therefore get annoying warning messages from the Oracle installer. Fortunately, a version of it is available for download as an RCSL 64-bit compatible RPM from here.

The final binary I suggest you download is rlwrap. You can download it as a tarball, extract it and then compile it if you like, but there’s an RPM version available for download which is a bit simpler to get working, so I’m going to suggest you get that and store it in your toolbox server’s web document root directory instead.

Of course, if you’ve been following this series of posts, you’ll know that my toolbox server, by design, doesn’t have a network connection to the Internet, so downloading those things using the toolbox itself is not possible. That’s why I download them all on a different machine that does have an Internet connection and then burn them onto an ISO (a virtual DVD). (I use Brasero to do that, but any DVD burning software will do the job). Once the four binaries (nmon, webmin, pdksh and rlwrap) are stored on the virtual DVD, it’s trivial to get the toolbox server to mount the ISO and copy them all off to the /var/www/html directory. Once there, you can install nmon and webmin on the toolbox itself:

rpm -Uvh nmon-14f-1.el6.rf.x86_64.rpm
rpm -Uvh webmin-1.620-1.noarch.rpm

The other two will come in handy later on. If you can’t burn your own ISOs, here’s one I prepared earlier

2. Add some Oracle files

The other software which it would be useful to copy to the toolbox, so it can be served up to clients later on, is the Oracle database software itself. Thanks to licensing restrictions, though, I am unable to give you a handy one-click link to those: you’ll have to get them from either Oracle’s own otn or edelivery sites.

If you have paid-for support, you could obtain the version of the Oracle database: you’ll have files called things like “p10404530_112030_Linux-x86-64_1of7.zip” and “p10404530_112030_Linux-x86-64_2of7.zip”.

If you download the freebie versions from OTN, you’ll have to make do with the version, and you’ll end up with file names like “linux.x64_11gR2_database_1of2.zip” and “linux.x64_11gR2_database_2of2.zip”.

If you do your downloads from edelivery without a paid-for support contract, you’ll again be limited to the version of the database, but this time you’ll end up with file names such as “V17530-01_1of2.zip” and “V17530-0_2of2.zip”.

Since all the versions and file name variations can get confusing, I’m going to suggest that whatever files you download, you rename them to be in the form: oradb-1120x-1of2.zip, where “x” is the relevant bit of the version number. So, having paid-for support, I’m going to end up with oradb-11203-1of2.zip; if I were only able to access OTN freebies, I’d end up with oradb-11201-1of2.zip, and so on.

Once you’ve download and re-named your Oracle files, again burn them onto a virtual DVD iso file, get your toolbox server to mount it, and copy all the zips it contains to the /var/www/html directory. Once there, the zip files will be able to be used by other servers you build that need them.

3. Conclusion

Having done all of the above, when I list the contents of my toolbox server’s /var/www/html directory, here’s what I see:

The “sl” directory (in blue) is there because, you’ll remember, my Kickstart script causes the toolbox to copy its own installation media to disk -and this happens to be a Scientific Linux box.

The four files in red are the little utilities that the toolbox itself, and any server it’s later used to help build, might find useful. Obviously, there are no Oracle database files there yet, but a bit of downloading and renaming as described earlier results in this:

Now you see the 2 Oracle database zip files sitting there (these are the freebie versions, so they’re

The significance of all this? Well, you’ve now got yourself a toolbox that is almost ready to do completely hands-free Oracle installations on other RCSL servers. I’ll explain the extra ingredient needed next time…

Scientifically 6.4

You may have missed the announcement, since it was made just before Good Friday. I was certainly in New Zealand at the time… but, no matter: Scientific Linux 6.4 has been released.

I’ve been using the beta since early March, and I see no significant difference between it and the new, final release. I also don’t see a hell of a lot of difference between SL6.4 and SL6.3 …but that’s about par for the course on RCSL point releases. The change log indicates that some under-the-hood stuff has been improved, though.

Anyway: downloadable at the usual places.