SELECT CDB FROM V$ DATABASE ;
alter database force logging;
alter database open ;
alter database archivelog;
alter pluggable database all open ;
alter pluggable database all save state;
select thread#, group #,bytes/1024/1024 SIZE_MB, status,members from v$log;
select member from v$logfile;
alter database add standby logfile thread 1 group 4 ‘/u01/app/oracle/oradata/LHR19C/standby_redo04.log‘ size 50M ;
alter database add standby logfile thread 1 group 5 ‘/u01/app/oracle/oradata/LHR19C/standby_redo05.log‘ size 50M ;
alter database add standby logfile thread 1 group 6 ‘/u01/app/oracle/oradata/LHR19C/standby_redo06.log‘ size 50M ;
alter database add standby logfile thread 1 group 7 ‘/u01/app/oracle/oradata/LHR19C/standby_redo07.log‘ size 50M ;
--------配置tns
lhr19c =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = lhr19c)
)
)
lhr19cdg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = lhr19cdg)
)
)
--------配置监听
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = lhr19c)
(ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1)
(SID_NAME = lhr19c)
)
(SID_DESC =
(GLOBAL_DBNAME = lhr19cdg)
(ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1)
(SID_NAME = lhr19cdg)
)
)
LISTENER_DG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.52)(PORT = 1522))
)
SID_LIST_LISTENER_DG =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = lhr19c)
(ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1)
(SID_NAME = lhr19c)
)
(SID_DESC =
(GLOBAL_DBNAME = lhr19cdg)
(ORACLE_HOME = /u01/app/oracle/product/19.2.0/dbhome_1)
(SID_NAME = lhr19cdg)
)
)
lsnrctl start LISTENER_DG
dbca -silent -createDuplicateDB \
-gdbName lhr19c \
-sid lhr19cdg \
-sysPassword lhr \
-primaryDBConnectionString 192.168.59.52:1522/lhr19c \
-nodelist raclhr-18c-n1 \
-databaseConfigType SINGLE \
-createAsStandby -dbUniqueName lhr19cdg \
-datafileDestination ‘/u01/app/oracle/oradata/lhr19cdg/‘ \
-initParams db_create_file_dest=/u01/app/oracle/oradata/lhr19cdg/, db_create_online_log_dest_1=/u01/app/oracle/oradata/lhr19cdg/,local_listener= "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1522)))"
--主库修改参数
alter system set LOG_ARCHIVE_DEST_1= ‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lhr19c‘ ;
alter system set LOG_ARCHIVE_DEST_2= ‘service=lhr19cdg VALID_FOR=(online_logfiles,primary_role) DB_UNIQUE_NAME=lhr19cdg‘ ;
alter system set log_archive_config= ‘dg_config=(lhr19c,lhr19cdg)‘ ;
alter system set db_file_name_convert= ‘/u01/app/oracle/oradata/LHR19CDG/‘ , ‘/u01/app/oracle/oradata/LHR19C/‘ scope=spfile;
alter system set log_file_name_convert= ‘/u01/app/oracle/oradata/LHR19CDG/‘ , ‘/u01/app/oracle/oradata/LHR19C/‘ scope=spfile;
alter system set standby_file_management=auto scope=spfile;
alter system set fal_client= ‘lhr19c‘ ;
alter system set fal_server= ‘lhr19cdg‘ sid= ‘*‘ ;
alter system set local_listener= ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1522)))‘ , ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1521)))‘ ;
shutdown immediate
startup
--备库修改参数
alter system set LOG_ARCHIVE_DEST_1= ‘LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lhr19cdg‘ scope=spfile;
alter system set log_archive_config= ‘dg_config=(lhr19c,lhr19cdg)‘ ;
alter system set db_file_name_convert= ‘/u01/app/oracle/oradata/LHR19C/‘ , ‘/u01/app/oracle/oradata/LHR19CDG/‘ scope=spfile;
alter system set log_file_name_convert= ‘/u01/app/oracle/oradata/LHR19C/‘ , ‘/u01/app/oracle/oradata/LHR19CDG/‘ scope=spfile;
alter system set standby_file_management=auto scope=spfile;
alter system set fal_client= ‘lhr19cdg‘ ;
alter system set fal_server= ‘lhr19c‘ sid= ‘*‘ ;
alter system set local_listener= ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1522)))‘ , ‘(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.59.52)(PORT=1521)))‘ ;
shutdown immediate
startup
alter system register;
--备库查询实时应用
alter database recover managed standby database cancel;
alter database recover managed standby database using current logfile disconnect;
! ps -ef|grep ora_mrp
select INST_ID, dbid, name ,DB_UNIQUE_NAME,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from gv$ database ;
COL NAME FOR A100
SET LINESIZE 9999 PAGESIZE 9999
COL NEXT_CHANGE# FOR 999999999999999
SELECT THREAD#, NAME , SEQUENCE #, ARCHIVED, APPLIED, A.NEXT_CHANGE#
FROM V$ARCHIVED_LOG A
WHERE A. SEQUENCE # >= ( SELECT MAX (B. SEQUENCE #) - 3
FROM V$ARCHIVED_LOG B
WHERE B.THREAD# = A.THREAD#
AND B.RESETLOGS_CHANGE# = A.RESETLOGS_CHANGE#
AND B.RESETLOGS_CHANGE# =
( SELECT D.RESETLOGS_CHANGE# FROM V$ DATABASE D)
AND B.APPLIED = ‘YES‘
GROUP BY B.THREAD#)
ORDER BY A.THREAD#, A. SEQUENCE #;
|