DATAGUARD of Oracle Learning (10) create DG using the new features of 11g rman on the same machine
First set up a database, db_name=primary, using dbca.
two。 Prepare static snooping for both databases. And the TNSNAME that connects to each other
11gdg1-> cat listener.ora tnsnames.ora # listener.ora Network Configuration File: / u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora# Generated by Oracle configuration tools.SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = primary) (ORACLE_HOME = / u01/app/oracle/product/11.2.0/db_1) (SID_NAME = primary) ) (SID_DESC = (GLOBAL_DBNAME = standby) (ORACLE_HOME = / u01/app/oracle/product/11.2.0/db_1) (SID_NAME = standby)) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 11gdg1.localdomain.com) (PORT = 1521)) ADR_BASE_LISTENER = / u01/app/oracle# tnsnames.ora Network Configuration File: / u01/app/oracle / product/11.2.0/db_1/network/admin/tnsnames.ora# Generated by Oracle configuration tools.PRIMARY = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.199.216) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = primary) STANDBY = (DESCRIPTION = (ADDRESS_LIST = (PROTOCOL = TCP) (HOST = 192.168.199.216) (PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = standby) 11gdg1->
3. Create a simple pfile for the slave library
11gdg1-> echo "db_name=whatever" > initstandby.ora
4. Create a password file for the slave library
11gdg1-> cp orapwprimary orapwstandby
5. Set up the directory needed from the slave library
11gdg1-> mkdir-p / u01 u01/app/oracle/oradata/standby mkdir mkdir-p / u01/app/oracle/fast_recovery_area/standby
6. Start from database to mount
7. Change the main library to FORCE LOGGING
SQL > alter database force logging;Database altered.
8. Open the main library archive
SQL > archivelog listDatabase log mode No Archive ModeAutomatic archival DisabledArchive destination USE_DB_RECOVERY_FILE_DESTOldest online log sequence 1Current log sequence 2SQL > shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL > startup mountORACLE instance started.Total System Global Area 839282688 bytesFixed Size 2233000 bytesVariable Size 494931288 bytesDatabase Buffers 339738624 bytesRedo Buffers 2379776 bytesDatabase mounted.SQL > alter database archivelog;Database altered.SQL > alter database open;Database altered.
9. Create standby log
ALTER DATABASE ADD STANDBY LOGFILE'/ u01 apprenticeship sredo01.log' size 50Mreter DATABASE ADD STANDBY LOGFILE'/ u01 apprenticeship sredo02.log' size 50Minto alter DATABASE ADD STANDBY LOGFILE'/ u01apapacleoradata DATABASE ADD STANDBY LOGFILE'/ u01apapacleoradata size 50M alter DATABASE ADD STANDBY LOGFILE'/ u01aporacleoradata
10. Create a standby database
Run {allocate channel prmy1 type disk; allocate channel prmy2 type disk; allocate channel prmy3 type disk; allocate channel prmy4 type disk; allocate channel prmy5 type disk; allocate auxiliary channel stby1 type disk Duplicate target database for standby from active database spfile parameter_value_convert 'primary','standby'set' db_unique_name'='standby'set control_files='/u01/app/oracle/oradata/standby/control01.ctl'set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'set DB_RECOVERY_FILE_DEST_SIZE='4G'set log_file_name_convert='/primary/','/standby/'set db_file_name_convert='/primary/' '/ standby/'set fal_server='primary'set standby_file_management='AUTO'set log_archive_config='dg_config= (primary,standby)' set log_archive_dest_2='service=primary LGWR ASYNC valid_for= (ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=primary'nofilenamecheck Sql channel prmy1 "alter system set log_archive_config=''dg_config= (primary,standby)'"; sql channel prmy1 "alter system set log_archive_dest_2=''service=standby LGWR ASYNC valid_for= (ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=standby''"; sql channel prmy1 "alter system set log_archive_max_processes=5"; sql channel prmy1 "alter system set fal_server=standby"; sql channel prmy1 "alter system set standby_file_management=AUTO"; sql channel prmy1 "alter system archive log current"; allocate auxiliary channel stby type disk Sql channel stby "alter database recover managed standby database using current logfile disconnect";}
11. Verify data synchronization
Main library
SQL > conn / as sysdbaConnected.SQL > alter user scott account unlock;User altered.SQL > alter user scott identified by tiger;User altered.SQL > conn scott/tigerConnected.SQL > create table T1 as select * from emp;Table created.
Slave library
SQL > alter database recover managed standby database cancel;Database altered.SQL > alter database open;Database altered.SQL > conn scott/tigerConnected.SQL > select count (*) from T1; COUNT (*)-14