Tuesday, 27 March 2007

kill the sessions held locks on the dbspace

1.Execute command "onstat -k".It will list out the locks in the database

sv210cwm3% onstat -k

IBM Informix Dynamic Server Version 9.40.UC4X3 -- On-Line -- Up 20:41:00 -- 410624 Kbytes

Locks
address wtlist
owner lklist type tblsnum rowid key#/bsiz
1010efe0 0
151f86f0 0 HDR+S 100002 204 0
1 active, 128000 total, 32768 hash buckets, 0 lock table overflows

2. Get the session id of the userthread which held the lock by grep with owner id "onstat -u | grep 151f86f0"

sv210cwm3# onstat -u | grep 151f86f0

address flags sessid user tty wait tout locks nreads nwrites
151f86f0 Y--P---
472 svplus - 1621a9f8 0 1 0 0

3. Now "472" is the session id.Kill the session using the command "onmode -z 472"

4.Now verify no locks are held on the database by executing "onstat -k "

Sql query to find table having indexes


echo "select tabname from systables where nindexes > 0 and owner ='svplus' " | dbaccess stratacom

Data base size estimation for a table having 1 Crore rows:

Data base size estimation for a table for 1 Crore rows:


Columns

Datatypes

Row Size in bytes

Index key size

timestamp

INTEGER

4

l_node

INTEGER

4

4

slot

SMALLINT

2

2

port

SMALLINT

2

2

vpi

SMALLINT

2

2

vci

INTEGER

4

4

subobject

SMALLINT

2

2

stat

SMALLINT

2

2

bucket

SMALLINT

2

2

total

FLOAT

8

peak

FLOAT

8

40+9 =49

20 + 9 = 29

· Additional 9 bytes for slot entry while write the data to disk

Index size calculation:

Total Index size = 29 bytes

Account for Index Overhead = 36.25 bytes (29*1.25)

Initital table size = 10000000 bytes (1 crore rows)

Total index space needed = 362500000 bytes (36.25* 10000000)

Conversion to KB = 354003.90625 KB (345 MB)

Data size calculation:

Page length in bytes = 2048 – 28 = 2020 bytes **

Row length = 49 bytes

Rows per page = 2020/49 = 41 rows

Noof Datpags for table of 1c row = 243902 Pages (10000000/41) ****

Total pages to store data = 499511296 bytes (476 MB) *******

Approximate total space needed = 476(datasize)+345(index size) = 821 MB

** 28 bytes subtracted for page overhead

**** Total no of rows / rows per page

******* No of Data pages * 2048

To remove a file or Directory

#rm filename (removes a single file)
#rm filename* (removes everything that matches filename. e.g. filename1, filename2, filename.bak)

#rm -rf /home/esofthub/directoryname (the -r deletes directoryname recursively and all its contents)

#rm * ((wildcard *) removes everything within a directory -- make sure you're in the right directory!!)

#rmdir /home/esofthub/directoryname (deletes empty directories)

An Inline Shell Script with a For Loop

You can easily go through a list of items using a for loop. Here's an example of copying selected contents of originalDir to destinationDir via the command line.

#sh
#for i in `cat /home/esofthub/mylist.dat`
#do
#cp -pr /originalDir/$i /destinationDir/.
#echo $i done
#done


sh – shell

cat – lists each item in the list one iteration at a time

cp – the copy utility for a local workstation

-pr – these options preserve the permission and copies recursively

echo – lists the item copied

File Permissions

To change the mode on a file or directory. I prefer the octal (0-7) format.

r -- read (has value of 4)
w -- write (has value of 2)
x -- execute (has value of 1)

rwxrwxrwx chmod 777 filename
rw-rw-rw- chmod 666 filename
r--r--r-- chmod 444 filename
-w--w--w- chmod 020 filename
--x--x--x chmod 001 filename
--------- chmod 000 filename

To make it recursive, use the -R option.

e.g. #chmod -R 777 directoryname

Change User or Group Attributes to a File


For User:

chown username filename
chown username directoryname

chown radha file1.txt

Recursively:
chown -R username directoryname

For Group:
chgrp groupname filename
chgrp groupname directoryname

chgrp radha file1.txt

Recursively:
chgrp -R groupname directoryname
-----
Change groupname and username at the same time.
chown username:groupname filename
Change username and groupname at the same time recursively.
chown -R username:groupname directoryname

My Tech Page