Pages

Saturday, November 5, 2011

Using DB2 from command prompt


you have to connect to a database. To connect to a database, enter the command:
db2 CONNECT TO MAXDB72 USER userID USING password
To connect to a database, and have DB2 prompt you for the password, issue the command:
db2 CONNECT TO MAXDB72 USER userID
To connect to a database using the default user ID, issue the command:
db2 CONNECT TO MAXDB72
select all of the rows from the EMPLOYEE table in the Asset database, issue this command:
db2 "SELECT * FROM employee"

List down all Instances
db2ilist
list down active instances
db2 list active databases
List all databases in an instance
db2 list db directory

Checking db2 running or not

bash-3.00$ netstat  -an | grep 50000
bash-3.00$ ps   -eaf |  grep db2
bash-3.00$ ps   -eaf |  grep db2sysc 

Friday, November 4, 2011

Starting control center in Linux



Execute this command:
$ /opt/ibm/db2/V9.7/bin/db2ilist
Assuming that that command returned "ctginst1", which is the instance name as well as the instance owner, here's how to start Control Center. I will also assume you are logged on to the computer as "wieslawg" and probably sitting at a Gnome desktop environment.
1. Open a terminal. You should be at a prompt with the username "wieslawg". You'll need to allow the instance owner to user your X display. Execute the command:
$ xhost+
2. Open another terminal and su to the instance owner:
$ su - ctginst1
3. Export your display:
$ export DISPLAY=:0.0
4. Start Control Center
$ db2cc
That should be all it takes under the assumptions I have given.


Wednesday, November 2, 2011

Changing Linux Host Name permanently


RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit
/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=”plain.domainname.com”
GATEWAY=”192.168.0.1″
GATEWAYDEV=”eth0″
FORWARD_IPV4=”yes”
Make changes in the /etc/hosts file to make sure that new hostname is getting resolved 
So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME variable.