Monday, July 19, 2010

Initializing Informix Innovator-C on Linux




If you are new to Informix, say this over and over and over again.  Then say it one more time.


Engine initialization is something you do once.  Engine initialization is not the same as starting the engine.

When you initialize an engine you give birth to a new instance.  A previous instance that was occupying the same location as this new instance is overwritten with the data for the new instance.  If you have unintentionally reinitialized an engine, the only way to bring it back is from a restore of your last backup.


oninit -iy instructs Informix to initialize the engine without asking if you're sure you'd like to wipe out any existing instances.  I don't recommend you use the -y option when running oninit, your brain will get used to typing this and you can accidentally wipe out your whole instance without realizing it until it is too late.  I feel queasy just typing that command, even in a blog.



What you will need:

As informix create a directory to hold your dbspace chunks, this is where your data will live on disk.  

When you create a database, table or index in Informix you create it in a dbspace.  Dbspaces are made up of one or more chunks.  Think of chunks as the physical storage and dbspaces as a logical grouping of this physical storage for you to use.  Chunks can be cooked (actual files that are part of the filesystem) or raw (raw disk that is not part of a filesystem).  Raw chunks are typically faster than cooked chunks because they eliminate the overhead of the filesystem.  For this example (and a lot of production systems) cooked is fast enough.


So to review:
  • Chunks define physical storage
  • Dbspaces are made up of one or more chunks
  • You put things in dbspaces
Where were we?  Create a directory to hold your chunks.  Ok, this is not really a requirement, but it does make things look pretty.  You could spread your chunks all over the place if you wanted to, but the only reason you would want to do this would be to spread I/O over multiple disk drives that have different partitions.  We won't get into this yet, just like we won't get into using links to define chunks instead of the actual chunk paths (a common practice that has certain advantages and will be talked about another day.)


I like to create my chunks in /home/informix/chunks, but that's just me.  Make sure your sysadmin or anyone else that might be interested in deleting large files because the filesystem is full knows where your chunks live and he/she shouldn't delete them.  It happens all of the time and you need to restore from a backup to recover from this.


informix> mkdir /home/informix/chunks

To get the engine initialized we only need 1 dbspace, the ROOTDBS and this ROOTDBS will initially only contain 1 chunk.  The ROOTDBS is where Informix keeps all of the housekeeping information that it needs to function.  For now all we need to do is create a file to hold the initial ROOTDBS chunk.  You can name the chunks whatever you like.  I like to use the dbspace name in all caps followed by the chunk number for this dbspace (the first chunks is 01, the second is 02, the third is 03, the 15th is 15, etc.)


informix> touch /home/informix/chunks/ROOTDBS.01


Informix chunks require ownership by user informix and group informix (should already be in place since we created the file as informix) and require read/write permission by user informix and group informix and no public permissions (660).


informix> chmod 660 /home/informix/chunks/ROOTDBS.01
informix> ls -l /home/informix/chunks/ROOTDBS.01
$ ls -l
total 0
-rw-rw---- 1 informix informix 0 2010-07-19 22:38 ROOTDBS.01



As informix create the sqlhosts file to setup connectivity for clients.  

The sqlhosts file serves 2 purposes.  When it is read by the engine at startup the sqlhosts file defines what listening ports the engine should start for client connection requests.  When sqlhosts is read by the client it defines which ports the engine is listening on.  

The standard location for this file is in $INFORMIXDIR/etc/sqlhosts, we'll use this location too.


The structure of the sqlhosts file is 5 columns, with each column separated by whitespace.  Anything following a # sign is treated as a comment.
  • Column 1 is the INFORMIXSERVER, a name for our instance.  We will name our instance blogsvr01
  • Column 2 defines the network protocol used for client communication.  We will use onsoctcp, the value for Socket based TCP connections
  • Column 3 defines the IP address of the server.  You can put the actual IP Address here, use /etc/hosts to map a hostname to the IP address or any other fancy pants networking stuff to map a name to an IP address and put that name here.  We'll use the hostname of blogsvr01
  • Column 4 defines the listening port.  We set this up in an earlier post when we modified /etc/services and named port 1526 idstcp01
  • Column 5 defines any options for this connection.  We won't be using these today so this column will be left blank
informix> vi $INFORMIXDIR/etc/sqlhosts

# blogsvr01 
blogsvr01   onsoctcp    blogsvr01   idstcp01


Now we need to create an ONCONFIG file as informix.  This is the configuration file for the Informix engine.  We will copy the standard config file supplied with the Informix install and modify just a few parameters in order to get the engine initialized.
  • ROOTPATH - Where the ROOTDBS chunk lives, /home/informix/chunks/ROOTDBS.01
  • ROOTSIZE - The size of the ROOTDBS chunk in KB, for no reason at all we will make this 2GB or 2097152
  • DBSERVERNAME - The INFORMIXSERVER name we gave this instance in the sqlhosts file, blogsvr01
That is all that we have to change in the config (even ROOTSIZE is optional with a default value of just under 200MB.)

The ONCONFIG environment variable defines the filename of the config file used for an engine, we will set this up in a second.  I like to name the ONCONFIG file onconfig.servername, or onconfig.blogsvr01 for this example.  The ONCONFIG file must live in $INFORMIXDIR/etc.


informix> cp $INFORMIXDIR/etc/onconfig.std $INFORMIXDIR/etc/onconfig.blogsvr01
informix> vi $INFORMIXDIR/etc/onconfig.blogsvr01 # make changes to ROOTPATH, ROOTSIZE and DBSERVERNAME


OK, we're almost there.  We just have to modify /etc/profile.d/informix.sh to setup the environment variables required by Informix and then we can run oninit -i.  Exciting times, remember you only get to do this once for the life of this instance.


Environment variables that need to be set

root> vi /etc/profile.d/informix.sh

# location of informix install
export INFORMIXDIR=/opt/informix

# add $INFORMIXDIR/bin to PATH for easy execution of Informix commands
export PATH=${INFORMIXDIR}/bin:${PATH}

# I still like to set this env variable even tho we used the default location
export INFORMIXSQLHOSTS=${INFORMIXDIR}/etc/sqlhosts

# the name of our Informix instance, matches sqlhosts and DBSERVERNAME in ONCONFIG
export INFORMIXSERVER=blogsvr01

# define the config filename
export ONCONFIG=onconfig.${INFORMIXSERVER}



Log out and log back in as informix (or run . /etc/profile.d/informix.sh as informix) to set our environment variables.


Now we are ready to initialize the engine.  Remember we only do this once and since it is such a special occasion I like to use the -v (verbose) option of oninit -i to get some extra feedback while the engine initialized.


So, here we go.


informix> oninit -iv


This action will initialize IBM Informix Dynamic Server;
any existing IBM Informix Dynamic Server databases will NOT be accessible -
Do you wish to continue (y/n)? y
Checking group membership to determine server run mode...succeeded
23:28:49  Warning: PDQ functionality is not supported in IDS Innovator-C Edition.
         The value of MAX_PDQPRIORITY cannot be set to 100. It is reset to 0.
Reading configuration file '/opt/informix/etc/onconfig.blogsvr01'...succeeded
23:28:49  Warning: PDQ functionality is not supported in IDS Innovator-C Edition.
         The value of MAX_PDQPRIORITY cannot be set to 100. It is reset to 0.
Creating /INFORMIXTMP/.infxdirs...succeeded
Checking config parameters...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 10574 kbytes...succeeded
Allocating 100016 kbytes for buffer pool of 2K page size...succeeded
Creating infos file "/opt/informix/etc/.infos.blogsvr01"...succeeded
Linking conf file "/opt/informix/etc/.conf.blogsvr01"...succeeded
Initializing rhead structure...succeeded
Writing to infos file...succeeded
Initialization of Encryption...succeeded
Initializing ASF...succeeded
Initializing Dictionary Cache and SPL Routine Cache...succeeded
Bringing up ADM VP...succeeded
Creating VP classes...succeeded
Onlining 0 additional cpu vps...succeeded
Onlining 2 IO vps...succeeded
Forking main_loop thread...succeeded
Initializing DR structures...succeeded
Forking 1 'soctcp' listener threads...succeeded
Starting tracing...succeeded
Initializing 8 flushers...succeeded
Initializing log/checkpoint information...succeeded
Initializing dbspaces...succeeded
Opening primary chunks...succeeded
Opening mirror chunks...succeeded
Validating chunks...succeeded
Creating database partition...succeeded
Initialize Async Log Flusher...succeeded
Starting B-tree Scanner...succeeded
Initializing DBSPACETEMP list...succeeded
Checking database partition index...succeeded
Initializing dataskip structure...succeeded
Checking for temporary tables to drop...succeeded
Forking onmode_mon thread...succeeded
Creating periodic thread...succeeded
Starting scheduling system...succeeded
Verbose output complete: mode = 5



We get some notices about PDQ being configured but not supported in Innovator-C and we get a nice scary warning about engine initialization and viola, the engine is online.  We can run some simple onstat command to look at the engine


Check the online status of the engine via onstat -


informix> onstat -

IBM Informix Dynamic Server Version 11.50.UC7IE -- On-Line -- Up 00:03:57 -- 144148 Kbytes
 

Check the last few lines of the Informix message log via onstat -m
 
informix> onstat -m

IBM Informix Dynamic Server Version 11.50.UC7IE -- On-Line -- Up 00:04:06 -- 144148 Kbytes

Message Log File: /opt/informix/tmp/online.log
23:30:47  Loading Module
23:31:00  Unloading Module
23:31:22  Checkpoint Completed:  duration was 1 seconds.
23:31:22  Mon Jul 19 - loguniq 1, logpos 0xee8018, timestamp: 0xfb33 Interval: 3

23:31:22  Maximum server connections 1
23:31:22  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 11, Llog used 3816

23:31:39  Loading Module
23:31:55  Unloading Module
23:31:57  Logical Log 1 Complete, timestamp: 0x14d15.
23:31:57  Process exited with return code 127: /bin/sh /bin/sh -c /opt/informix/etc/alarmprogram.sh 2 23 "" "Logical Log 1 Complete, timestamp: 0x14d15." ""
23:32:15  Checkpoint Completed:  duration was 0 seconds.
23:32:15  Mon Jul 19 - loguniq 2, logpos 0x1018, timestamp: 0x14d4e Interval: 4

23:32:15  Maximum server connections 1
23:32:15  Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 119, Llog used 1185

23:32:31  Loading Module
23:32:47  Unloading Module
 

Display dbspace and chunk information
 
informix> onstat -d

IBM Informix Dynamic Server Version 11.50.UC7IE -- On-Line -- Up 00:04:09 -- 144148 Kbytes

Dbspaces
address  number   flags      fchunk   nchunks  pgsize   flags    owner    name
4ae5b808 1        0x40001    1        1        2048     N  B     informix rootdbs
 1 active, 2047 maximum

Chunks
address  chunk/dbs     offset     size       free       bpages     flags pathname
4ae5b968 1      1      0          1048576    989343                PO-B- /home/informix/chunks/ROOTDBS.01
 1 active, 32766 maximum

NOTE: The values in the "size" and "free" columns for DBspace chunks are
      displayed in terms of "pgsize" of the DBspace to which they belong.

Expanded chunk capacity mode: always



See that Informix has written data to our ROOTDBS chunk

 
$ ls -l /home/informix/chunks
total 2097156
-rw-rw---- 1 informix informix 2147483648 2010-07-19 23:33 ROOTDBS.01



That's all there is to initializing the engine.


You can shutdown Informix via onmode -k and restart by running oninit with no options.

1 comment:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in IBM INFORMIX TRAINING, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Sangita Mohanty
    MaxMunus
    E-mail: sangita@maxmunus.com
    Skype id: training_maxmunus
    Ph:(0) 9738075708 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete