Wednesday, 10 February 2010

Oracle Dataguard : Bring standby in line using rman

* ON STANDBY
{noformat}
sqlplus / as sysdba
SQL>startup mount
SQL>select current_scn from v$database;

CURRENT_SCN
-----------
  151214061
{noformat}

* ON LIVE
{noformat}
export ORACLE_SID=FOSDB
. oraenv
$ORACLE_HOME/bin/rman nocatalog
RMAN>connect target DBA_CRON/DBA_CRON
RMAN>backup incremental from scn 151214061 database format '/b01/volbackupfos/FOSDB/201002/ForStandby_%U' tag 'FORSTANDBY';
RMAN>backup current controlfile for standby format '/b01/volbackupfos/FOSDB/201002/ForStandby_ctl.bkp';
scp * oracle@slofosdb01:/u03/volfoslivedata01/oradata/201002
{noformat}
OR - actually did a full backup and transfer
{noformat}
RMAN>backup full database format '/b01/volbackupfos/FOSDB/201002/ForStandby_%U' tag 'FORSTANDBY';
RMAN>backup current controlfile for standby format '/b01/volbackupfos/FOSDB/201002/ForStandby_ctl.bkp';
scp * oracle@slofosdb01:/u03/volfoslivedata01/oradata/201002
{noformat}

{noformat}
* Must stop dataguard or recovery complains cannot get unique lock on files
sqlplus / as sysdba
SQL> alter database recover managed standby database cancel;
{noformat}

* ON STANDBY
{noformat}
$ORACLE_HOME/bin/rman nocatalog
RMAN> connect target DBA_CRON/DBA_CRON
RMAN> shutdown immediate;
RMAN> startup nomount;
RMAN> restore standby controlfile from '/u03/volfoslivedata01/oradata/201002/ForStandby_ctl.bkp';
RMAN> shutdown immediate;
RMAN> startup mount
RMAN> -- Catalog the copied files
RMAN> catalog start with '/u03/volfoslivedata01/oradata/201002/'


RMAN> restore database;
RMAN> recover database noredo;
RMAN> exit
{noformat}

{noformat}
sqlplus / as sysdba
SQL>startup mount
SQL> alter database recover managed standby database disconnect;
{noformat}

* Needed to recreate STANDBY LOGFILEs as named differently from source db
{noformat}
sqlplus / as sysdba
SQL> alter database recover managed standby database cancel;
Database altered.

select 'alter database drop standby logfile group ' group# ';' from v$standby_log;
--Run generated script

--This plus others
ALTER DATABASE ADD STANDBY LOGFILE '/u02/volfoslivelogs01/oradata/FOSDGFOSDB_1srl2.f' SIZE 100M REUSE;
{noformat}

sqlplus / as sysdba
SQL>startup mount
SQL> alter database recover managed standby database disconnect;
{noformat}

Oracle Dataguard : Check status from SQL

--On secondary
select current_scn from v$database

--On primary
select scn_to_timestamp(287481398) from v$database
union all
select scn_to_timestamp(current_scn) from v$database;

If too far apart may need to force log switch on primary

ALTER SYSTEM SWITCH LOGFILE;

Also see
select * from  V$DATAGUARD_STATUS;

Friday, 5 February 2010

Oracle : Rolling sequences forward

declare
dummy number;
begin
    for sq in (
    select sequence_owner||'.'||sequence_name nm
    from dba_sequences
    where sequence_owner
       in ( 'CLIENTDBO','DEALERTOOLS_DBO','GAINDBO','IT_JOB_LOG','MXDBO','MYBROKERDBO',
            'NEWTOPSDBO','ODFSDBO','ODL_DBADMIN_DBO','ODL_DBSERVICES_DBO','ODL_USERAPPS_DBO',
            'PRODUCTDBO','RECONCILIATIONSDBO','SETTLEMENTSDBO','USER_ADMIN_SYS','WEB')
            )
        loop
        dbms_output.put_line(sq.nm);
        for i in 1..10000 loop
           execute immediate 'select  '||sq.nm||'.nextval from dual' into dummy;
        end loop;
    end loop;
end;


Thursday, 28 January 2010

Powershell : Get inner errors for more info (sometimes)

Statement that fails
#                        Trap {
#  write-output "herea"
#  $_.Exception
#  $err = $_.Exception
#  while ( $err.InnerException )
#    {
#    $err = $err.InnerException
#    write-output $err.Message
#    };
#    continue
#  }


Wednesday, 20 January 2010

Powershell : IUnable to install CTP3 - Access Denied Error

Reason was a anti-confickr strategy of adding a permission to stop values being changed in a registry key :
HKLM, Software\Microsoft\Windows Nt\CurrentVersion\Svchost

This has advanced acl perms set to Deny Everyone Set Value



Tuesday, 12 January 2010

Powershell - Performance Diagnostics reports error

When using powershell to query performance counters (via New-Object Diagnostics.PerformanceCounter) getting an errors (The network path was not found)

Fix - Assuming wiondows firewall on the target machine is turned on enable File and Printer Sharing in the exceptions on the target



Sunday, 27 December 2009

Vmware : Vsphere Console Desktop Shortcut

For Vmware infrastructure :
"%PROGRAM_FILES%\VMware\Infrastructure\Virtual Infrastructure Client\4.0\vmware-vmrc.exe" -h 192.168.69.42 -u username -p PASSWORD -d "[datastore1] Ninefingers2/Ninefingers2.vmx"

Add -X for full screen