Oracle 11g R2 dataguard Build physical standby

Source: Internet
Author: User
Tags aliases sqlplus

Database version: 11.2.0.4
Server version: RedHat6.4
Main Library Primary: Installing database software and examples
Standby standby: Install only database software

First, the pre-erection of the main standby storage environment:
Main Library Primary:

[Email protected] dbs]$ Cat/home/oracle/.bash_profile#. Bash_profile# Get The aliases and functionsif[- F~/.BASHRC]; Then. ~/.bashrcfi# User specific environment and startup programsPath=$PATH:$HOME/binExportPATHExportTmp=/tmpExportTmpdir=$TMPExportOracle_hostname=orclExportOracle_unqname=orclExportOracle_base=/u01/oracleExportOracle_home=$ORACLE _base/product/11.2.0/db_1ExportOracle_sid=orclExportPath=$ORACLE _home/bin:$PATHExportLd_library_path=$ORACLE _home/lib:$LD _library_pathExportClasspath=$ORACLE _home/jlib:$ORACLE _home/rdbms/jlib:$CLASSPATH

Standby Library Standby:

[Email protected] ~]$ Cat/home/oracle/.bash_profile#. Bash_profile# Get The aliases and functionsif[- F~/.BASHRC]; Then. ~/.bashrcfi# User specific environment and startup programsPath=$PATH:$HOME/binExportPATHExportTmp=/tmpExportTmpdir=$TMPExportOracle_hostname=dgExportOracle_unqname=dgExportOracle_base=/u01/oracleExportOracle_home=$ORACLE _base/product/11.2.0/db_1ExportOracle_sid=dgExportPath=$ORACLE _home/bin:$PATHExportLd_library_path=$ORACLE _home/lib:$LD _library_pathExportClasspath=$ORACLE _home/jlib:$ORACLE _home/rdbms/jlib:$CLASSPATH

Ii. Erection of Dataguard
Main Library primary operations:

--检查数据库是否支持Dataguard[[email protected] dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Thu Jul 23 10:02:01 2015Copyright (c) 1982, 2013, Oracle.  ‘Managed Standby‘;PARAMETER----------------------------------------------------------------VALUE----------------------------------------------------------------Managed StandbyTRUE
--Check if the main library is open in Archive mode sql> archiveLogListdatabaseLogMode Archive modeautomatic Archival enabledarchive destination/u01/archive/orcloldest OnlineLogSequence atNextLogSequence to archive -CurrentLogSequence ---If you do not turn on the following actions sql>shutdownimmediatesql> startup mountsql> ALTER DATABASE Archivelog; Sql> ALTER DATABASEOpen;--Set the database to forced log mode sql> ALTER DATABASE force logging;--Create the DB password file (if not) [Oracle@oracle/]$ orapwd file=$ORACLE _home/dbs/orapw$ORACLE _sidPassword=oracle force=yIgnorecase=yentries=5--Create the main library archive directory [Oracle@oracle/]$ cd/u01[oracle@oracleu01]$mkdirArchive[oracle@oracleu01]$ CD Archive[oracle@oraclearchive]$mkdirorcl--backing up the database initialization parameter file sql> create pfile='/home/oracle/pfile.ora 'The from spfile;--creates the Pfile file, which facilitates modifying the initialization parameters sql> create Pfile from spfile;--Open the Pfile file, adding the following content Db_unique_name=orcllog_ archive_config=' dg_config= (ORCL,DG) 'log_archive_dest_1=' Location=/u01/archive/orcl valid_for= (all_logfiles,all_roles) DB_UNIQUE_NAME=ORCL 'Log_archive_dest_2=' SERVICE=DG ASYNC valid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME=DG 'Log_archive_dest_state_1=enablelog_archive_dest_state_2=enableremote_login_passwordfile=exclusivelog_archive_ format=%t_%s_%r. arcfal_server=dgdb_file_name_convert='/u01/oracle/oradata/dg/','/u01/oracle/oradata/orcl/'log_file_name_convert='/U01/ARCHIVE/DG ','/U01/ARCHIVE/ORCL 'standby_file_management=auto--Closing the database sql>shutdownimmediate--creating spfilesql> Create SPFile from pfile;--by pfile Open database sql> startup--backup main Library Primary database file--close database sql>shutdownImmediate-Stop monitoring [Oracle@oracle/]$ lsnrctl stop--Start database to mount status sql> startup mount--create backup directory [Oracle@oracle/]$ cd/u01[oracle@oracleu01]$mkdirBackup--rman Backup [Oracle@oracle/]$ Rman target/rman> Backup full databaseformat '/u01/backup/backup_%t_%s_%p.bak '---Create a control file for the repository on the main library (2copy) sql> ALTER DATABASE create standby Controlfile as'/u01/backup/stdby_control01.ctl '; [Oracle@oracle/]$ cd/u01/backup/[oracle@oraclebackup]$ CP Stdby_control01.ctl Stdby_control02.ctl

Repository Standby Operation:

--Create the necessary directories Cd/u01mkdir ARCHIVECD archivemkdir dgcd/u01/oraclemkdir admincd adminmkdir dgcd dgmkdir adumpcd/u01/oracle/or Adatamkdir dgcd/u01/oraclemkdir FAST_RECOVERY_AREACD Fast_recovery_areamkdir dgcd/u01mkdir backup--the backup file from the master library to the standby via SCP [Oracle@oracleBackup$ Cd/u01/backup[oracle@oracleBackup$ SCP Backup*.bak192.168.8.223:/u01/backup[Oracle@oracleBackup$ SCP Stdby_control*.ctl192.168.8.223:/u01/oracle/oradata/[Oracle@oracleBackup$ Cd$ORACLE _home/dbs[oracle@oracleDBs$ SCP Initorcl.ora192.168.8.223:$ORACLE _homeAfter the/dbs/is transferred, place the control file in the directory set in the initialization parameter--Create a password file for the repository standby: [Oracle@dg~]$ Orapwd file=$ORACLE _home/dbs/orapw$ORACLE _sidPassword=oracle force=y ignorecase=y entries--Modify the Repository initialization parameter file (the main library initialization parameter file is Initorcl.ora to be modified to Initdg.ora), add the initialization file to the following content ( Delete or modify a similar content in the main library):Db_unique_name=dgLog_archive_config=' dg_config= (ORCL,DG) 'log_archive_dest_1=' LOCATION=/U01/ARCHIVE/DG valid_for= (all_logfiles,all_roles) DB_UNIQUE_NAME=DG 'log_archive_dest_2=' Service=orcl ASYNC valid_for= (online_logfiles,primary_role) DB_UNIQUE_NAME=ORCL 'Log_archive_dest_state_1=ENABLElog_archive_dest_state_2=ENABLERemote_login_passwordfile=EXCLUSIVELog_archive_format=%t_%s_%r.arcFal_server=orclDb_file_name_convert='/u01/oracle/oradata/orcl/','/u01/oracle/oradata/dg/'Log_file_name_convert='/U01/ARCHIVE/ORCL ','/U01/ARCHIVE/DG 'standby_file_management=AUTO--Create SPFile files with Pfile [Oracle@dg~]$ Sqlplus/as SYSDBASQL> Create SPFile from pfile;--to start the physical standby library standbySQL> Startup NomountSQL> ALTER DATABASE mount standby database;--standby standby do rman recovery [Oracle@dg~]$ Rman Target/RMAN> RESTORE Database;

Configure the Master repository file (the repository is not available for modification from the main library SCP), only the contents of the main repository related files are posted below.

--Listener.ora of the main library primary# Listener.ora NetworkConfiguration File:/u01/oracle/product/11.2. 0/db_1/network/admin/listener.ora# Generated by OracleConfigurationTools. LISTENER = (Description_list = (DESCRIPTION = (address = (PROTOCOL = IPC) (KEY = EXTPROC1521)) (address = (PR Otocol = TCP) (HOST = Oracle) (PORT=1521))) Adr_base_listener =/u01/oracle--Listener.ora of the storehouse standby# Listener.ora NetworkConfiguration File:/u01/oracle/product/11.2. 0/db_1/network/admin/listener.ora# Generated by OracleConfigurationTools. LISTENER = (Description_list = (DESCRIPTION = (address = (PROTOCOL = IPC) (KEY = EXTPROC1521)) (address = (PR Otocol = TCP) (HOST = DG) (PORT=1521))) Adr_base_listener =/u01/oracle--Tnsnames.ora of the main library primary# Tnsnames.ora NetworkConfiguration File:/u01/oracle/product/11.2. 0/db_1/network/admin/tnsnames.ora# Generated by OracleConfigurationTools. ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = Oracle) (PORT=1521)) (Connect_data = (SERVER = dedicated) (service_name = ORCL))) DG = (DESCRIPTION = (ADDRESS = (PROT Ocol = TCP) (HOST =192.168. 8. 223)(PORT=1521)) (Connect_data = (SERVER = dedicated) (service_name = DG)))--Tnsnames.ora of the storehouse standby# Tnsnames.ora NetworkConfiguration File:/u01/oracle/product/11.2. 0/db_1/network/admin/tnsnames.ora# Generated by OracleConfigurationTools. dg = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = DG) (PORT=1521)) (Connect_data = (SERVER = dedicated) (service_name = DG))) ORCL = (DESCRIPTION = (ADDRESS = (PROT Ocol = TCP) (HOST =192.168. 8. 205)(PORT=1521)) (Connect_data = (SERVER = dedicated) (service_name = ORCL)))--Restart listener after completionLsnrctl Stoplsnrctl Start--tnsping Master Standby LibraryTnsping orcltnsping DGLinux Firewall restrictions may be--tnsping when firewall commands are disabledService Iptables Stop

Configure Standby Redolog (if the database is the best performance mode can be ignored, if it becomes a repository later and is to be two other modes to be established)

--Create:sql> ALTER DATABASE add standby logfile on the main library primaryGroup 4('/u01/oracle/oradata/orcl/stdby_redo04.log ')size  -MGroup 5('/u01/oracle/oradata/orcl/stdby_redo05.log ')size  -MGroup 6('/u01/oracle/oradata/orcl/stdby_redo06.log ')size  -MGroup 7('/u01/oracle/oradata/orcl/stdby_redo07.log ')size  -sql> ALTER DATABASE Add standby logfile on m;--Standby library standbyGroup 4('/u01/oracle/oradata/dg/stdby_redo04.log ')size  -MGroup 5('/u01/oracle/oradata/dg/stdby_redo05.log ')size  -MGroup 6('/u01/oracle/oradata/dg/stdby_redo06.log ')size  -MGroup 7('/u01/oracle/oradata/dg/stdby_redo07.log ')size  -M
--在备库standby上启动redo applySQL> alter database recover managed standby database disconnect from session;

To this physical standby created!

Some common commands (in the collation)

 Select switchover_status  from v$database;Startup Nomount alter database mount standby database; alter database recover managed standby database disconnect from  session;--read-only open from recovering state alter database recover managed standby database cancel; alter database open read only;

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Oracle 11g R2 dataguard Build physical standby

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.