Tuesday, January 29, 2013

Auto-Start Standby Database



1. Start Standalone Grid Infrastructure - High Availability Services (HAS)
host > $CRS_HOME/bin/crsctl config has
CRS-4621: Oracle High Availability Services autostart is disabled.
host > $CRS_HOME/bin/crsctl enable has
CRS-4622: Oracle High Availability Services autostart is enabled.

2. Change auto_start to “always” and the default startup mode to “mount”
srvctl modify database -d stndbydb -s mount
crsctl modify resource ora.stndbydb.db –attr “AUTO_START=always”
Test with crs_stat -p

How to Trace SQL in the Current Session

Trace SQL in the current session:

alter session set timed_statistics=true;
alter session set max_dump_file_size=unlimited;
alter session set tracefile_identifier='20Jul2012_special_trace_1';​
alter session set events '10046 TRACE NAME CONTEXT FOREVER,level 12';

..Run some things..

select 'close cursor' from dual; --to dump the rowsource information
alter session set events '10046 trace name context off';


Trace file will be in diag/admin/db_name/instance_name/trace


ASM Debugging Info


ASM Debugging Information

If you have an ASM issue, you'll want these commands handy.

cat /etc/*release
uname -a
rpm -qa|grep oracleasm
/usr/sbin/oracleasm configure
/sbin/modinfo oracleasm
/etc/init.d/oracleasm status​
/usr/sbin/oracleasm-discover
oracleasm scandisks
oracleasm listdisks
ls -l /dev/oracleasm/disks
/sbin/blkid
ls -l /dev/mpath/*
ls -l /dev/mapper/*
ls -l /dev/dm-*

another approach...
1. uname -a
2. rpm -qa | grep oracleasm
3 cat /etc/sysconfig/oracleasm
4. upload /var/log/oracleasm
5. cat /proc/partitions
6. ls -la /dev/oracleasm/disks
7. /etc/init.d/oracleasm scandisks
8. /etc/init.d/oracleasm listdisks
9. Run "sosreport" from command line. That will generate a bzip file. Attach it to SR
10. Send me following command outputs
a. cat /proc/partitions |grep sd|while read a b c d;do echo -n $d$'\t'" scsi_id=";(echo $d|tr -d [:digit:]|xargs -i scsi_id -g -s /block/{})done
b. blkid|grep sd.*oracleasm|while read a b;do echo -n $a$b" scsi_id=";(echo $a|tr -d [:digit:]|tr -d [:]|cut -d"/" -f3|xargs -i scsi_id -g -s /block/{})done;
11. Also you can verify the disk has correct header as follows:
# dd if=/dev/path/to/disk bs=16 skip=2 count=1 | hexdump -C
example:
# dd if=/dev/mapper/data0p1 bs=16 skip=2 count=1 | hexdump -C
1+0 records in
1+0 records out
16 bytes (16 B) copied, 0.037821 seconds, 0.4 kB/s
00000000 4f 52 43 4c 44 49 53 4b 44 41 54 41 30 00 00 00 |ORCLDISKDATA0...|

Reference note: Troubleshooting a multi-node ASMLib installation (Doc ID 811457.1)

RAC - Relocating VIP and SCAN


Failover VIP (on the destination node)
./crs_relocate [vip resource name]

The VIP will now go where it's configured to be

Failover SCAN
srvctl relocate scan -i [LISTENER_NUMBER] -n [DESTINATION_NODE_NAME]

Shared TNSNAMES.ora is not supported



Oracle does not Support Shared tnsnames.ora

SR Reply: "Well, technically there is no official support for UNC (Universal Naming Convention eg. \\path\file) in the tnsnames files. I have seen customers try this and some manage to get it to work and some do not. My tests have always lead to it not working so I personally do not believe those that have claimed it worked when I used the same syntax and it fails.

Officially we do not support it because the values used for UNC are restricted values.


See this link Specifically the //

Those are used by our coding logic for ezconnect connections therefore we have logic in place for those values to be used for a different purpose.
That is just one of the many reasons its not supported not the only reason just an FYI.

So I cannot really provide the proper syntax as it technically does not exist. 
My apologies.

Also so you know technically we do not officially support shared tnsnames files on remote directories.


The ifile and even TNS_ADMIN was designed to handle multiple oracle homes on the same node. It was never intended or supported to work over a network. It does work under most circumstances but is not something we recommended or support. Shared usage over the network we suggest LDAP server as the intended feature to use."

How FULL are the BLOCKS in my TABLE?


Table Block Space Usage:

set serveroutput on size 100000
declare
 v_unformatted_blocks number;
 v_unformatted_bytes number;
 v_fs1_blocks number;
 v_fs1_bytes number;
 v_fs2_blocks number;
 v_fs2_bytes number;
 v_fs3_blocks number;
 v_fs3_bytes number;
 v_fs4_blocks number;
 v_fs4_bytes number;
 v_full_blocks number;
 v_full_bytes number;
 begin
  dbms_space.space_usage (
   '&TABLEOWNER',        --object owner
   '&TABLENAME',         --object name
   'TABLE',              --object type TABLE, INDEX, or "TABLE PARTITION" 
   v_unformatted_blocks,
   v_unformatted_bytes,
   v_fs1_blocks,
   v_fs1_bytes,
   v_fs2_blocks,
   v_fs2_bytes,
   v_fs3_blocks,
   v_fs3_bytes,
   v_fs4_blocks,
   v_fs4_bytes,
   v_full_blocks,
   v_full_bytes
--'&PARTITIONNAME',
);
  dbms_output.put_line('Unformatted Blocks = '||v_unformatted_blocks);
  dbms_output.put_line('FS1 Blocks   = '||v_fs1_blocks);
  dbms_output.put_line('FS2 Blocks   = '||v_fs2_blocks);
  dbms_output.put_line('FS3 Blocks   = '||v_fs3_blocks);
  dbms_output.put_line('FS4 Blocks   = '||v_fs4_blocks);
  dbms_output.put_line('Full Blocks  = '||v_full_blocks);
 end;
/

Sample Output:
Unformatted Blocks = 16
FS1 Blocks   = 42  <--- 0-25% full
FS2 Blocks   = 31  <-- 25-50% full
FS3 Blocks   = 35  <-- 50-75% full
FS4 Blocks   = 4651 <- 75-99% full
Full Blocks  = 99448
 
Shrinking options:
-- Enable row movement.
ALTER TABLE scott.emp ENABLE ROW MOVEMENT;
-- Recover space and amend the high water mark (HWM).
ALTER TABLE scott.emp SHRINK SPACE;
-- Recover space, but don't amend the high water mark (HWM).
ALTER TABLE scott.emp SHRINK SPACE COMPACT;
-- Recover space for the object and all dependant objects.
ALTER TABLE scott.emp SHRINK SPACE CASCADE;

RAC Cluster Name



$CRS_HOME/bin/cemutlo -n