Initialization of IBM Informix Dynamic Server (IDS) and creation of DBspaces.

1 Allocate chunks

On UNIX, you can allocate disk space in two ways:

  • Raw devices: Use unbuffered disk access. When dbspaces reside on raw disk devices (also called character-special devices), the database server uses unbuffered disk access. A raw disk directly transfers data between the database server memory and disk without also copying data.
  • Cooked files: Use files that are buffered through the operating system. While you should generally use raw disk devices on UNIX systems to achieve better performance, you might prefer to use cooked files, which are easier to allocate and manage than raw devices. If you use cooked files, you might be able to get better performance by enabling the Informix® direct I/O option. This requires the library libaio installed on the OS.

Chunks filesystem

It is recommended to have a disk partition exclusively for the chunks (data), mounted on /ifmx1 for example.

Create the following subdirectory for the chunks:

Copy
mkdir /ifmx1/IFMX-CHUNKS

Change owner and group to informix:

Copy
chown informix:informix IFMX-CHUNKS

The DBspaces will be created against symbolic links that point to the cooked files corresponding to the chunks.

Create the following symbolic link:

Copy
ln -s /ifmx1/IFMX-CHUNKS /INFORMIXDEV

2 Onconfig parameter

Copy
ROOTNAME rootdbs
ROOTPATH /INFORMIXDEV/rootdbs
ROOTOFFSET 0
ROOTSIZE 2048000

The ROOTNAME and ROOTPATH are defined acording to the filesytem configuration.

The size of the rootdbs may be small since the data must be located in other DBSpaces

3 Initializing database server manually

Following this steps you can initialize the database server creating the devices, chunks, dbspaces using the command line. The next section shows how to proceed using a shell script.

Create the chunk corresponding to DBspace rootdbs:

Copy
cd /INFORMIXDEV
Copy
touch rootdbs

All chunks must have 660 permissions:

Copy
chmod 660 rootdbs

And both owner and group informix:

Copy
chown informix:informix rootdbs

Follow the same steps to create the chunks corresponding to the following DBspaces:

  • d_llog
  • d_plog
  • d_wics
  • s_wics
  • s_sbstd
  • d_data
  • i_data

Initialize the server as a user informix:

Copy
oninit –iv

Create the DBspaces corresponding to the created chunks, except the rootdbs, with the command onspaces:

Copy
onspaces -c -d d_llog -p /INFORMIXDEV/d_llog -o 0 -s 5000000

A DBspace named d_llog is created against the /INFORMIXDEV/d_llog physical device, with an offset of 0, and a size of 5 GB.

4 Initializing database server using shell script

DEISTER has a shell script that automates the initialization and creation of DBspaces and chunks.

We recommend creating the following directory to save the script:

Copy
mkdir /CONFIG

Create a file named init_ids_<cliente>.sh where <cliente> is the name of the client

Copy
cat > init_ids_deister.sh

And paste the following code:

Copy
#!/bin/bash

NUMLLOGS=40
LLOGSIZE=100000
PHYSSIZE=4000000

# Directory for cooked files. Change it if needed.
DIRCHUNKS=/ifmx1/IFMX-CHUNKS

echo ""; echo "STARTING INITIALIZATION FOR INFORMIX DYNAMIC SERVER (IDS) IN [$INFORMIXDIR] FOR [$INFORMIXSERVER]";
echo ""; echo "REVIEW THIS PARAMETERS NUMLLOGS=[$NUMLLOGS], LLOGSIZE=[$LLOGSIZE], PHYSSIZE=[$PHYSSIZE]";
echo ""; echo "BY DEFAULT USE [${DIRCHUNKS}] AS DIRECTORY FOR THE COOKED FILES FOR THE CHUNKS, YOU CAN CHANGE IT IF NECESSARY.";
echo ""; echo "THIS SHELL SCRIPT USES RAMDISK FOR TEMPORARY DBSPACES, YOU CAN CHANGE IT IF NECESSARY.";
echo ""; echo "IF YOU WANT TO CONTINUE, PLEASE PRESS 'RETURN'. IF NOT, PLEASE CANCEL THE PROCESS:";
read resp

# ----------------------------------------------------------------------
# CHECK USER, MUST BE INFORMIX (NOT ROOT)
# ----------------------------------------------------------------------
if [ "`echo $(whoami)`" != "informix" ]; then
  echo ""; echo "Access denied: only 'informix' can execute this shell"; echo ""
  exit 1
fi

# ----------------------------------------------------------------------
# CHECK IF EXISTS AN INSTANCE ONLINE
# ----------------------------------------------------------------------
if [ "`$INFORMIXDIR/bin/onstat - | grep "not initialized" | wc -l`" != 1 ]; then
  echo ""; echo "ERROR: Exists a running instance in this installation"
  exit 1
fi

# ----------------------------------------------------------------------
# SYMBOLINK LINKS DIRECTORY.
# CHECK /INFORMIXDEV (MUST EXISTS AND informix:informix)
# ----------------------------------------------------------------------
if [ ! -d /INFORMIXDEV ]; then
    echo ""; echo "The /INFORMIXDEV dir must exists and must have 'informix:informix' owner:group"; echo ""
    exit 1
fi

D_USER=`ls -ld /INFORMIXDEV | awk 'NR==1 {print $3}'`
D_GROUP=`ls -ld /INFORMIXDEV | awk 'NR==1 {print $4}'`

if [ "`echo $D_USER`" != "informix" ] || [  "`echo $D_GROUP`" != "informix" ]; then
    echo ""; echo "The /INFORMIXDEV dir must have 'informix:informix' owner:group"; echo ""
    exit 1
fi

# ----------------------------------------------------------------------
# COOKED FILES CHUNKS DIRECTORY
# CHECK ${DIRCHUNKS} (MUST EXISTS AND informix:informix)
# ----------------------------------------------------------------------
if [ ! -d ${DIRCHUNKS} ]; then
    echo ""; echo "The ${DIRCHUNKS} dir must exists and must have 'informix:informix' owner:group"; echo ""
    exit 1
fi

D_USER=`ls -ld ${DIRCHUNKS} | awk 'NR==1 {print $3}'`
D_GROUP=`ls -ld ${DIRCHUNKS} | awk 'NR==1 {print $4}'`

if [ "`echo $D_USER`" != "informix" ] || [  "`echo $D_GROUP`" != "informix" ]; then
    echo ""; echo "The ${DIRCHUNKS} dir must have 'informix:informix' owner:group"; echo ""
    exit 1
fi

# ----------------------------------------------------------------------
# CHUNKS LIST
# dbspace:device:size:type:pagesize
# ----------------------------------------------------------------------
CHUNKS="
rootdbs:${DIRCHUNKS}/rootdbs:2048000

s_sbstd:${DIRCHUNKS}/s_sbstd:4096000:S
s_sbsys:${DIRCHUNKS}/s_sbsys:4096000:S
s_sbtmp:${DIRCHUNKS}/s_sbtmp:4096000:St

d_plog:${DIRCHUNKS}/d_plog:4096000:P
d_llog:${DIRCHUNKS}/d_llog:4096000

t_tmp1:${DIRCHUNKS}/t_tmp1:4096000:t
t_tmp2:${DIRCHUNKS}/t_tmp2:4096000:t
t_tmp3:${DIRCHUNKS}/t_tmp3:4096000:t
t_tmp4:${DIRCHUNKS}/t_tmp4:4096000:t

d_conf:${DIRCHUNKS}/d_conf:4096000:
s_conf:${DIRCHUNKS}/s_conf:4096000:S

d_wics:${DIRCHUNKS}/d_wics:4096000
s_wics:${DIRCHUNKS}/s_wics:4096000:S

d_data:${DIRCHUNKS}/d_data_01:4096000
i_data:${DIRCHUNKS}/i_data_01:4096000
"

# ----------------------------------------------------------------------
# DELETING LINKS IN /INFORMIXDEV
# ----------------------------------------------------------------------
echo "Delete old links in /INFORMIXDEV directory. Please enter 'yes' to continue."

read resp
if [ $resp = "yes" ]; then
    rm -f "/INFORMIXDEV/*"
	if [ $? != 0 ]; then
		echo ""; echo "Can not delete content of /INFORMIXDEV directory"; echo ""
		exit 1
	fi
else
    echo ""; echo "Process cancelled by user"; echo ""
    exit 1
fi

# ----------------------------------------------------------------------
# CREATE FILES AND LINKS FOR THE CHUNKS
# ----------------------------------------------------------------------
echo ""; echo "Creating files and links for the chunks ..."; echo ""
for CHUNK in $CHUNKS; do
        DEV=`echo $CHUNK | awk -F: '{ print $2 }'`
        LNK=`basename $DEV`

        echo "Creating cooked file for chunk [$DEV]"
        echo "Creating symbolic link [/INFORMIXDEV/$LNK]"

        if [ "$DEV" == "/" ]; then
        	echo ""; echo "!!! ERROR: DEVICE IS / (root system path) !!!"; echo ""
        	exit 1
        fi

        if [ ! -f $DEV ]; then
            touch $DEV
        fi

        if [ ! -L /INFORMIXDEV/$LNK ]; then
            ln -s $DEV /INFORMIXDEV/$LNK
        else
        	echo ""; echo "ERROR: LINK [$LNK] already exists"; echo ""
        	exit 1
        fi

        if [ $? != 0 ]; then
        	echo ""; echo "ERROR: The link [/INFORMIXDEV/$LNK] to device [$DEV] can not be created"; echo ""
        	exit 1
        fi

        chown informix:informix /INFORMIXDEV/$LNK
        chown informix:informix $DEV
        chmod 660 $DEV
done

# ----------------------------------------------------------------------
# ENSURE THAT sysadmin DATABASE WILL BE CREATED
# ----------------------------------------------------------------------
echo "Ensuring that sysadmin database will be created removing a possible $INFORMIXDIR/etc/sysadmin/stop file"
rm $INFORMIXDIR/etc/sysadmin/stop

# ----------------------------------------------------------------------
# INITIALIZING DATABASE SERVER
# ----------------------------------------------------------------------
echo ""; echo "Initializing database server ..."; echo ""
echo "Enter 'yes' to initialize Informix IDS"

read resp
if [ $resp = "yes" ]; then
    oninit -iv
    echo ""
    echo "Please wait for the initialization ..."
    echo ""
    sleep 10
else
    echo ""; echo "Process cancelled by user"; echo ""
    exit 1
fi

onmode -BC 2

echo ""
echo "Database initilization is successful. In a few seconds will start the dbspaces and chunks creation ..."
echo ""
sleep 10

# ----------------------------------------------------------------------
# CREATE DBSPACE FROM LIST
# ----------------------------------------------------------------------
echo ""; echo "Creating dbspaces and chunks ..."; echo ""
for CHUNK in $CHUNKS; do
    DBS=`echo $CHUNK | awk -F: '{ print $1 }'`
    DEV=`echo $CHUNK | awk -F: '{ print $2 }'`
    LNK=`basename $DEV`
    SIZE=`echo $CHUNK | awk -F: '{ print $3 }'`
    TYPE=`echo $CHUNK | awk -F: '{ print $4 }'`
    PAGE=`echo $CHUNK | awk -F: '{ print $5 }'`

    if [ -z "$LNK" ]; then
    	echo ""; echo "ERROR: Link for device [$DEV] does not exists"; echo ""
    	exit 1
    fi

    if [ -z "$SIZE" ]; then
    	echo ""; echo "ERROR: Size for chunk [$DEV] is not defined"; echo ""
    	exit 1
    fi

    if [ "$TYPE" = "S" ]; then
         TYPE="-S"
         FLAG=""
         PARAMS="-Df LOGGING=ON"
    elif [ "$TYPE" = "St" ]; then
         TYPE="-S"
         FLAG="-t"
         PARAMS=""
    elif [ "$TYPE" = "t" ]; then
         TYPE="-d"
         FLAG="-t"
         PARAMS=""
    elif [ "$TYPE" = "P" ]; then
         TYPE="-P"
         FLAG=""
         PARAMS=""         
    else
         TYPE="-d"
         FLAG=""
         PARAMS=""
    fi

	# Sets the link always in /INFORMIXDEV
	LNK=/INFORMIXDEV/$LNK

    if [ -z "`echo $DBSPACES | grep $DBS`" ] ; then
      DBSPACES="$DBSPACES $DBS"
      echo "Creating dbspace ..."
      echo "onspaces -c $TYPE $DBS $FLAG -p $LNK -o 0 -s $SIZE $PARAMS"
      onspaces -c $TYPE $DBS $FLAG -p $LNK -o 0 -s $SIZE $PARAMS
    else
      echo "Adding a chunk ..."
      echo "onspaces -a $DBS -p $LNK -o 0 -s $SIZE"
      onspaces -a $DBS -p $LNK -o 0 -s $SIZE
    fi

done

ontape -s -L 0 -t /dev/null

# ----------------------------------------------------------------------
# CREATE LOGICAL LOGS
# ----------------------------------------------------------------------
echo ""; echo "Creating [$NUMLLOGS] logical logs of [${LLOGSIZE}KB]..."; echo ""
for i in `seq 1 $NUMLLOGS`; do
    onparams -a -d d_llog -s $LLOGSIZE
done

ontape -s -L 0 -t /dev/null


# ----------------------------------------------------------------------
# SHOW DBSPACES
# ----------------------------------------------------------------------
onstat -d

Give him execution permissions:

Copy
chmod +x init_ids_deister.sh

The default dbspaces and chunks layout that comes in the script is:

Copy
rootdbs:/ifmx1/IFMX-CHUNKS/rootdbs:2048000

s_sbstd:/ifmx1/IFMX-CHUNKS/s_sbstd:4096000:S
s_sbsys:/ifmx1/IFMX-CHUNKS/s_sbsys:4096000:S
s_sbtmp:/ifmx1/IFMX-CHUNKS/s_sbtmp:4096000:St

d_plog:/ifmx1/IFMX-CHUNKS/d_plog:4096000
d_llog:/ifmx1/IFMX-CHUNKS/d_llog:4096000

t_tmp1:/ramdisk/t_tmp1:4096000:t
t_tmp2:/ramdisk/t_tmp2:4096000:t
t_tmp3:/ramdisk/t_tmp3:4096000:t
t_tmp4:/ramdisk/t_tmp4:4096000:t

d_conf:/ifmx1/IFMX-CHUNKS/d_conf:4096000:
s_conf:/ifmx1/IFMX-CHUNKS/s_conf:4096000:S

d_wics:/ifmx1/IFMX-CHUNKS/d_wics:4096000
s_wics:/ifmx1/IFMX-CHUNKS/s_wics:4096000:S

d_data:/ifmx1/IFMX-CHUNKS/d_data_01:4096000
i_data:/ifmx1/IFMX-CHUNKS/i_data_01:4096000

You have to modify the layout by adding more chunks arding to the volume and nature of the data that the server will store.

At this point you can already execute the initialization shell script, as user informix:

Copy
./ifmx_init_deister.sh