Personal tools


From Systems Engineering

Jump to: navigation, search


Embed Video

Using embeded videos see for details

Growing Software Raid Mirror

  • Hot add the new disks in this case sdd and sde
  • use from scsitools to find the disks
  • user fdisk to setup disks with a single partition
  • add the first disk as a hot spare
# mdadm --add /dev/md0 /dev/sdd1
  • fail one of the original disks
# mdadm --fail /dev/md0 /dev/sdb1
  • wait for the new disk to be sync'ed
# mdadm --detail /dev/md0


# cat /proc/mdstat
  • remove failed disk
# mdadm --remove /dev/md0 /dev/sdb1
  • repeat for the other disk
# mdadm --add /dev/md0 /dev/sde1
# mdadm --fail /dev/md0 /dev/sdc1
# mdadm --detail /dev/md0
# mdadm --detail /dev/md0
# mdadm --remove /dev/md0 /dev/sdc1
  • Grow the mirror
# mdadm --grow /dev/md0 --size=max
  • finaly grow the filesystem
# resize2fs /dev/md0

Geshi Test

C code

#include "stdio.h"
main () {
  printf("Hello World\n");

PHP code

An exmple of php code taken from

$diary_directory = opendir(".");
  while($filename = readdir($diary_directory))
    $filesplit = explode(".", $filename);
    $check_filename = $filesplit[0];
       if(ereg("[0-9]{6}", $check_filename))
         $check_filename .= ".$filesplit[1]";
         $valid_filename[] = $check_filename;
for($index = 0; $index < count($valid_filename); $index++)

Verilog modules

The basic unit of description in Verilog is the module. A module encapsulates functionality of a block of logic (at any level, from a coarse to a fine grain of detail) and also indicates how it communicates with other external modules through ports. A module is created as an ascii file with a .v extension. A module can embed other modules to create hierarchy.

A module description is enclosed module and endmodule keywords as shown below:

module name (...); // this is a line comment

Within (…) goes a list of ports. For example;

module m1 (a, b, cin); // do not forget ";" here!

Module "m1" has ports a, b, and cin for communication (more on this later).

Module syntax

The basic syntax for a Verilog module is:

module name (port_list);
input, output, inout // port direction
reg, wire, parameter // data types

Simple module example

module xor3 (a, b, c, s);
input  a; 
input  b;
input  c;
output s;
assign s = a ^ b ^ c;

GDM theme variables

%c clock (date and time)
%d timed variable
%h hostname
%m machine type (i686 etc)
%n Short name
%o ? ie (none)
%r release
%s User?

Solaris iSCSI Server

I have two DELL 1950 with two 500Mb disks which I want to turn into iSCSI servers. I want to have a small partion on each disk used as root zpool mirrored and a larger partition on each disk used as to vdev in one zpool. This means that there is no redundance for the data on each server but I "clients" using these serers will mirror the data between the server to give redundancy.

Install Solaris U7 core

The default install did not allow the partition structure I wanted if slecting a zfs root filesystem so I installed on ufs with the root on the larger partion on one disk and swap on the other large partition.

Live upgrade to zfs root

  • Add packages for livupgrade
pkgadd SUNWlucfg SUNWlur SUNWluu
  • Create the new root pool
zpool create rpool c0t0d0s0 c0t1d0s0
  • Create an boot environment on the root pool
lucreate -c ufs -n sol10u7 -p rpool
  • Activate the new boot environment
luactivate -n sol10u7
  • "Reboot" into the new evironment (do not user reboot)
shutdown -i6
  • Remove the old ufs boot environment
ludelete -n ufs

Setup the iscsi pool

  • Install iSCSI target packages
pkgadd SUNWiscsitgtr SUNWiscstgtu
  • Enable the iSCSI initiator service
svcadm enable svc:/network/iscsi_initiator:default
  • Setup the iscsi pool
zpool create c0t0d0s1 c0t1d0s1
  • Enable iscsi sharing
zfs set shareiscsi=on iscsi
  • Remove the mount point to avoid confusion
zfs set mountpoint=none iscsi
  • Create and iscsi share
zfs create -V 800g iscsi/data
  • Check it is being shared
iscsitadm list target


You can use to take an RSS feed to convert rss updates into twitters. You can get and RSS feed from the history of a wiki page. So now changes to a wiki page can generate a twitter.

Tweet Tweet

Does adding a summary of changes help with the tweet?

Installing Eprints 3 using blastwave on Solaris 10

First install blastwave pkg-get as in

Now install ap2_modperl which will cause all the required packages to be install includeing apache2 and perl

% /opt/csw/bin/pkg-get install ap2_modperl

Install mysql5 Or at least the runtime package mysql5rt if the mysql database is on another machine.

% /opt/csw/bin/pkg-get install mysql5

Setup the intial database

% /opt/csw/mysql5/share/mysql/quick_start-csw

Start the service

% svcadm enable cswmysql5

and set the root password

% /opt/csw/mysql5/bin/mysqladmin -u root password 'new-password'
% /opt/csw/mysql5/bin/mysqladmin -u root -h FQDN password 'new-password'

Install GDOME

% /opt/csw/bin/pkg-get instal gdome2

Install extra perl modules

% /opt/csw/bin/pkg-get install pm_unicodestring
% /opt/csw/bin/pkg-get install pm_xmllibxml
% /opt/csw/bin/pkg-get install pm_datashowtbl
% /opt/csw/bin/pkg-get install pm_termreadkey
% /opt/csw/bin/pkg-get install pm_mimelite
% /opt/csw/bin/pkg-get install pm_libwww

The version of xmllibxml is too old and readonly is not available so we have to compile them

% perl -MCPAN -e 'install XML::LibXML'
% perl -MCPAN -e 'install Readonly'

Need to compile XML-GDOME so we need a compiler :-(

% wget
% gzcat XML-GDOME-0.86.tar.gz | tar xvf -
% cd XML-GDOME-0.86/

In order to compile this you need glib2.0 and glib1.2

% /opt/csw/bin/pkg-get install glib
% /opt/csw/bin/pkg-get install glib2

Make sure we have the blastwave perl in the path and gcc

% set path = ( /opt/SUNWspro /opt/csw/bin /opt/csw/gnu $path )
% perl Makefile.PL

Now we need to modify the Makefile as it does not have all the include directories

INC = -I/opt/csw/include -I/opt/csw/include/libgdome -I/opt/csw/include/libxml2 -I/opt/csw/lib/glib-2.0/include -I/opt/csw/lib/glib/include -I/opt/csw/include/glib-2.0
% make
% make install

Note the modification for gdome under Redhat Enterise 4 might help here

Full Text Indexing


Instal xpdf thise seems to require the SUN packages SUNWxwice, SUNWxwfnt SUNWxwrtl SUNWxwplr SUNWxwplt

% /opt/csw/bin/pkg-get install xpdf

Microsoft Word

% /opt/csw/bin/pkg-get install wv2
% /opt/csw/bin/pkg-get install antiword


% /opt/csw/bin/pkg-get install lynx
% /opt/csw/bin/pkg-get install elinks

Latex Tools

tetex require SUNWfmrun

% /opt/csw/bin/pkg-get install tetex
% /opt/csw/bin/pkg-get install imagemagick

Install Eprints

Now we get to the point where we can install eprints (at last).

groupadd eprints
useradd -g eprints -d /opt/eprints -m -c "Eprints user" eprints

Untar the tarball

$ su - eprints
$ gzcat eprints-3.0.3.tar.gz | tar xvf -
$ PATH=/opt/csw/bin:/usr/bin
$ export PATH
$ ./configure --prefix=/opt/eprints

Setup Eprints

# su - eprints
% bin/epadmin create
% bin/generate_views

Coolstack, lighttpd, php and ldap extensions

I am using cooltools 1.2 and was trying to get the ldap extensions to php5 to work with lighttpd

I added ldap extension to php.ini but it would still not show up in phpinfo

The problem appears to be that the can not find the openssl libraries

> ldd /opt/coolstack/php5/lib/php/extensions/no-debug-non-zts-20060613/ => /opt/coolstack/lib/ => /lib/ => /opt/coolstack/lib/ => /opt/coolstack/lib/ => /opt/coolstack/lib/ => /lib/ => /lib/ => /lib/ => /lib/ => /lib/ => /lib/ => (file not found) => (file not found) => /lib/ => /lib/ => /lib/ => /lib/ => /lib/ => /lib/

Setting LD_LIBRARY_PATH fixes this problem.

I modified the lighttpd.conf file to set LD_LIBRARY_PATH

fastcgi.server = ( ".php" =>
 ( "localhost" =>
   "socket" =>
   "bin-path" =>
   "/opt/coolstack/php5/bin/php-cgi -c /etc/coolstack/php.ini",
   "bin-environment" => ("LD_LIBRARY_PATH" => "/usr/sfw/lib")

Coolstack 1.2 and Zones

I prefer runing services inside a Solaris Containers where the files for the service are mounted read-only from the global zone. The new version of Coolstack has SMF support but unfortunatly the configuration files are still under /opt/coolstack.

Here is how I set up a machine to install coolstack in the global zone but run in in a local zone.

Install the base runtime package in the global zone only

pkgadd -G -d CSKruntime_1.2_x86.pkg

Install the amp package but do not setup the service

pkgadd -G -d CSKamp_1.2_x86.pkg

The following packages are available:
  1  CSKapache2     Apache httpd
                    (i386) 2.2.6
  2  CSKmysql32     MySQL 5.0.45 32bit
                    (i386) 5.0.45
  3  CSKphp5        PHP 5
                    (i386) 5.2.4

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:

Processing package instance <CSKapache2> from </mnt/CSKamp_1.2_x86.pkg>

Apache httpd(i386) 2.2.6

Do you also want to configure csk-http service [y,n,?,q] n

Also answer n about configureing the mysql service.



Modify the apache2 httpd.conf file

add the dirtectives

LockFile /var/coolstack/apache2/logs/accept.lock
PidFile /var/coolstack/apache2/run/

Modify the log directives to use full pathnames

ErrorLog /var/coolstack/apache2/logs/error_log
CustomLog /var/coolstack/apache2/logs/access_log common

If you include any files then you need to give the full path name otherwise the file from /opt/coolstack/apache/conf will be included for exmaple

Include /etc/coolstack/apache2/extra/httpd-mpm.conf

insead of

Include conf/httpd-mpm.conf

Change the DoumentRoot and associated Directory directive as appropriate. Personaly I like to have htdocs mounted read-only from the global zone or via NFS.

Setup the service

Now modify the method to work with configuration files under /etc and runtime files under /var. Modify /opt/coolstack/lib/svc/method/svc-cskpache2 to look line this

 . /lib/svc/share/
 [ ! -f ${CONF_FILE} ] &&  exit $SMF_EXIT_ERR_CONFIG
 case "$1" in
         mkdir -p ${PIDDIR}
         chown webservd:webservd ${PIDDIR}
         /bin/rm -f ${PIDFILE}
         ssl=`svcprop -p httpd/ssl svc:/network/csk-http:CSKapache2`
         if [ "$ssl" = false ]; then
                 cmd="start -D SSL"
         echo "Usage: $0 {start|stop|refresh}"
         exit 1
 exec ${APACHE_HOME}/bin/apachectl -f ${CONF_FILE} -k $cmd 2>&1

Import the new service config as follows :

# svccfg -v import /opt/coolstack/lib/svc/manifest/cskapache2.xml

We are now ready to start our service. Start it as follows :

# svcadm -v enable csk-http


I am installing on Solaris x86 and I do not need a large database so I am going to use the 32bit version of mysql. Create the user and group for mysql

# groupadd mysql
# useradd -g mysql mysql

Create the directory for the mysql data

# mkdir -p /var/coolstack/mysql_32bit/data
# chown -R mysql:mysql /var/coolstack/mysql_32bit

Install the database and set the permission

# /opt/coolstack/mysql_32bit/bin/mysql_install_db --datadir=/var/coolstack/mysql_32bit/data
# chown -R mysql:mysql /var/coolstack/mysql_32bit

Modify the file /opt/coolstack/lib/svc/method/svc-cskmysql32

PIDFILE=${DB_DIR}/`/usr/bin/uname -n`.pid

Then import the service:

   # svccfg import /opt/coolstack/lib/svc/manifest/cskmysql32.xml

Before starting MySQL we need to put a config file in /etc. The example small config provided with MySQL is just right for now.

   # cp /opt/coolstack/mysql_32bit/share/mysql/my-small.cnf /etc/my.cnf

Then change the datadir setting in /etc/my.cnf to point to t/var/coolstack/mysql_32bit/data

And make sure it starts:

   # svcadm -v enable csk-mysql32

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands:

/opt/coolstack/mysql_32bit/bin/mysqladmin -u root password 'new-password'
/opt/coolstack/mysql_32bit/bin/mysqladmin -u root -h <FQDN> password 'new-password'

Useful Links

Opus 3.X in a zone

Opus is | Online Placement University System

Untar the opus distribution into a local direcory in the zone I just untar it under /var and then create a link.

cd /var
gzcat /var/tmp/opus_3.3.1.orig.tar.gz | tar xvf -
ln -s opus-3.3.1 opus

An do the same with smarty

tar xf tmp/Smarty-2.6.18.tar
ln -s Smarty-2.6.18 Smarty

Install the php extensions using pear in the global zone

pear install DB
pear install Mail
pear install Mail_Mime
pear install Log

In the zone copy php.ini to /etc/coolstack and modiy the include path


and turn register_globals on :-(

register_globals on

modifiy PHPINIDir in /etc/coolstack/apache2/httpd.conf

PHPINIDir /etc/coolstack

Upgrading Coolstack 1.2 to 1.3 with LiveUpgrade

Upgrade a Solaris 10 U4 box with non global zones with roots on ufs and zfs

Create boot environtment

Since this is the first time live upgrade has been used on this machine we need to name the existing boot environment with the -c option.

lucreate -c CSK1.2 -m /:/dev/dsk/c0t0d0s7:ufs -n CSK1.3

The zones with roots on ufs are on the / partition so they get copied over to the root partition on the new boot environment. Zones with roots on ZFS have new zfs filesystems created but they are not mounted. The will be mounted with the boot environment

lumount -n CSK1.3

Use mount, df or zfs to the see then new zfs's for the zones. Do not forget to unmount the BE

luumount -n CSK1.3

Check the packages that need to be removed

We can check the Coolstack packges in the boot environment with the following command

luupgrade -I -n CSK1.3 | grep CSK

At the moment this is just the same as using pkginfo on the running BE

Remove old packages

luupgrade -P -n CSK1.3 CSKtomcat CSKlighttpd CSKperl CSKphplibs CSKphp5 CSKmysql32 CSKapache2 CSKruntime

Install the new packages

The new version of coolstack will install with zones but since we have existing zones with lofs mounts of /opt/coolstack we still need to use the -G option

luupgrade -p -n CSK1.3 -O "-G"  -s /path/to/packages/CSKruntime_1.3RC1_i386.pkg 
luupgrade -p -n CSK1.3 -O "-G"  -s /path/to/packages/CSKamp_1.3RC1_i386.pkg 
luupgrade -p -n CSK1.3 -O "-G"  -s /path/to/packages/CSKphplibsbundle_1.3RC1_i386.pkg 
luupgrade -p -n CSK1.3 -O "-G"  -s /path/to/packages/CSKperl_1.3RC1_i386.pkg
luupgrade -p -n CSK1.3 -O "-G"  -s /path/to/packages/CSKlighttpd_1.3RC1_i386.pkg 
luupgrade -p -n CSK1.3 -O "-G"  -s /path/to/packages/CSKtomcat_1.3RC1_i386.pkg

WARNING the install process seems to automatically instal the service and this may affect your global zone.