原文: Installing Informix On Linux
Here I'll go through the steps to install the Informix (http://www.informix.com/) RDBMS on Linux.
This guide is based on http://webxpert.wordpress.com/how-to-install-informix-dynamic-server-in-redhat-linux/.
Download Informix
On the informix website go to: Support & Downloads -> Downloads -> Trials and DemosUnder I click on Informix Dynamic Server.
Download either IBM Informix Dynamic Server Express Edition or IBM Informix
Dynamic Server Developer Edition.
Create Informix User and Group
addgroup informix
adduser --ingroup informix informix
Run GUI Installer
Extract the tarball, then as root (with a working X $DISPLAY) run:./ids_install -i console
Choose /home/informix as the installation path.
Do not create the sample database, it will likely fail anyway, we will do that later.
Configure 'informix' User Environment
Log in as the informix user:sudo su - informix
Edit the .bashrc and add the following at the bottom:
export INFORMIXDIR=/home/informix
export INFORMIXSERVER=demo_on
export ONCONFIG=onconfig
export INFORMIXTERM=terminfo
Relogin.重新登录,这里目的其实是为了让环境变量生效。
Configure Informix
Copy etc/onconfig.std to etc/onconfig and make the following changes:--- onconfig.std 2009-04-14 23:02:02.000000000 -0400
+++ onconfig 2010-03-26 04:00:41.000000000 -0400
@@ -40,11 +40,11 @@
###################################################################
ROOTNAME rootdbs
-ROOTPATH $INFORMIXDIR/tmp/demo_on.rootdbs
+ROOTPATH /home/informix/dbspaces/online_root
ROOTOFFSET 0
ROOTSIZE 200000
MIRROR 0
-MIRRORPATH $INFORMIXDIR/tmp/demo_on.root_mirror
+MIRRORPATH /home/informix/mirrors/root_mirror
MIRROROFFSET 0
###################################################################
@@ -123,7 +123,7 @@
# CONSOLE - The path of the IDS console message file
###################################################################
-MSGPATH $INFORMIXDIR/tmp/online.log
+MSGPATH /home/informix/logs/online.log
CONSOLE $INFORMIXDIR/tmp/online.con
###################################################################
@@ -198,7 +198,7 @@
###################################################################
SERVERNUM 0
-DBSERVERNAME
+DBSERVERNAME demo_on
DBSERVERALIASES
###################################################################
@@ -398,7 +398,7 @@
# positive integral multiple of LTAPEBLK.
###################################################################
-LTAPEDEV /dev/tapedev
+LTAPEDEV /dev/null
LTAPEBLK 32
LTAPESIZE 0
Copy etc/sqlhosts.std to etc/sqlhosts and add the following line:
demo_on onipcshm localhost demo_on
Change
localhost to the host name of the machine. (可以通过hostname命令查看服务器name)
Make some directories and files:
cd ~
mkdir dbspaces mirrors logs
cd dbspaces
touch online_root
chmod 660 online_root
Create and start the instance:
oninit -iv
To optionally create a sample database, run
dbaccessdemo7 or
dbaccessdemo9. (这里没有写错,确实有这两个命令)
Starting and Stopping
To start the instance, run:oninit
To stop, run:
onmode -ky
An init script I wrote is here:
http://blog.cachemiss.com/articles/Informix%20Init%20Script.pod
至此,你的数据库已经可以在本地使用了。
Create a Database
The sample database is not created with logging, this makes it not very useful for use with e.g. DBD::Informix.To create a database, first log in as informix and run the dbaccess command.
Go to Database -> Create, type in the name you want; then go to Log -> Buffered_log; then Exit -> Create-new-database .
Configure your User Environment
In your .bashrc or whatever, put:
export INFORMIXDIR=/home/informix
export INFORMIXSERVER=demo_on
export INFORMIXTERM=terminfo
export DBD_INFORMIX_DATABASE=stores_demo
export DELIMIDENT=y
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/informix/lib:/home/informix/lib/esql
export PATH=$PATH:/home/informix/bin
You can now use the dbaccess command as a shell to run SQL queries. Unfortunately, it's a menu-driven program.
Build DBD::Informix for Perl
With the environment set as above, just install DBD::Informix as normally from CPAN. Or just perl Makefile.PL; make; sudo make install. The DBD_INFORMIX_DATABASE environment variable should be set to a database that exists, you have stores_demo if you ran dbaccessdemo7 or 9.Verify that it works:
perl -MDBI -le 'my $dbh = DBI->connect("dbi:Informix:stores_demo", "", ""); print for $dbh->selectrow_array("select today from sysmaster:sysdual")'
Replace stores_demo with the name of the logged database you created earlier.
Setting up TCP Connection Support
This information taken from http://database.itags.org/informix/57440/.Login as the user informix.
Edit etc/onconfig.
Find the DBSERVERALIASES line and change it to:
DBSERVERALIASES hlaghdb_tcp
Edit etc/sqlhosts and add the line:
hlaghdb_tcp onsoctcp localhost informix_tcp
replace localhost with your hostname.
As root, edit /etc/services and add:
informix_tcp 33333/tcp
or whatever port you want to use.
Restart informix:
onmode -ky
oninit
Your DBI DSN becomes:
dbi:Informix:hlaghdb@hlaghdb_tcp
SQL Shell
You can use the dbaccess program to run SQL statements against your DBs, but it's some sort of very cumbersome, ancient terminal GUI.I use the DBI::Shell CPAN module: http://search.cpan.org/perldoc?DBI::Shell.
Unfortunately DBI::Shell does not have history support, so I use rlwrap to add one.
Putting it all together:
alias informix="rlwrap -a -N -t dumb -i -f ~/.informix_dbish_history -H ~/.informix_dbish_history -s 30000 dbish dbi:Informix:hlaghdb@hlaghdb_tcp"
Statements end with ; like in SQL*Plus, use /quit to quit. Readline uses emacs keybindings by default, but you can change this in your ~/.inputrc.