19 Temmuz 2013 Cuma

Streams Table Instantiation Rules


 Streams Table Instantiation Rules

  • If your streams configuration one-way, table-level; Source to Destination replication, you have to instantiate objects at Destination site.
  • If your streasms configuration bi-directional, table-level;  Source to Dest and Dest to Source,  you have to instantiate objects both Source and Destination databases.
  • If your streams configuration one-way,schema level;  Source to Destination replication, you have to instantiate SCHEMAS at Destination site.
  • If your streasms configuration bi-directional, schema level;  Source to Dest and Dest to Source,  you have to instantiate SCHEMAS both Source and Destination databases.

1. If you forget to instantiate tables or schemas you will get this error message.


ORA-26687: no instantiation SCN provided for "HR"."EMPLOYEE" in source database "SOURCE" ;

2. You could check your error messages from  DBA_APPLY_ERROR  view.  You must control this view attentively especially these columns:

 
ERROR_MESSAGE column,
ERROR_CREATION_TIME column,
LOCAL_TRANSACTION_ID column

SELECT * FROM DBA_APPLY_ERROR where error_message like '%ORA-26687%';

 
NOTE : save your error messages before re-execute the transactions. You could save dba_apply_error to excel file.

3. Check the tables or schemas that are really not instantiated  Follow the instructions above and check out the rules.

select * from DBA_APPLY_INSTANTIATED_OBJECTS where source_object_name='EMPLOYEE' AND source_object_owner='HR'

Select * from DBA_APPLY_INSTANTIATED_OBJECTS@SOURCE where source_object_name='EMPLOYEE' AND source_object_owner='HR' ;


4. Stop the Streams Services  on both side. Because replication cause a lock on objects and if its still try to working we couldnt instantiate the objects.

  • You could stop the service Oracle Enterprise Manager Console , Click the Data Movement and Under Streams Click Manage Replication. DISABLE ALL SERVICES.

        OR

  •    You could stop the services with STRMADMIN account with this script.

exec dbms_capture_adm.stop_capturE(capture_name=>'SOURCE');
exec dbms_apply_adm.stop_apply (apply_name=>'APPLY_SOURCE');
exec DBMS_PROPAGATION_ADM.STop_PROPAGATION(propagation_name=>'PROP_SOURCE');

5.  Instantiating objects with this script table-level. IF you want to instantiate schemas you could use DBMS_APPLY_ADM.set_schema_instantiation_scn procedure.

 

DECLARE
v_scn NUMBER;

BEGIN
v_scn := DBMS_FLASHBACK.get_system_change_number@SOURCE ();

DBMS_APPLY_ADM.set_table_instantiation_scn
(

source_object_name
=> 'HR.EMPLOYEE',

source_database_name
=> 'SOURCE',

instantiation_scn
=> v_scn);

END;

/

 
6. Back sto Step 2 and check the error messages which are getting  no instantiation SCN provided error message. Execute these messages from LOCAL_TRANSACTION_ID  with this script until no rows retuned  from DBA_APPLY_ERROR.


exec DBMS_APPLY_ADM.EXECUTE_ERROR ('local_transaction_id');


7. Check the invalid objects and compile them.

18 Temmuz 2013 Perşembe

Change Bash Prompt



Showing server name  at blogger posts is known problem for bloggers. Especially  if you are beginner blogger you have to face lots of screenshots sharing problem.  Best and practical case you can change your server name with simple this command. This change effects only your session.


command :

$echo $PS1

output :

\\u@\h \\W]\\$


run command : PS1="[\d \t \u@server:\w ] $ "

\d : the date in (Thu Jul 18)  format
\t  : the time in (16:48:35) format
\u : user
\w: current working directory







14 Temmuz 2013 Pazar

RMAN INCREMENTAL MERGE







  1. How to copy ASM datafile from Primary Database to Standby database on ASM using RMAN ID 605234.1

  1. Steps to peform for rolling forward a standby database using RMAN incremental when primary and standby are in ASM filesystem ID 836986.1

  1. How to use an incremental Backup to Roll forward the Standby when new datafiles are added to Primary [ID 1275762.1]

Advanced RMAN


Rman is powerfull to for Oracle Backup, it has many features but little known. this post covered 11gR1 and 11gR2.

  • Rman Recovery manager tool, could be backup up database, datafile, tablespace and archivelog
  • All commands necessary to end with semicolon
  • Rman can be used for both hot or cold backups. But database must be archivelog mode for host backups  as you know.

  • In 11g rman REDUCE the size of backup with :
    • skips the undo data for committed transactions.
    • 10g backup 
      •  at TAPE = once used blocks (ou) +used now blocks (u) +never used (nu)
      • at DISK =  once used blocks (ou) +used now blocks (u)
    • 11g backup
      • at TAPE =  (o.u)+ (u)
      • at DISK  = (u)
  • Datafiles can  have many to many backup pices , Backup pices can have many to one Backup sets  and a datafile cant be split accross the backupsets
  • 11g RMAN Read and Restore parallel.

  • Incremental backups checks for used blocks, so it can check it he blocks have been backed up before.
  • It can  backup only changed blocks
  • Reducing backup size, time, I/O and CPU
  • Level 0 Full Backup
  • Level 1 changed since last level 1
  •  Incremental doesnt care blocks are logging and data exist on undo or redo.
  • Can be compressed.

  • %d name of the database
  • %D day of the Date
  • %M month number
  • %Y yerar
  • %t time from reference point
  • %T YYYYMMDD
  • %n tablespace name
  • %p backup piece number
  • %s backupset number
  • %U cover all parameters.

  • Block Media Recovery
  • 11gR1 recover datafile parameter is deprecated so we must use !
  • blockrecover datafile DF# block  BLOCK#;

  • Flash Recovery Area
  • We have to define 2 initialization parameters;
  • db_recovery_file_dest='+ORAFLASH' or '/ORAFLASH'
  • db_recovery_file_dest_size = 10G

  • Image Copies
  • copies all blocks used or not
  • command includes as copy
  • Image copy backup is simple rman doesnt have to read file and restoring is simplier with no reconstruction
  • merge is possible 
  • !you tahe a imgae copy backup every sunday and incremental merge every day.
  • Compression ?
  • you cant backup to tape. you can backup only disk.

  • Regular backup
  • only used blocks are backed up so size is smaller than image copy
  • time is short than image copy
  • compression possible
  • disk and tape backup is possible

  • Compression
  • how compressi,on do this;Default algorithm method is BZIP2.
  • ABC123
  • ABC789
  • ABC223 SO GET THE ABC AS SYMBOL & and writes data to disk &123, &789 ....
  • show compression algorithm;
  • CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; #default;
  • There is another algorithm avaible in 11gR1-  ZLIB2 ( cpu usage is less then BZIP2)  but it requires advanced compression option.

  • Trace and debug and logging
  • You can use trace and debugging command at rman
  • rman target=/ debug=all trace=rmantrace1.trc
  • end of backup  you can read  #vi rmantrace1.trc
  • rman target=/ log=rman1.log ( append is possible )
  • rman target=/ log=rman1.log append
  • rman target=/ log=rman1.log checksyntax
  • v$rman_output
  • v$rman_backup_job
  • v$rman_backup_job_details

  • Duplicating Database
  • 10g needs connection to primary and backup for duplicate via rman
  • 11gR1 needs connect to primary but backup not necessary from active DB
  • 11gR2 from backup alone but no connection to primary needed. ***********

  • Health checks (11g)
  • RMAN >list failure
  • RMAN >advise  failure
  • RMAN >repair  failure preview

  • Security
  • Oracle RMAN can encrypt an entire database backup using one of these three methods:
    • Local TDE master encryption key
    • Passphrase
    • Hybrid  : Passphrase and  Local TDE master encryption key
    • Wallet ( alter system set encryption wallet open authenticated by "ilknur";
    • you can store table encryption key SYS.ENC$ table.

 Make sure directory
$ORACLE_BASE/admin/$ORACLE_SID/wallet exists
set enc key password : key.sql
open the wallet : wallo.sql
close the wallet : wallo.sql


more information rman backup security: http://www.oracle.com/technetwork/database/security/index-095354.html