Thursday, March 27, 2008

Are your tablespaces shrinkable? (oracle)

here is a sql script by Tom Kyte.
if you have problems with sizes of tablespaces you can shrink datafiles. but if there is data at the end of the datafile you cannot shrink them.
with this sql script you can see if you can shrink them.
after running script you should copy the shrink commands and run them..

set verify offcolumn file_name format a50 word_wrappedcolumn smallest format 999,990 heading "SmallestSizePoss."column currsize format 999,990 heading "CurrentSize"column savings format 999,990 heading "Poss.Savings"break on reportcompute sum of savings on report
column value new_val blksizeselect value from v$parameter where name = 'db_block_size'/
select file_name, ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest, ceil( blocks*&&blksize/1024/1024) currsize, ceil( blocks*&&blksize/1024/1024) - ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savingsfrom dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) bwhere a.file_id = b.file_id(+)/
column cmd format a75 word_wrapped
select 'alter database datafile '''file_name''' resize ' ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) 'm;' cmdfrom dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) bwhere a.file_id = b.file_id(+) and ceil( blocks*&&blksize/1024/1024) - ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 0/


http://www.oracle.com/technology/oramag/oracle/04-sep/o54asktom.html

how to take tab delimited export with mysql

you can use mysqldump to take a dump of a table or a database.
when you use the command without a parameter dump is taken with insert statements.

if you want to have a tab delimeted export file you should use --tab paramter with mysqldump.

shell > mysqldump --tab=/path_to_dump_files database table

after this command table.sql and table.txt files will be created. sql for table structure and txt file for data.

Tuesday, March 18, 2008

Using ufsdump for directory backup

you can take incremental backups with ufsdump. here is the usage:

ufsdump 0ucf /pathto/backup/backup_1 /device

what about taking backup of a directory? Of course you can use tar, cpio or cp commands to take backup of a directory. But it might be useful to use ufsrestore command for restoring any corrupted data.

But there is a point, you cannot take incremental backup of directories with ufs dump. this feature is only for devices. so you have to take always zero level backup when you backup a directory.

ufsdump, updates the /etc/dumpdates file to control the backup levels. but it doesn't matter to update this file manual for a directory.

Wednesday, March 5, 2008

Maximum number of files under a directory (Solaris)

- Is there a limit to the number of files under a directory on Solaris OS?
- In fact, there is no such limit. But it is not a good situation if there are thousands of files under a directory. Because, operations like finding, opening, creating and deleting a file are affected as the number of files goes into tens of thousands.
(http://www.sun.com/bigadmin/xperts/sessions/20_jes/#8)

Thursday, February 21, 2008

Learning the Cluster (installation) Type of an Solaris

Solaris OS has various cluster types for installation.
here is the list:

SUNWCrnet Reduced Networking Core System Support
SUNWCreq Core System Support
SUNWCuser End User System Support
SUNWCprog Developer System Support
SUNWCall Entire Distribution
SUNWCXall Entire Distribution plus OEM support

if you want to learn the cluster type of an installed system, you can run this command:

# cat /var/sadm/system/admin/CLUSTER
CLUSTER=SUNWCXall

Wednesday, February 20, 2008

Oracle Client for Linux (rpm)

if you want to connect to a remote oracle database from a linux machine (with net naming services, tnsnames.ora file) you should have oracle client software. you can download this software from oracle official site.
size of the softwares for client and server are so huge. Maybe it is normal for server software but not for client.
But you have an another choice, you can install only 2 rpm files and use sqlplus and oracle client libraries.
total size of these files is 34mb, download url is: http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html

installation:
it is too basic.
rpm -iv oracle-instantclient-basic-10.2.0.3-1.i386.rpm
rpm -iv oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm

after installation you have to set LD_LIBRARY_PATH and add /usr/lib/oracle/10.2.0.3/client/lib. (to see the path of client files:
[root@oracle]# rpm -qlv oracle-instantclient-basic
-rwxr-xr-x 1 root root 39612 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/bin/genezi
-rw-r--r-- 1 root root 18825267 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
-rw-r--r-- 1 root root 5486009 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so
-rw-r--r-- 1 root root 1398088 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libocci.so.10.1
-rw-r--r-- 1 root root 72480394 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libociei.so
-rw-r--r-- 1 root root 120135 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libocijdbc10.so
-rw-r--r-- 1 root root 1545954 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/ojdbc14.jar
)

so, where is tnsnames.ora file?
you can put this file anywhere. it is enough to set TNS_ADMIN shell variable to the directory of tnsnames.ora file.

now you can use sqlplus to connect remote oracle database.

Router Configuration for Solaris

if you want to make router configuration permanent for a solaris machine, you should put the ip or hostname of your router to /etc/defaultrouter file. (ipv4)