• OEM 05-03-2009 Comments Off

    emca -deconfig dbcontrol db

    and

    emca -config dbcontrol db

  • Database Recovery, RMAN 05-02-2009 Comments Off

    1. Trying to start the database using ’startup’ will fail trying to open the datafile. It will give the datafile number let’s say D.

    2. Make sure we have backups of all the datafiles. In RMAN type:
    REPORT NEED BACKUP REDUNDANCY 1;

    If there are datafiles that were not backed up as yet, there are 2 options:
    a) delete the datafiles. (RMAN will create them and apply their data from redo logs).
    b) issue RMAN command:
    BACKUP DATAFILE N;

    3. Use RMAN to restore and recover the datafile found missing in step #1. The recovery operation will fail because the online redo is missing.
    RESTORE DATAFILE D;
    RECOVER DATAFILE D;

    4. Find the last log sequence:
    SELECT SEQUENCE# FROM V$ARCHIVED_LOG WHERE RECID = (SELECT MAX(RECID) FROM V$ARC
    HIVED_LOG);

    5. Run the following RMAN script. The nunber X will be 1 more than the number you got from step 4. This is because the UNTIL SEQUENCE clause of RMAN goes to one less than the number specified.

    RUN {
    SET UNTIL SEQUENCE X THREAD 1;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    }

  • Backup & Recovery 05-02-2009 Comments Off

    select sequence# from v$archived_log where recid = (select max(recid) from v$archived_log);

  • HACKING 05-01-2009 Comments Off

    1. ran query:
    select VIEW_NAME from ALL_VIEWS WHERE (view_name like ‘V_$%’ or view_name like ‘V$%’) order by view_name; and saved to a text file (/tmp/vdollar.txt)

    2. make a directory to work in:
    mkdir VDOLLAR

    3. change to that directory:
    cd VDOLLAR

    4. use shell to create scripts to login and run
    DESC for each line in above file and save to an individual file:
    for i in `cat /tmp/vdollar.txt `; do (echo “sqlplus / as sysdba << EOF”; echo desc ‘V\$’${i}’;'; echo “EOF”) > $i.sh; done

    5. Now execute all of the scripts:
    for i in `ls *.sh`; do sh $i > $i.txt; done

    6. used perl to parse out the sqlplus header and footer in each of the files, then catt`ed everything together with the #### separators:
    #!/usr/bin/perl

    @files=`ls *.sh.txt`;

    foreach $file (@files){
    chomp $file;
    #print “FILE: $file\n”;
    ($vdollar,undef,undef)=split(’\.’,$file);
    open(IN,”$file”) or die “unable to open $file: $!\n”;
    open(OUT,”>$vdollar.txt”) or die “unable to open $vdollar.txt: $!\n”;
    $inside=’no’;
    $lnum=1;
    print OUT “V\$$vdollar\n”;
    while(<IN>){
    #print “File; $file: LINE: $lnum\n”;
    $l = $_;
    if ( $l =~ /———/ ){
    $inside = ‘yes’;
    }
    elsif ( $l =~ /^$/  && $inside eq ‘yes’ ){
    $inside = ‘no’; last;
    }
    elsif ( $inside eq ‘yes’ ){
    print OUT $l;
    $lnum++;
    }
    }
    close OUT;
    close IN;
    # delete all of the zero line files
    if ( $lnum == 1 ){
    system (”rm -f $vdollar.txt”);
    }
    }

    7. now remove all of the .sh.txt files (used by the perl program):
    rm -f  *.sh.txt

    8. Cat everything together:
    for i in `ls *.txt`; do cat $i; echo; echo ‘#######################################################’; echo; done > /tmp/all.txt

  • Data Dictionary, Documentation 05-01-2009 Comments Off

    contents too big for a post :) see file http://oracle.3dub.com/vdollar.txt

  • Backup & Recovery, RMAN 05-01-2009 Comments Off

    select max(sequence#) from v$archived_logs;

    this can then be used in rman as follows:

    run{
    set until sequence 15 thread 1;
    restore database;
    recover database;
    alter database open resetlogs;
    }

  • Enterprise Manager, OEM 05-01-2009 Comments Off

    emca -deconfig dbcontrol db

    then

    emca -config dbcontrol db

  • BLOCK SIZE 05-01-2009 Comments Off

    You have to setup a cache for the size you want to create if it is different from DB_BLOCK_SIZE initialization parameter like so:

    alter system set db_<N>k_cache_size=<REQUESTED SIZE> scope=BOTH;

  • DBVERIFY, SQLPLUS 05-01-2009 Comments Off

    You may need to get the block size of a datafile before running dbv (DBVERIFY) on it. The following will do this in sqlplus:

    set wrap off
    select t.name tablespace, file#, d.name datafile, block_size BS from v$datafile d join v$tablespace t using (ts#);