According to a record of practice operation, this article introduces the use of Rman Gebelai to create Dataguard physical active Standby library; This way the main library needs to be restarted only once, so that the main library has higher availability!
Before the operation of this document, our default primary database is already in the archive run mode, the approximate process is to first configure the main library parameters and do the Rman backup, then install Oracle software in the standby, configuration monitoring, do not need to create a database DBCA, and then modify the repository parameter files and rman recovery, After the test.
Environment Description:
primary:centos6.3 64-bit 192.168.100.117,db_name:ahqy,db_unique_name:ahqy
standby:centos6.3 64-bit 192.168.100.118,db_name:ahqy,db_unique_name:standby
Oracle version: 11.2.0.1 64-bit Enterprise Edition
One, primary server configuration
1: Open forced Logging on the main library
ALTER DATABASE force logging;
2: Create a password file on the repository and copy it directly from the main library to the standby library
Scp/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapwahqy 192.168.100.118:/home/oracle/app/oracle/ Product/11.2.0/dbhome_1/dbs/orapwahqy
3: Configure standby Redo Log on the main library
Select member from V$logfile;du-h/home/oracle/oradata/ahqy/redo01.logsqlplus/as sysdbamkdir standbyalter Database add Standby logfile Group 4 '/home/oracle/oradata/ahqy/standby/standby04.log ' size 200m;alter database add standby logfile gr OUP 5 '/home/oracle/oradata/ahqy/standby/standby05.log ' size 200m;alter database add standby logfile Group 6 '/home/oracl E/oradata/ahqy/standby/standby06.log ' size 200M;
4. Modify the initialization parameters of the main library
Alter system set log_archive_config= ' dg_config= (ahqy,standby) '; alter system set log_archive_dest_1= ' location=/home/ Oracle/arch valid_for= (all_logfiles,all_roles) db_unique_name=ahqy ' Scope=spfile;alter system set log_archive_dest_2 = ' Service=standby lgwr async valid_for= (online_logfiles,primary_role) Db_unique_name=standby ' Scope=spfile;alter System set log_archive_dest_state_1=enable; Alter system set Log_archive_dest_state_2=enable;alter system set log_archive_format= '%t_%s_%r.arc ' scope=spfile;show Parameter Remote_login;alter system set Log_archive_max_processes=30;alter system set Fal_server=standby;alter system Set Fal_client=ahqy;alter system set Standby_file_management=auto; Shutdown immediate; Startup
5: Configure the Main library's Tnsnames.ora file, the repository needs the same operation
Cat/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin//tnsnames.ora # Tnsnames.ora Network Configuration File:/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora# Generated by Oracle Configuration tools. Listener_ahqy = ( ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.100.117) (PORT = 1521)) ahqy = (DESCRIPTION = ( addre SS = (PROTOCOL = TCP) (HOST = 192.168.100.117) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (Service_nam E = ahqy) ) STANDBY = (DESCRIPTION = ( ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.100.118) (PORT = 1521))
(Connect_data = (SERVER = dedicated) (service_name = standby) ) )
6: Prepare the Pfile and database backup files, control files, etc. on the main library
Mkdir-p/home/oracle/backup/create pfile= '/home/oracle/backup/initahqy.ora ' from Spfile;rman target/backup tag ' dg_ 20141226 ' format '/home/oracle/backup/dg_%u ' incremental level 0 database plus archivelog; Backup format '/home/oracle/backup/controlfile_%u ' current controlfile for standby;
Second, standby server configuration
1: Set Oracle_sid, configure Tnsnames.ora
echo $ORACLE _sidscp/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora [email protected]:/ Home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
2: Copy the backup files from the main library on the standby and prepare the related directories
Mkdir-p/HOME/ORACLE/BACKUP/SCP-RP [email protected]:/home/oracle/backup/*/home/oracle/backup/cp/home/ Oracle/backup/initahqy.ora $ORACLE _home/dbsgrep ' Fal_ ' $ORACLE _home/dbs/initahqy.ora *.fal_client= ' STANDBY ' *.fal_ Server= ' ahqy ' grep ' log_archive_dest_ ' $ORACLE _home/dbs/initahqy.ora *.log_archive_dest_1= ' location=/home/oracle/ Arch valid_for= (all_logfiles,all_roles) db_unique_name=standby ' *.log_archive_dest_2= ' service=ahqy lgwr async valid_ For= (online_logfiles,primary_role) db_unique_name=ahqy ' *.log_archive_dest_state_1= ' ENABLE ' *.log_archive_dest_ State_2= ' ENABLE ' *.db_unique_name= ' standby '----------------------------this omission, resulting in the default of Ahqy, be sure to add *. Log_archive_config= ' dg_config= (standby,ahqy) '--the main repository switch, otherwise the switchover will have a problem---alter system set log_archive_config= ' dg_config= ( standby,ahqy) '; Mkdir-p/home/oracle/arch/ahqymkdir-p/home/oracle/app/oracle/admin/ahqy/{adump,bdump,cdump, Dpdump,udump,pfile}--There are several folders that may not be mkdir-p/home/oracle/oradata/ahqymkdir-p/U01/APP/ORACLE/FLASH_RECOVER_AREA/ORCL --Not found--(the corresponding main library files are moved directly to the repository, such as:/home/oracle/arch/,/home/oracle/oradata/,/home/oracle/oradiag_oracle) mkdir-p/home/ Oracle/app/oracle/diag/rdbms/ahqy/ahqy/{alert,cdump,hm,incident,incpkg,ir,lck,metadata,stage,sweep,trace} Considering that there may be a folder that is not built, I will copy several main folders directly from the main library to the corresponding directory in the repository.
3: Boot repository to Nomount state
Sqlplus/as Sysdbastartup Nomount;
4: Use Rman to restore a standby library
Rman target Sys/[email protected] auxiliary/duplicate target database for standby nofilenamecheck;
5: Put the standby library into the app Redolog mode
Sqlplus/as sysdbaarchive Log list;alter database recover managed standby database disconnect from Session;select Sequenc E#,first_time,next_time,applied from V$archived_log;select member to v$logfile; you can log switching on the main library to speed up the library application log! Sqlplus/as sysdbaalter system Switch logfile;archive log list, re-query on standby: select Sequence#,first_time,next_time,applied fr Om v$archived_log;select name,database_role from V$database;
third, data testing
1. Create a table space on the main library, build a table
Select Name,database_role from V$database;create tablespace ahqy datafile '/home/oracle/oradata/ahqy/ahqy.dbf ' size 10M autoextend on; CREATE TABLE DG01 as SELECT * from dba_source;alter system switch logfile;
2. Open View data read-only after repository application log
ALTER DATABASE recover managed standby Database cancel;alter database open read only; Select type from DG01;
3: Put the repository into Application log mode from the new
Sqlplus/as sysdbashutdown immediate;startup nomount;alter database mount standby database;alter database recover managed Standby database disconnect from session;
Iv. placing the standby in active mode
1) View standby current status Mount
Select Open_mode,database_role,db_unique_name from V$database;
2) Cancel the automatic recovery of the standby library
ALTER DATABASE recover managed standby database cancel;
3) Open Standby library is read-only (Dataguard can only boot to readonly mode)
ALTER DATABASE Open;select Open_mode from v$database;alter database recover managed standby the database using current logfile Disconnect;select open_mode,database_role,db_unique_name from V$database;
v. Master and Standby Library switching
Main Library Operations:
ALTER DATABASE commit to switchover to physical standby with session Shutdown;shutdown Immediatestartup Mountalter databas E Recover managed Standby database disconnect from session;
To prepare the library operation:
Shutdown Immediatestartup Mountalter Database commit to switchover to primary;alter database open;
vi. matters of caution
1: Static listening is used on the primary and standby side
[[email protected] admin]$ cat Listener.ora # Listener.ora Network Configuration File:/home/oracle/app/oracle/ product/11.2.0/dbhome_1/network/admin/listener.ora# Generated by Oracle configuration tools. LISTENER = (Description_list = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.100.118) (PORT = 1521)) )) Sid_list_listener = (Sid_list = (Sid_desc = (Sid_name = plsextproc) (Oracle_home =/home/oracl E/app/oracle/product/11.2.0/dbhome_1) (program = Extproc)) (Sid_desc = (Sid_name = ahqy) (ORAC Le_home =/home/oracle/app/oracle/product/11.2.0/dbhome_1) (Global_dbname = standby))) Adr_base_listener =/ho Me/oracle/app/oracle[[email protected] admin]$ cat Listener.ora # Listener.ora Network Configuration File:/home/ oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora# Generated by Oracle configuration tools. LISTENER = (Description_list = (DESCRIPTION = (ADDRESS = (PROTOCOL= TCP) (HOST = 192.168.100.117) (PORT = 1521)))) Sid_list_listener = (Sid_list = (Sid_desc = (Sid_name = Plsextproc) (Oracle_home =/home/oracle/app/oracle/product/11.2.0/dbhome_1) (program = Extproc)) (Sid_desc = (Sid_name = ahqy) (Oracle_home =/home/oracle/app/oracle/product/11.2.0/dbhome_1) (GLOBAL_DBNA ME = ahqy)) Adr_base_listener =/home/oracle/app/oracle
2:tnsname Configuration
The service_name in TNSNames can be configured according to the show parameter name.
[[email protected] admin]$ cat Tnsnames.ora # Tnsnames.ora Network Configuration File:/home/oracle/app/oracle/ product/11.2.0/dbhome_1/network/admin/tnsnames.ora# Generated by Oracle configuration tools. Listener_ahqy = (Address = (PROTOCOL = TCP) (HOST = 192.168.100.117) (PORT = 1521)) Ahqy = (DESCRIPTION = (address = (PR Otocol = TCP) (HOST = 192.168.100.117) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (service_name = ahqy) )) standby = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.100.118) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (service_name = standby)) ) [[email protected] admin]$ cat Tnsnames.ora # Tnsnames.ora Network Configuration File:/HOME/ORACLE/APP/ORACLE/PR oduct/11.2.0/dbhome_1/network/admin/tnsnames.ora# Generated by Oracle configuration tools. Listener_ahqy = (Address = (PROTOCOL = TCP) (HOST = 192.168.100.117) (PORT = 1521)) Ahqy = (DESCRIPTION = (address = (PR Otocol = TCP) (HOST = 192.168.100.117) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (service_name = ahqy))) STANDBY = (descripti On = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.100.118) (PORT = 1521)) (Connect_data = (SERVER = dedicated) (service_name = standby)) )
Vii. Articles of reference
http://ylw6006.blog.51cto.com/470441/661105
Http://www.educity.cn/shujuku/1177494.html
http://blog.csdn.net/w63667329/article/details/7900270
ORACLE11G+CENTOS6+DG Installation Record