سؤال

When building a new standby database, is it possible to have it start shipping archive logs from the primary without having the datafiles on the standby yet?

هل كانت مفيدة؟

المحلول

Yes! we can do that.

Which can be observed from the following demo.

I have two hosts Server1(192.168.30.132) and Server2(192.168.30.142) and ORCl database is on Server1.

I skipped some of the steps, creating standby redo logs for example, and configuration to make the answer short.

On Server1

Enable archivelog

SQL> alter database archivelog;

Database altered.

Enable force logging.

SQL> alter database force logging;

Database altered.

Create standby controlfile.

SQL> alter database create standby controlfile as '/home/oracle/Desktop/orcl_stby.ctl';

Database altered.

SCP standby control file to Server2.

 [oracle@server1 Desktop]$ scp orcl_stby.ctl oracle@192.168.30.142:/u01/app/oracle/fast_recovery_area/ORCL2/controlfile/

SCP password file to Server2.

[oracle@server1 dbs]$ scp orapworcl oracle@192.168.30.142:/u01/app/oracle/product/11.2.0/db_1/dbs/

Set log archive config and log archive dest parameters.

SQL>ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,orcl2)';
SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=orcl2 NOAFFIRM lgwr ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl2';

On Server2

Make necessary directories.

$ORACLE_BASE/admin/db_unique_name/adump
fast_recovery_area/db_unique_name/controlfile
fast_recovery_area/db_unique_name/archivelog

Create initSID.ora filewith the following parameters OR you can create pfile on Server1 and SCP to Server2.

[oracle@server2 dbs]$ vi initorcl2.ora

db_name= orcl
db_unique_name=orcl2
compatible=11.2.0.4
control_files='/u01/app/oracle/fast_recovery_area/ORCL2/controlfile/orcl_stby.ctl

[oracle@server2 dbs]$ sqlplus / as sysdba
SQL> startup nomount

SQL> create spfile from memory;

File created.
SQL> shut immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area  217157632 bytes
Fixed Size          2251816 bytes
Variable Size         159384536 bytes
Database Buffers       50331648 bytes
Redo Buffers            5189632 bytes
SQL> alter database mount;

Database altered.

SQL> ALTER SYSTEM SET LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,orcl2)';

System altered.

SQL> alter system set db_recovery_file_dest_size=500M;

System altered.

SQL> alter system set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/';

System altered.

On Server1

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

On Server2

[oracle@server2 archivelog]$ pwd
/u01/app/oracle/fast_recovery_area/ORCL2/archivelog
[oracle@server2 archivelog]$ ls
2017_02_22
[oracle@server2 archivelog]$ cd 2017_02_22/
[oracle@server2 2017_02_22]$ ls
o1_mf_1_36_dbtc52mg_.arc
[oracle@server2 2017_02_22]$ 

As long as LGWR/ARCn process on Primary and RFS process on Standby are running we can transfer archived logs without having datafiles in place on standby database.

On Server2

SQL> SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY;
PROCESS   STATUS      THREAD#  SEQUENCE#     BLOCK#     BLOCKS
--------- ----------- -------- ----------    ---------- ----------
RFS       IDLE          0      0             0           0
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top