Pages

Monday, September 12, 2022

Flashback only standby database - 19c Dataguard

 ### On Primary: (before simulation)

SQL> select name, switchover_status,flashback_on from v$database;

SQL> alter system archive log current;

------------------------------------------------------------

### On Standby: (before simulation)

SQL> SET NUMFORMAT 999999999999999999
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;  
SQL> select name, time, scn from v$restore_point;
SQL> CREATE RESTORE POINT BEFORE_SIMULATION GUARANTEE FLASHBACK DATABASE; 
SQL> select name, time, scn from v$restore_point;
SQL> STARTUP MOUNT FORCE;

SQL> col space_limit for 999999999999999999999
SQL> col space_used for 999999999999999999999
SQL> select space_limit/1024/1024/1024 avail_GB, space_used/1024/1024/1024 Used_GB from v$recovery_file_dest;

SQL> col name for a20
SQL> col time for 999999999999999999999999999999
SQL> col time for a35
SQL> select name, time, scn from v$restore_point;

?SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT; 
(if recovery needs to continue)


------------------------------------------------------------


### On Standby: (DR simulation invoked..)


?SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; 
(if recovery needs to be cancelled)
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;
SQL> STARTUP MOUNT FORCE;
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
SQL> ALTER DATABASE OPEN;
SQL> select open_mode, database_role from v$database;
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=DEFER;

SQL> select scn_to_timestamp(STANDBY_BECAME_PRIMARY_SCN) from v$database;

------------------------------------------------------------

### On Primary:
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=DEFER;


### Handover to application team for testing DR Standby....

------------------------------------------------------------


### On Standby: (after bcp test - recovery / rollback)

SQL> select current_scn, standby_became_primary_scn from v$database;

        CURRENT_SCN STANDBY_BECAME_PRIMARY_SCN
------------------- --------------------------
     13223120496345             13222215208347

SQL> STARTUP MOUNT FORCE;
SQL> select name, time, scn from v$restore_point;
SQL> FLASHBACK DATABASE TO RESTORE POINT BEFORE_SIMULATION;

SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
SQL> STARTUP MOUNT FORCE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

SQL> drop restore point before_simulation;

------------------------------------------------------------

### On Primary: (after bcp test - recovery / rollback)

SQL> alter system set log_archive_dest_state_2=enable;
SQL> alter system switch logfile;

------------------------------------------------------------

### make sure restore point is dropped..!


END.


Saturday, January 2, 2021

The listener supports no services


New listener or new database cloned, listener not registered.


LSNRCTL> status

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.20.27.134)(PORT=1526)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER11

Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production

Start Date                02-JAN-2021 21:43:33

Uptime                    0 days 0 hr. 0 min. 33 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /app/oracle/product/11.2.0.2/dbhome_1/network/admin/listener.ora

Listener Log File         /app/oracle/diag/tnslsnr/prjutyu01/listener11/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.20.27.134)(PORT=1526)))

The listener supports no services

The command completed successfully

LSNRCTL> 




Solution:

    (To register the listener with database)

SQL> alter system set local_listener='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.20.27.134)(PORT=1526)))' scope=both;


SQL> alter system register; 



Tuesday, December 15, 2020

xclock dbca PuTTY X11 proxy: Authorisation not recognised

PuTTY X11 proxy: Authorisation not recognised

Error: Can't open display: localhost:10


Error:


[dbadmin53@brvmoracle ~]$ sudo su - oracle

Last login: Wed Dec 16 09:43:51 +03 2020 on pts/0

[oracle@brvmoracle ~]$ xclock

PuTTY X11 proxy: Authorisation not recognised

Error: Can't open display: localhost:10


or 


[oracle@brvmoracle ~]$ dbca

PuTTY X11 proxy: Authorisation not recognised

Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:264)

        at java.awt.Toolkit$2.run(Toolkit.java:860)

        at java.awt.Toolkit$2.run(Toolkit.java:855)

        at java.security.AccessController.doPrivileged(Native Method)

        at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)

        at com.jgoodies.looks.LookUtils.isLowResolution(LookUtils.java:484)

        at com.jgoodies.looks.LookUtils.<clinit>(LookUtils.java:249)

        at com.jgoodies.looks.plastic.PlasticLookAndFeel.<clinit>(PlasticLookAndFeel.java:135)

        at java.lang.Class.forName0(Native Method)

        at java.lang.Class.forName(Class.java:348)

        at javax.swing.SwingUtilities.loadSystemClass(SwingUtilities.java:1874)

        at javax.swing.UIManager.setLookAndFeel(UIManager.java:582)

        at oracle.install.commons.util.Application.startup(Application.java:917)

        at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)

        at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:198)

        at oracle.assistants.common.base.driver.AssistantApplication.startup(AssistantApplication.java:320)

        at oracle.assistants.dbca.driver.DBConfigurator.startup(DBConfigurator.java:342)

        at oracle.assistants.dbca.driver.DBConfigurator.main(DBConfigurator.java:386)

[oracle@brvmoracle ~]$


Reason:


Switching from 'dbadmin53' user to 'oracle' user - causing the error.

Try login with oracle user directly from putty.


Wednesday, August 12, 2020

ping multiple ip addresses from windows PowerShell script cmd

### save iplist in a txt file as "iplist.txt"

### save the script as "PingIP.ps1" ( powershell script )

### rightclick and choose "Run with PowerShell"


$names=Get-content "D:\tasks\Ping\iplist.txt"

foreach($name in $names){

if(Test-Connection -ComputerName $name -Count 2 -ErrorAction SilentlyContinue){

Write-Host "$name is up" -ForegroundColor Green

$output+="$name is up,"+"`n"

}

else{

Write-Host "$name is --------&gt; down" -ForegroundColor Red

$output+="$name is --------&gt; down,"+"`n"

}

}

$output | Out-File "D:\tasks\Ping\result.txt"

Start-Sleep -s 30



### iplist.txt ( without tab or space at end of line)

172.21.80.3

172.21.80.4

172.21.80.60

172.21.80.61

172.21.11.115

172.21.11.43

172.21.30.5

localhost



### result.txt ( looks like below )

172.21.80.3 is up,
172.21.80.4 is up,
172.21.80.60 is --------> down,
172.21.80.61 is up,
172.21.11.115 is up,
172.21.11.43 is up,
172.21.30.5 is up,
localhost is up,

Wednesday, June 6, 2018

sample waiting script, waits for 60 minutes and fails after that.


sample script


okFile=okay.ok
bFlagFound=false
waitCounter=0

while [ "$bFlagFound" = "false" ]; do
        if [ -e $okFile ]; then
                bFlagFound=true
        else
                sleep 60
                waitCounter=$(($waitCounter + 1))
                if [ $waitCounter -gt 60 ]; then
                        echo "$okFile flag not found, after waiting 60 minutes"
                        exit 1
                fi
        fi
done




echo "task 1"
echo "task 2"



Sunday, December 10, 2017

SQL Query to fetch dataguard sync status after resetlogs

SQL Query to fetch dataguard sync status after reset logs


You may run both the below query on Primary site:


select 'PROD = '||max(a.sequence#) from v$archived_log a join v$database_incarnation b using (resetlogs_id) where b.status = 'CURRENT';

select 'DR   = '||max(a.sequence#) from v$archived_log a join v$database_incarnation b using (resetlogs_id) where b.status = 'CURRENT' and a.applied= 'YES';


The result should look like below:


PROD = 91678
  

DR   = 91678




----

Sunday, November 19, 2017

[SOLVED] - RMAN-03002 RMAN-12009 RMAN-12017

RMAN-03002 RMAN-12009 RMAN-12017

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/24/2017 21:25:09
RMAN-12009: command aborted because some backup pieces could not be located
RMAN-12017: could not locate pieces of backup set key 10400



Issue:


RMAN> catalog start with '/backup1/rman/';
RMAN> recover database;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/24/2017 21:25:09
RMAN-12009: command aborted because some backup pieces could not be located
RMAN-12017: could not locate pieces of backup set key 10400



Solution:


RMAN> catalog backuppiece '/backup1/rman/1_gtmh8n3v_20110712.rmb';
RMAN> recover database;


Note: Catalog backup piece manually.

Tuesday, November 8, 2016

iperf - Network Bandwidth calculator between two servers

Network Bandwidth calculator between two servers - iperf


Download the rpm/software from the website: https://iperf.fr/

Direct Download link for Redhat: https://iperf.fr/download/fedora/iperf3-3.1.3-1.fc24.x86_64.rpm


Install on both source and destination servers.
normally no dependency rpm.you can remove the rpm after test.
[root@hsb-dr-ora-test ~]# rpm -ivh iperf3-3.1.3-1.fc24.x86_64.rpm

[root@hsb-hq-ora-test ~]# rpm -ivh iperf3-3.1.3-1.fc24.x86_64.rpm

Below command listens for the port 1522: (choose ports that is not used)

[root@hsb-dr-ora-test ~]# iperf -s -p 1522
------------------------------------------------------------
Server listening on TCP port 1522
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 172.166.0.166 port 1522 connected with 172.199.0.166 port 59973
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.7 sec  2.75 MBytes  2.15 Mbits/sec
[  5] local 172.166.0.166 port 1522 connected with 172.199.0.166 port 59979
[  5]  0.0-10.7 sec  3.25 MBytes  2.55 Mbits/sec
[root@hsb-dr-ora-test ~]#


Below command transfers packet on port 1522:

[root@hsb-hq-ora-test ~]# iperf -c 172.166.0.166 -p 1522
------------------------------------------------------------
Client connecting to 172.166.0.166, TCP port 1522
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 172.199.0.166 port 9927 connected with 172.166.0.166 port 1522
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.5 sec  2.88 MBytes  2.29 Mbits/sec
[root@hsb-hq-ora-test ~]# 


Options used above:
 -s (running as server)
 -c (running as client)
 -p (port to check)

Sunday, March 20, 2016

oracle-rdbms-server-12cr1-preinstall redhat

Preinstall rpm for Oracle 12c database on RHEL 7


[root@linux7 tmp]# yum install bind-utils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc-devel kernel-uek ksh libaio libaio-devel libstdc++-devel nfs-utils psmisc smartmontools sysstat xorg-x11-utils xorg-x11-xauth


Note: You should have yum repository configured for this above command to work. 



You can download the actual rpm for OL7 below:

http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-rdbms-server-12cR1-preinstall-1.0-4.el7.x86_64.rpm

Monday, June 23, 2014

Simulating ORA-errors or How to write custom message to Oracle alert log file

To test monitoring script or monitoring tool: Simulating ORA-errors


Writes to alert log:


SQL> exec dbms_system.ksdwrt(2, 'ORA-600: TEST :Check alert log');

PL/SQL procedure successfully completed.

Writes to trace file:


SQL> exec dbms_system.ksdwrt(1, 'ORA-600: TEST :Check udump');

PL/SQL procedure successfully completed.

Writes to alert log and trace file:


SQL> exec dbms_system.ksdwrt(3, 'ORA-600: TEST :Check alert log and udump');

PL/SQL procedure successfully completed.


Your alert log should look something like this:


Mon May 23 10:36:03 2014
ORA-600: TEST :Check alert log
Mon May 23 10:36:13 2014
ORA-600: TEST :Check alert log and udump

Your trace file should look something like this:

*** 2014-05-23 10:21:11.096
*** SERVICE NAME:(SYS$USERS) 2014-05-23 10:21:11.080
*** SESSION ID:(317.26206) 2014-05-23 10:21:11.080
*** 2014-05-23 10:35:53.782
ORA-600: TEST :Check udump
*** 2014-05-23 10:36:13.704
ORA-600: TEST :Check alert log and udump

Wednesday, December 4, 2013

How to get Windows version from command line of remote servers

How to get windows version from command line of remote server ?



For one server:

D:\> reg query "\\172.69.0.79\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
    ProductName    REG_SZ    Windows Server 2008 R2 Enterprise

NoteLogin to your client PC as domain user with local administrator privilege.




For multiple servers: (content republished, Source here)

Save the below code as a batch file:


REM Check OS Version on a remote server
@echo Off
pushd %~dp0
for /f %%a in (serverlist.txt) do (
Echo %%a is checked
reg query "\\%%a\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName

) >> OS_version_query_result.txt


In the same folder location of batch file, place the serverlist.txt file.
Just type one host name per line without any trailing space.

serverlist.txt read as below:

phygrsrv01
phyaprsrv01
172.36.88.101
10.1.0.122

Now execute the batch file, it creates a output file in the same location.

Monday, December 2, 2013

Manually Move + Delete Archive log [Windows]


### Below command deletes files ARC*.* from F:\Oracle_Arc with date older than 7 days:

FORFILES /P F:\Oracle_Arc /M ARC*.* /D -7 /C "cmd /c del @path"


### Below Command moves files ARC*.* from D:\Logs to F:\Arc with date older than 2 days: 

FORFILES /P D:\Logs /M ARC*.* /D -2 /C "cmd /c move @path F:\Arc"


ORA-08181 ORA-06512: at "SYS.SCN_TO_TIMESTAMP"

Version: 11.2.0.3

SQL> select name, open_mode, database_role from v$database;

NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
HSB62 READ ONLY PHYSICAL STANDBY

SQL> select scn_to_timestamp(current_scn) scn_sync_until from v$database;
select scn_to_timestamp(current_scn) scn_sync_until from v$database
*
ERROR at line 1:
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1



OR


SQL> select current_scn from v$database;

CURRENT_SCN
--------------------
10588754037


SQL> select scn_to_timestamp(10588754037) scn_sync_until from v$database;
select scn_to_timestamp(10588754037) scn_sync_until from v$database
*
ERROR at line 1:
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1



Workaround: To bounce the database and flush shared pool (doesn't worked for me..!)


Conclusion / Solution:

Bug 17214565.

There is no fixes for this bug currently.

The issue seems to be resolved in 12c.





Monday, July 22, 2013

how to get ping result with timestamp ?

# ping 172.11.23.103 | while read pong; do echo "$(date): $pong"; done >> /tmp/pingtest103.log


Tue Jul 23 09:04:33 AST 2013: PING 172.11.23.103 (172.11.23.103) 56(84) bytes of data.
Tue Jul 23 09:04:33 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=21 ttl=64 time=0.137 ms
Tue Jul 23 09:04:34 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=22 ttl=64 time=0.100 ms
Tue Jul 23 09:04:35 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=23 ttl=64 time=0.144 ms
Tue Jul 23 09:04:36 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=24 ttl=64 time=0.112 ms
Tue Jul 23 09:04:37 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=25 ttl=64 time=0.122 ms
Tue Jul 23 09:04:38 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=26 ttl=64 time=0.136 ms
Tue Jul 23 09:04:39 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=27 ttl=64 time=0.097 ms
Tue Jul 23 09:04:40 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=28 ttl=64 time=0.201 ms
Tue Jul 23 09:04:41 AST 2013: 64 bytes from 172.11.23.103: icmp_seq=29 ttl=64 time=0.115 ms



After 16 hours:

# ls -lrth /tmp/pingtest103.log

-rw-r--r-- 1 root root 8.5M Jul 24 01:09 /tmp/pingtest103.log


Monday, July 15, 2013

How to take RMAN Disk backup while Tape backup is configured ? [ TESTED ]


The below script overrides the DEFAULT DEVICE TYPE for backup.



RMAN> SHOW DEFAULT DEVICE TYPE;

RMAN configuration parameters for database with db_unique_name HSBC12 are:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';

RMAN> run
{
backup AS COMPRESSED BACKUPSET device type disk database 
format '/ora/dbbkp/DB_%d_%t_%s_%p' plus archivelog format '/ora/dbbkp/Archive_%d_%U';
backup AS COMPRESSED BACKUPSET device type disk current controlfile tag =cf1 
format '/ora/dbbkp/ctrlfile_%t_%s_p%p.dbf';
backup AS COMPRESSED BACKUPSET device type disk spfile 
format '/ora/dbbkp/Manual_spfile_%t_%s_p%p.dbf';




Sunday, May 26, 2013

how to check data guard is in sync?


### How to check data guard is in sync?

On Standby:


SQL> col CURRENT_SCN for 9999999999999999999

SQL> SELECT SCN_TO_TIMESTAMP(CURRENT_SCN) SYNC_UNTIL FROM V$DATABASE;

SYNC_UNTIL
---------------------------------
26-MAY-13 02.00.38.000000000 PM

SQL>

































Data Guard - How To Check Whether Physical Standby is in Sync with the Primary or Not?



Summary:


1. Check for GAP on standby
2. Check redo received on standby
3. Check redo applied on standby
4. Identify missing archive log files
5. Copy archive log files
6. Register archive log files with standby
7. Restart the managed recovery operations


step 1. Check for GAP on standby

-----------------------------------------------------------------------------------------------
primary + standby > select max(sequence#) from v$log_history;

primary > SELECT THREAD# "Thread",SEQUENCE# "Last Sequence Generated"
          FROM V$ARCHIVED_LOG
          WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)
          ORDER BY 1;
-----------------------------------------------------------------------------------------------


step 2 and 3. Check redo received on standby and Check redo applied on standby

-----------------------------------------------------------------------------------------------
standby > SELECT ARCH.THREAD# "Thread", ARCH.SEQUENCE# "Last Sequence Received", APPL.SEQUENCE# "Last Sequence Applied", (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
          FROM
         (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
         (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
         WHERE
         ARCH.THREAD# = APPL.THREAD#
          ORDER BY 1;
-----------------------------------------------------------------------------------------------


step 4. Identify missing archive log files

-----------------------------------------------------------------------------------------------
-- if GAP
standby > SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
-----------------------------------------------------------------------------------------------


step 5.  Copy archive log files

-----------------------------------------------------------------------------------------------
After identifying a gap (as shown above), the DBA will need to query the primary database
to locate the archived redo logs on the primary database. The following query assumes the
local archive destination on the primary database is LOG_ARCHIVE_DEST_1:

primary > SELECT name
            FROM v$archived_log
            WHERE thread# = 1
              AND dest_id = 1
              AND sequence# BETWEEN 09464 and 90468;
-----------------------------------------------------------------------------------------------


step 6. Register archive log files with standby

-----------------------------------------------------------------------------------------------
--  Copy the above redo log files to the physical standby database and register
    them using the ALTER DATABASE REGISTER LOGFILE ... SQL statement on the
    physical standby database.
 
    For example:

standby > ALTER DATABASE REGISTER LOGFILE '/u04/arch/HSBC33/arch_t1_s64.dbf';
standby > ALTER DATABASE REGISTER LOGFILE '/u04/arch/HSBC33/arch_t1_s65.dbf';
standby > ALTER DATABASE REGISTER LOGFILE '/u04/arch/HSBC33/arch_t1_s66.dbf';
standby > ALTER DATABASE REGISTER LOGFILE '/u04/arch/HSBC33/arch_t1_s67.dbf';
standby > ALTER DATABASE REGISTER LOGFILE '/u04/arch/HSBC33/arch_t1_s68.dbf';
-----------------------------------------------------------------------------------------------


step 7. Restart the managed recovery operations

-----------------------------------------------------------------------------------------------
-- After the redo logs have been registered on the physical standby database,
   the DBA can restart the managed recovery operations.

   For example, to put the physical standby database into automatic recovery managed mode:

standby > alter database recover managed standby database disconnect from session;
-----------------------------------------------------------------------------------------------


Tuesday, March 5, 2013

How to check RECOVER MANAGED STANDBY DATABASE real time apply?



### On Standby: Delayed apply or Real time apply?


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DELAY 60 disconnect; -- apply delayed for 60 minutes.

Database altered.

SQL> SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS;

RECOVERY_MODE
-----------------------
MANAGED
IDLE
IDLE
IDLE
...


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE disconnect; -- Realtime apply

Database altered.

SQL> SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS; 

RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY
IDLE
IDLE
IDLE
...



-- no time delay
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT; 

-- no time delay
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE NODELAY DISCONNECT;

-- 60 minutes delay
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DELAY 60 DISCONNECT;

-- real time apply
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;


--- Note: -----------------------------------------------------------------------------------

By default, apply services wait for the full archived redo log file to arrive on the standby database before applying it to the standby database.

If the real-time apply feature is enabled, apply services can apply redo data as it is received, without waiting for the current standby redo log file to be archived.





Saturday, February 23, 2013

ORA-39083 ORA-02063 Object type VIEW failed to create with error


ORA-39083: Object type VIEW failed to create with error:
ORA-02063: preceding 5 lines from HSBC26

face above error during impdp? this means your impdp tries to import the statistics to an remote database through an dblink.


Solution:

exclude=STATISTICS while expdp or impdp

or

set HS_FDS_SUPPORT_STATISTICS=FALSE in the init.ora

Note: In my case, I hit this error, when impdp is trying to create a view, which has a base table on remote database. 


impdp log snippet:

Failing sql is:
CREATE  FORCE VIEW "PLOANS"."CLIENT_TYPE" ("ITEM_CODE") AS select "SYMBOL_CODE" from  CUST_001.CLIENT_SUMMARY@HSBC26

ORA-39083: Object type VIEW failed to create with error:
ORA-02063: preceding 5 lines from HSBC26




Saturday, February 9, 2013

how to tar a directory [ tested ] Linux


### Tar and compress a directory: 

[ includes sub-directories and files ]

For example: 

[oracle@oradb1 ~]$ echo $ORACLE_HOME 
/u01/app/product/11.2.0/dbhome_1

[oracle@oradb1 ~]$ cd /u01

[oracle@oradb1 u01]$ tar -pczf OH_backup.tar.gz app/



### Untar and uncompress:

[oracle@oradb1 ~]$ cd /u01

[oracle@oradb1 u01]$ tar xvfz OH_backup.tar.gz



### Tar multiple files:

[oracle@oradb1 bkp] tar -pczf dump2012.tar.gz psm_full.dmp psm_full.log qsm_full.dmp qsm_full.log 



### How do I untar ?

[oracle@oradb1 bkp] tar xvfz dump2012.tar.gz




Wednesday, February 6, 2013

how to move datafiles in oracle 11g

Move or Rename datafiles: Steps same in 10g or 11g

C:\> rman target /

RMAN> REPORT SCHEMA;

using target database control file instead of recovery catalog
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace   RB segs Datafile Name
---- -------- ------------ ------- ------------------------
1    1320     SYSTEM       ***     D:\ORADATA\HSBC\SYSTEM01.DBF
3    860      SYSAUX       ***     D:\ORADATA\HSBC\SYSAUX01.DBF
4    7681     USERS        ***     D:\ORADATA\HSBC\USERS01.DBF
5    5864     UNDOTBS01    ***     D:\ORADATA\HSBC\UNDOTBS1.DBF
6    6219     USERS        ***     C:\ORACLE\PRODUCT\10.2.0\ORADATA\HSBC\USERS02.DBF
9    2281     INDX01       ***     D:\ORADATA\HSBC\INDX01.DBF
10   2719     USER01       ***     D:\ORADATA\HSBC\USER01.DBF

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- ---------- ----------- --------------------
1    4229      TEMP      32767       D:\ORADATA\HSBC\TEMP01.DBF

RMAN>

RMAN> SQL 'ALTER TABLESPACE USERS OFFLINE';

RMAN> COPY DATAFILE 6 TO 'D:\ORADATA\HSBC\USERS02.DBF';

RMAN> SWITCH DATAFILE 6 TO COPY;

RMAN> RECOVER TABLESPACE USERS; 

RMAN> SQL 'ALTER TABLESPACE USERS ONLINE';

RMAN> HOST 'del C:\ORACLE\PRODUCT\10.2.0\ORADATA\HSBC\USERS02.DBF';

RMAN> REPORT SCHEMA;

using target database control file instead of recovery catalog
Report of database schema

List of Permanent Datafiles
===========================
File Size(MB) Tablespace   RB segs Datafile Name
---- -------- ------------ ------- ------------------------
1    1320     SYSTEM       ***     D:\ORADATA\HSBC\SYSTEM01.DBF
3    960      SYSAUX       ***     D:\ORADATA\HSBC\SYSAUX01.DBF
4    7681     USERS        ***     D:\ORADATA\HSBC\USERS01.DBF
5    5864     UNDOTBS01    ***     D:\ORADATA\HSBC\UNDOTBS1.DBF
6    6219     USERS        ***     D:\ORADATA\HSBC\USERS02.DBF
9    2281     INDX01       ***     D:\ORADATA\HSBC\INDX01.DBF
10   2719     USER01       ***     D:\ORADATA\HSBC\USER01.DBF

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- ---------- ----------- --------------------
1    4229      TEMP      32767       D:\ORADATA\HSBC\TEMP01.DBF

RMAN> EXIT;