Wednesday, July 9, 2008

Ubuntu under VMware.

How to install VMware tools on Ubuntu:

Click on VM\Install VMware Tools in the main menu of VMware.
The execute the following command in a terminal of you virtual Ubuntu:

cp /cdrom/*.gz /tmp/
cd /tmp
tar xvzf VM*.gz
cd vmware*
sudo ./vmware-install.pl
vmware-toolbox &

Another problem is that mouse wheel scrolling does not work on Ubuntu under VMware.

To fix it you have to edit the following file:

sudo gedit /etc/X11/xorg.conf

Where you have to have the following section:

Section "InputDevice"
Identifier "Configured Mouse"
Driver "vmmouse"
Option "CorePointer"
Option "Device" "/dev/input/mice"
Option "Protocol" "ImPS/2"
Option "Buttons" "5"
Option "ZAxisMapping" "4 5"
EndSection

Then press "Ctrl+Alt+Backspace" for restating the windows system.

Thursday, July 3, 2008

Oracle Identity Management And Internet Directory.

  1. The $ORACLE_HOME/(server_dbname)/sysman/recv/errors directory is filled up by err files.

$ORACLE_HOME/(server_dbname)/sysman/recv/errors directory is filled up by err files.

1. Stop the consoles:
cd $ORACLE_HOME/bin
./emctl stop iasconsole
./emctl stop dbconsole

2. Make a backup of the $ORACLE_HOME/sysman/jlib/emCORE.jar file
cd $ORACLE_HOME/sysman/jlib
cp emCORE.jar emCORE.jar.bkp

3 Replace this jar file by that one of 10.1.0.5.0 version: emCORE.jar

4. Make a copy of the $ORACLE_HOME/bin/emctl.pl file.
cd $ORACLE_HOME/bin
cp emctl.pl emctl.pl.bkp

5. Replace 10.1.0.3.0 to 10.1.0.5.0 in the $ORACLE_HOME/bin/emctl.pl file.
There are three places where this string has to be changed.

6. Start consoles.
cd $ORACLE_HOME/bin
./emctl start iasconsole
./emctl start dbconsole
./emctl status iasconsole
./emctl status dbconsole

How to rebuild a table which occupies the last extend in the data file, and then shrink this file.

We can use the following script for preparing a script for rebuilding the last table in the tablespace, its indices and analyzing all this stuff:

select comm from (
select 3,'ALTER TABLE '||owner||'.'||SEGMENT_NAME||' MOVE TABLESPACE fire_tables;' comm
from (
select owner, segment_name, segment_type, block_id
from dba_extents
where file_id =
( select ddf.file_id
from dba_data_files ddf
where ddf.file_name = '(file name)' )
order by block_id desc ) where rownum = 1
union
select 1,'exec dbms_stats.gather_table_stats(ownname=>'''||owner||''',tabname=>'''||segment_name||''',estimate_percent=>20,cascade=>true);' comm
from (
select owner, segment_name, segment_type, block_id
from dba_extents
where file_id =
( select ddf.file_id
from dba_data_files ddf
where ddf.file_name = '(file name)' )
order by block_id desc ) where rownum = 1
union
select 2,'ALTER INDEX '||idx.owner||'.'||idx.index_name||' REBUILD TABLESPACE fire_indexes online;' comm from
(select owner,SEGMENT_NAME
from (
select owner, segment_name, segment_type, block_id
from dba_extents
where file_id =
( select ddf.file_id
from dba_data_files ddf
where ddf.file_name = '(file name)' )
order by block_id desc )
where rownum = 1) tbs, dba_indexes idx
where idx.table_name=tbs.segment_name and idx.owner=tbs.owner ) order by 1 asc;

After the rebuilding the table you should figure out the block size:

select value from v$parameter where name = 'db_block_size'
/

Then you can execute the script which creates a script for maximum shrinking a required data file:

select 'alter database datafile ''' ||file_name|| ''' resize ' ||
ceil( (nvl(hwm,1)*(db block size))/1024/1024 )||'m;' cmd
from dba_data_files a,
( select file_id, max(block_id+blocks-1) hwm
from dba_extents group by file_id ) b
where a.file_id = b.file_id(+) and
ceil(blocks*(db block size)/1024/1024)-
ceil((nvl(hwm,1)*
(db block size))/1024/1024 ) > 0
/

Then we may increase a size of each data file to 10% if we want.

select 'alter database datafile ''' ||file_name|| ''' resize '||ceil((100+10)*ceil(bytes/1024/1024)/100)||'m;' from dba_data_files;

And then we may set up auto-extend to a size of file plus 2Gb for example:

select 'ALTER DATABASE DATAFILE '''||file_name||''' AUTOEXTEND ON NEXT 5M MAXSIZE '||to_char(bytes+2147483648)||';' from dba_data_files;




How to analyze all tables with theirs indices where statistics is equal to null.

For preparing a script for analyzing all tables with its indices where statistics is equal to null you can use this query:

select 'exec dbms_stats.gather_table_stats( ownname=>''' ||owner||''',tabname=>'''|| table_name||''', estimate_percent=>20,cascade=>true);' comm from dba_tables where last_analyzed is null and owner not in ('SYS','SYSTEM');

How to make a crontab backup.

If we want to make a crontab backup we can insert the following lines into crontab (crontab -e)

#------------------------------------------------------------------------------
# Write out crontab file daily for backup
00 18 * * * $HOME/scripts/crontab_backup.ksh > $HOME/logs/crontab_backup.log 2>&1
#------------------------------------------------------------------------------
# Cleanup files
#
12 07 * * * find $HOME/logs/* -name "*" -mtime +30 -exec rm {} \; > /dev/null 2>&1

Where the $HOME/scripts/crontab_backup.ksh script contains of the following code:

#!/bin/ksh
LOG=$HOME/logs/crontab.`date +%y%m%d_%H:%M`
crontab -l > $LOG
# EOF

How to switch a database into the archive log mode:

In order to switch a database to archivelog mode we can use the following procedure:

shutdown immediate;
startup mount exclusive
alter database archivelog;
archive log start;
startup force;

And to check what is the the archivelog mode status:

SELECT log_mode FROM gv$database;

MISCELLANEOUS

ORACLE TECHNIQUES

INSTALLATION