Oracle 11g R2 ADG Construction

Source: Internet
Author: User

--============oracle ADG Building ==============


--========== Preparation Stage =========

1. Check primary for Archivelog mode.
Select Log_mode from V$database;

If it is Noarchivelog mode, switch to Archivelog mode.
Shutdown immediate;
startup Mount;
ALTER DATABASE Archivelog;
ALTER DATABASE open;

Perform forced logging:
ALTER DATABASE force logging;


2. Service configuration.

Primay and Standby resolve members in DG according to Tnsname, and configure "$ORACLE _home/network/admin/tnsnames.ora" in the server.
can be created using NETCA or manually.
Sicily =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.198.195.163) (PORT = 1521))
)
(Connect_data =
(service_name = Sicily)
)
)

Sicilybak =
(DESCRIPTION =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.198.195.164) (PORT = 1521))
)
(Connect_data =
(service_name = Sicilybak)
)
)


3. Record the db_name and db_unique_name of primary and standby.
Show parameter Db_name
Show Parameter Db_unique_name

Character Db_name Db_unique_name
Primary Sicily Sicily
Standby Sicily Sicilybak

Standby and primary have the same db_name, but db_unique_name are different.

The db_unique_name of primary and standby are used in the configuration log_archive_config dg_config parameters.

Executed on primary and standby, the parameter value is primary and db_unique_name of all standby members.
Alter system set log_archive_config= ' dg_config= (Sicily,sicilybak) ';


4. Set the remote archive path.

The default local location archive path in fast recovery area, the size of the flashback zone should be set sufficiently large. (Not recommended)
General, modify Log_archive_dest_1

1) View Archive file path location
Show Parameter log_archive_dest_1
2) Close the database
ALTER DATABASE chenkpoint;
Shutdown immediate
3) Mount Database
Start mount
4) Modify the archive path
Alter system set log_archive_dest_1= ' location=/oracle/archive ';
5) Start the database
ALTER DATABASE open;
6) See if it takes effect
Select Archiver from V$instance;
alter system switch logfile;
Ls/oracle/archive

Note that the standby-related service and db_unique_name are in the remote archive path.

ALTER SYSTEM SET log_archive_dest_2= ' service=sicilybak noaffirm ASYNC compression=enable valid_for= (Online_logfiles, primary_role) Db_unique_name=sicilybak ';
ALTER SYSTEM SET log_archive_dest_state_2=enable;

ALTER SYSTEM SET log_archive_format= '%t_%s_%r.arc ' scope=spfile;
ALTER SYSTEM SET log_archive_max_processes=30;
ALTER SYSTEM SET remote_login_passwordfile=exclusive scope=spfile;

If you need to switchover back and forth between primary and standby, let primary switch to standby role, you need to set the *_convert parameter to ensure that the file name and path between the servers are different.
--Here is the service name, which means where to get the gap when the log appears.
ALTER SYSTEM SET Fal_server=sicilybak;
--Here is the replacement of the preceding string with the following string
--alter SYSTEM SET db_file_name_convert= ' Sicilybak ', ' Sicily ' scope=spfile;
--alter SYSTEM SET log_file_name_convert= ' Sicilybak ', ' Sicily ' scope=spfile;
ALTER SYSTEM SET Standby_file_management=auto;
Note that some parameters cannot be modified and will take effect after the database restarts.


--========== Backup ==========

1.primary Backup
$ Rman Target/
Rman> BACKUP DATABASE as compressed backupset format '/oracle/rman/full_%d_%u.bak ';

2. Create a Standby control file
--performed on the primary
ALTER DATABASE CREATE STANDBY controlfile as '/oracle/rman/standby.ctl ';

3. Create the standby parameter file Pfile
CREATE pfile= '/oracle/rman/pfile ' from SPFILE;

4. Modify the configuration associated with the Pfile standby. Because it is a copy of the source server, only the following parameters need to be modified.
*.db_unique_name= ' Sicilybak '
*.fal_server= ' Sicily '
*.log_archive_dest_2= ' service=sicily ASYNC valid_for= (online_logfiles,primary_role) db_unique_name=sicily '


--========== Copy =========

1. Create the data file directory, archive log file directory, audit directory, and other parameter files listed in the standby
$ mkdir-p/oracle/rman
$ mkdir-p/oracle/archive
$ mkdir-p/oracle/oradata/sicily

2. Copy files from primary to standby
$ # Standby Controlfile to all locations.
$ SCP [Email Protected]:/oracle/rman/standby.ctl/oracle/rman/control01.ctl
$ cp/oracle/rman/control01.ctl/oracle/fast_recovery_area/sicily/control02.ctl

$ # Archivelogs
$ scp-r [Email protected]:/oracle/archive/oracle/archive

$ # Parameter file.
$ SCP [Email protected]:/oracle/rman/pfile/oracle/rman/pfile

$ # Remote Login password file.
$ SCP [email protected]: $ORACLE _home/dbs/orapw$oracle_sid $ORACLE _home/dbs

Note that if your backup is in the Flash zone, you need to copy the flashback back to standby;
If your backup is not in the flashback zone, you must make sure that you copy the backup to the same directory as primary.


--========== Recovery ===========

1. Create SPFile with Pfile
Create SPFile from pfile= '/oracle/rman/pfile ';

2. Recovery control files
rman> restore Controlfile from '/oracle/rman/standby.ctl ';

3. Restoring a Backup
rman> startup Mount;
rman> Restore Database;


--=========== creating online redo logs and standby redo logs==========

1. Create standby online redo logs, preferably in accordance with primary
ALTER SYSTEM SET standby_file_management=manual;
ALTER DATABASE ADD LOGFILE ('/oracle/oradata/sicily/redo01.log ') SIZE 50M;
ALTER DATABASE ADD LOGFILE ('/oracle/oradata/sicily/redo02.log ') SIZE 50M;
ALTER DATABASE ADD LOGFILE ('/oracle/oradata/sicily/redo03.log ') SIZE 50M;
ALTER SYSTEM SET Standby_file_management=auto;

2. Create standby standby redo logs, if primary is to be switched to standby role, it will be built on primary.
Standby redo logs should be at least as big as the largest online redo log, one more than online redo logs.
ALTER DATABASE ADD STANDBY LOGFILE ('/oracle/oradata/sicily/standby_redo01.log ') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('/oracle/oradata/sicily/standby_redo02.log ') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('/oracle/oradata/sicily/standby_redo03.log ') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE ('/oracle/oradata/sicily/standby_redo04.log ') SIZE 50M;


--============= start the application process ==============

# Background Redo apply. Control is returned to the session once the apply process is started.
ALTER database RECOVER MANAGED STANDBY database DISCONNECT from SESSION;

#you need to cancel the apply process, issue the following command.
ALTER database RECOVER MANAGED STANDBY database CANCEL;

ALTER DATABASE OPEN READ only;

#you has configured standby redo logs, you can start real-time apply using the following command.
ALTER database RECOVER MANAGED STANDBY database USING current LOGFILE DISCONNECT;


--============ Check ===========

Select Database_role,log_mode,protection_mode,protection_level from V$database;

Oracle 11g R2 ADG Construction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.