rman target /

run
{
  set nocfau;
  allocate channel ch01 device type disk format '/mnt/yavin4/tech/oracle/work/dataguard_ADNA/backup/ADNAPRD/backupset/%d_%U_%s_%t.bck';
  allocate channel ch02 device type disk format '/mnt/yavin4/tech/oracle/work/dataguard_ADNA/backup/ADNAPRD/backupset/%d_%U_%s_%t.bck';
  allocate channel ch03 device type disk format '/mnt/yavin4/tech/oracle/work/dataguard_ADNA/backup/ADNAPRD/backupset/%d_%U_%s_%t.bck';
  allocate channel ch04 device type disk format '/mnt/yavin4/tech/oracle/work/dataguard_ADNA/backup/ADNAPRD/backupset/%d_%U_%s_%t.bck';
  backup as compressed backupset incremental level 0 database section size 2G include current controlfile plus archivelog delete input;
  release channel ch01;
  release channel ch02;
  release channel ch03;
  release channel ch04;
  allocate channel ch01 device type disk format '/mnt/yavin4/tech/oracle/work/dataguard_ADNA/backup/ADNAPRD/backupset/%d_%U_%s_%t.controlfile';
  backup current controlfile;
  release channel ch01;
}


sqlplus 'sys/"Secret00!"'@wayland.swgalaxy:1555/ADNAPRD_DGMGRL as sysdba
sqlplus 'sys/"Secret00!"'@togoria.swgalaxy:1555/ADNADRP_DGMGRL as sysdba


configure archivelog deletion policy to applied on all standby;

rman target='sys/"Secret00!"'@wayland.swgalaxy:1555/ADNAPRD_DGMGRL auxiliary='sys/"Secret00!"'@togoria.swgalaxy:1555/ADNADRP_DGMGRL

run
{
  allocate channel pri01 device type disk;
  allocate channel pri02 device type disk;
  allocate channel pri03 device type disk;
  allocate channel pri04 device type disk;
  allocate channel pri05 device type disk;
  allocate channel pri06 device type disk;
  allocate channel pri07 device type disk;
  allocate channel pri08 device type disk;
  allocate channel pri09 device type disk;
  allocate channel pri10 device type disk;

  allocate auxiliary channel aux01 device type disk;
  allocate auxiliary channel aux02 device type disk;
  allocate auxiliary channel aux03 device type disk;
  allocate auxiliary channel aux04 device type disk;
  allocate auxiliary channel aux05 device type disk;
  allocate auxiliary channel aux06 device type disk;
  allocate auxiliary channel aux07 device type disk;
  allocate auxiliary channel aux08 device type disk;
  allocate auxiliary channel aux09 device type disk;
  allocate auxiliary channel aux10 device type disk;

  duplicate database 'ADNA' for standby
    from active database using compressed backupset section size 512M;
}



alter system set dg_broker_config_file1='/app/oracle/base/admin/ADNAPRD/dgmgrl/dr1ADNAPRD.dat' scope=both sid='*';
alter system set dg_broker_config_file2='/app/oracle/base/admin/ADNAPRD/dgmgrl/dr2ADNAPRD.dat' scope=both sid='*';
alter system set dg_broker_start=TRUE scope=both sid='*';


alter system set dg_broker_config_file1='/app/oracle/base/admin/ADNADRP/dgmgrl/dr1ADNADRP.dat' scope=both sid='*';
alter system set dg_broker_config_file2='/app/oracle/base/admin/ADNADRP/dgmgrl/dr2ADNADRP.dat' scope=both sid='*';
alter system set dg_broker_start=TRUE scope=both sid='*';


rlwrap dgmgrl 'sys/"Secret00!"'@wayland.swgalaxy:1555/ADNAPRD_DGMGRL

create configuration ADNA as
  primary database is ADNAPRD
  connect identifier is 'wayland.swgalaxy:1555/ADNAPRD_DGMGRL';

add database ADNADRP
  as connect identifier is 'togoria.swgalaxy:1555/ADNADRP_DGMGRL'
  maintained as physical;

enable configuration;

edit database 'adnaprd' set property ArchiveLagTarget=0;
edit database 'adnaprd' set property LogArchiveMaxProcesses=2;
edit database 'adnaprd' set property LogArchiveMinSucceedDest=1;
edit database 'adnaprd' set property StandbyFileManagement='AUTO';

edit database 'adnadrp' set property ArchiveLagTarget=0;
edit database 'adnadrp' set property LogArchiveMaxProcesses=2;
edit database 'adnadrp' set property LogArchiveMinSucceedDest=1;
edit database 'adnadrp' set property StandbyFileManagement='AUTO';

edit instance 'ADNAPRD' set property 'StaticConnectIdentifier'='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wayland.swgalaxy)(PORT=1555))(CONNECT_DATA=(SERVICE_NAME=ADNAPRD_DGMGRL)(INSTANCE_NAME=ADNAPRD)(SERVER=DEDICATED)))';
edit instance 'ADNADRP' set property 'StaticConnectIdentifier'='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=togoria.swgalaxy)(PORT=1555))(CONNECT_DATA=(SERVICE_NAME=ADNADRP_DGMGRL)(INSTANCE_NAME=ADNADRP)(SERVER=DEDICATED)))';

show configuration
validate database 'adnadrp'
validate database 'adnaprd'




create table heartbeat (ts TIMESTAMP);
insert into heartbeat values (CURRENT_TIMESTAMP);
commit;


CREATE OR REPLACE PROCEDURE update_heartbeat AS
BEGIN
    UPDATE heartbeat
       SET ts = SYSTIMESTAMP;
    COMMIT;
END;
/


BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
        job_name        => 'HEARTBEAT_JOB',
        job_type        => 'STORED_PROCEDURE',
        job_action      => 'UPDATE_HEARTBEAT',
        start_date      => SYSTIMESTAMP,
        repeat_interval => 'FREQ=SECONDLY; INTERVAL=1',
        enabled         => FALSE
    );
END;
/


BEGIN
    DBMS_SCHEDULER.ENABLE('HEARTBEAT_JOB');
END;
/


BEGIN
    DBMS_SCHEDULER.DISABLE('HEARTBEAT_JOB');
END;
/



BEGIN
    DBMS_SCHEDULER.DROP_JOB('HEARTBEAT_JOB');
END;
/

drop PROCEDURE update_heartbeat;

drop table heartbeat purge;


run{
  set until time "TIMESTAMP'2026-02-21 15:50:00'";
  alter pluggable database RYLS close immediate instances=all;
  restore pluggable database RYLS;
  recover pluggable database RYLS;
  alter pluggable database RYLS open resetlogs instances=all;
}
