ORACLE11GR2 Dataguard Construction

Source: Internet
Author: User
Tags prepare scp command

Database version: Oracle database 11g Enterprise Edition Release 11.2.0.1.0 Main Library ip:192.168.133.133 INSTANCE_NAME:ORCL service_name:p DB hostname: DG1 ip:192.168.133.134 INSTANCE_NAME:ORCL service_name:sdb hostname: DG2 (note that the operation on the virtual machine, the network connection method is best to choose host only, so The internal network is stable, the communication between the master repository is more normal)--Modify the Master Repository Hosts file: Main Library: [[email protected]~]# cat/etc/hosts127.0.0.1 dg1 localhost:: 1 Localhost6.localdo Main6 localhost6192.168.133.133 dg1192.168.133.134 DG2 Prepare library: [[email protected]~]# cat/etc/hosts127.0.0.1 dg2 localhost:: 1 localhost6.localdoma In6 localhost6192.168.133.133 dg1192.168.133.134 DG2--see if the firewall is off: [[email protected]~]#/etc/init.d/iptables Status
Firewall is stopped.  --to build the DG before the preparation: Open the database logging and Archivelog modesql>alter databases force logging; Check: SQL >select force_logging from V$database; (yes) check that the database is in archive mode: Sql>select Log_mode from V$database; If the database is not in archive mode, Then the database is Shutdow immediate; reboot to mount, execute Sql>alter DB archivelog; Sql>alter database open; Sql>archive log list;  --Configuring the master repository for monitoring and Network service name: Main Library: Listener.ora:SID_LIST_LISTENER =  (sid_list =    (Sid_desc =      (global_dbname = pdb)       (Oracle_home =/U01/APP/ORACLE/PRODUCT/11 .2.0/dbhome_1)       (sid_name = ORCL)    )  )  listener =  (DESCRIPTION =  &NB Sp (ADDRESS = (PROTOCOL = TCP) (HOST = DG1) (PORT = 1521))  )  adr_base_listener =/u01/app/oracle tnsnames.ora: PDB =  (DESCRIPTION =    (address_list =      (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.133 .133) (PORT = 1521))         (Connect_data =  &nbsp   (service_name = pdb)    )    sdb =  (DESCRIPTION =    (address_list =  &nbs P   (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.133.134) (PORT = 1521))    )     (Connect_data =      (service_name = SDB)    )    ORCL =  (DESCRIPTION =    (address_list =&N Bsp     (ADDRESS = (PROTOCOL = TCP) (HOST = DG1) (PORT = 1521))    )     (Connect_data =  &nbs P   (SERVER = dedicated)       (service_name = ORCL)    )  )   Prepare library: Listener.ora:SID_LIS T_listener =  (sid_list =    (sid_desc =      (global_dbname = SDB)       (ORA Cle_home =/u01/app/oracle/product/11.2.0/dbhome_1)       (sid_name = ORCL)    )  )   LISTENER =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP) (HOST = dg2) (PORT = 1521))  )  adr_base_l Istener =/U01/app/oracle tnsnames.ora:pdb =  (DESCRIPTION =    (address_list =      (ADDRESS = (P Rotocol = TCP) (HOST = 192.168.133.133) (PORT = 1521))    )     (Connect_data =      (SERV Ice_name = pdb)    )  )  sdb =  (DESCRIPTION =    (address_list =      (A ddress = (PROTOCOL = TCP) (HOST = 192.168.133.134) (PORT = 1521))    )     (Connect_data =    & nbsp (service_name = SDB)    )  )   --boot master standby monitoring: Lsnrctl start  -- Create a password file for the repository: if there is a direct use of the SCP command in the main library to the directory where the standby server is located, if it is not created using the ORAPWD command:
Orapwd file=xxx password=xxx entries=xx--Create the pfile of the main repository, add the corresponding parameters: Main Library: Sql>create pfile from SPFile; [[email protected]dbs]$ VI Initorcl.ora Add the following: *.instance_name=orcl*.db_unique_name=pdb*.log_archive_config= ' dg_config= (PDB,SDB) ' *. fal_server=sdb*.fal_client=pdb*.log_archive_dest_2= ' service=sdb lgwr sync affirm valid_for= (Online_logfiles, Primary_role) Db_unique_name=sdb ' *. log_archive_dest_state_1=enable*. log_archive_dest_state_2=enable*. Standby_file_management=auto if the main repository data files and log files are not in the same directory, you need to add the following two parameter files, the path is first remote after the local:

*. Db_file_name_convert= '/u01/oradata/sdb/', '/u01/oradata/pdb/'

*. Log_file_name_convert= '/u01/oradata/sdb/', '/u01/oradata/pdb/'

Repository: Use the SCP command to copy the pfile of the main library to the same directory as the standby server, and modify the following parameters: [[email protected]dbs]$ vi initorcl.ora*.instance_name=orcl*.db_unique_name=sdb*.log_archive_config= ' dg_config= (pdb,sdb) ' *.fal_ server=pdb*.fal_client=sdb*.log_archive_dest_2= ' service=pdb lgwr sync affirm valid_for= (online_logfiles,primary_ role) db_unique_name=pdb ' *. log_archive_dest_state_1=enable*. log_archive_dest_state_2=enable*. Standby_file_management=auto--Create the appropriate directory for the repository (my path below): Data files and log files directory/u01/app/oracle/oradata/orcl/flash back directory:/u01/app/oracle /FLASH_RECOVERY_AREA/ORCL Alert log file directory:/u01/app/oracle/diag/rdbms/sdb/orcl/trace archive log file directory:/SS/ARCHIVELOG/ORCL-- Prepare library: Create SPFile with Pfile and start database to Nomount:sql>startrup nomount pfile= '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/ Initorcl.ora ' sql>create spfile from Pfile; Sql>shutdown immediate; Sql>startup Nomount--Detecting the network connectivity of the Master repository: Main Library:sql> Conn sys/[email protected]As Sysdba
Connected.
Sql> Conn sys/[email protected]As Sysdba
Connected. Standby Library:sql> Conn sys/[email protected]As Sysdba
Connected.
Sql> Conn sys/[email protected]As Sysdba
Connected. --Backing up the database with RMAN: Back up the current control file: Rman>backup format '/ss/backup/controlfile_%u ' for standby;  Backup data files and archive log files: rman>backup format '/ss/backup/db_%u ' database plus archivelog; --Copy the backup set to the same directory as the main library/ss/backup/: scp/ss/backup/* [email protected]:/ss/backup/--physical Standby Database Creation--in the steps above I The repositories have been booted to Nomount, open Rman, and use Rman's Rman duplicate to create the standby database: [[email protected]~] $rman Target sys/[email protected] auxiliary/rman>duplicate Target database for standby Nofilenamecheck; After the standby database is complete, the databases are automatically opened to mount:sql> Select status from V$instance; (if the main standby directory is different: Duplicate target database for standby; If the master and standby directory is the same: duplicate target database for Stan Dby Nofilenamecheck;)    --Modify the repository for recovery management mode so that the repository can apply the redo data of the master library for synchronization: Sql>alter database Recover Managed Standby database disconnect from session, or Sql>alter database recover managed standby database using current logfile dis Connect from session;  --Check for an error message: Sql>select error From v$archive_dest where target= ' STANDBY ';   --check the Repository log application:sql> Select Sequence#,first_time,next_time,applied from V$archived_log ORDER by sequence#;    sequence# first_tim next_time applied-------------------------------------        01-nov-14 01-nov-14 yes        01-nov-14 01-nov-14 yes        01-nov-14 02-nov-14 yes        02-nov-14 02-nov-14 yes        02-nov-14 02-nov-14 yes        + 02-nov-14 02-nov-14 yes        02-nov-14 02-nov-14 yes        PNS 02-nov-14 02-nov-14 yes --in the main library Switch logs to view log applications in the Standby library:  sequence# first_tim next_time applied-------------------------------------        01-nov-14 01-nov-14 yes        01-nov-14 01-nov-14 yes        01-nov-14 02-nov-14 yes        02-nov-14 02-nov-14 yes        02-NOV-14 0 2-nov-14 yes        02-nov-14 02-nov-14 yes        $02-nov-14 02-nov-14 YES&N Bsp       PNS 02-nov-14 02-nov-14 yes        02-nov-14 03-nov-14 In-memory &nbs p;--Create standby log files (at least one more than redo log) for the Master repository: de-repository log application: Sql>alter database recover managed standby database cancel; Main Library: SQL >alter Database Add StandbyLogFile '/u01/app/oracle/oradata/orcl/stdredo01.log ' size 50m; Sql>alter database Add standby logfile '/u01/app/oracle/oradata/orcl/stdredo02.log ' size 50m; Sql>alter database Add standby logfile '/u01/app/oracle/oradata/orcl/stdredo03.log ' size 50m; Sql>alter database Add standby logfile '/u01/app/oracle/oradata/orcl/stdredo04.log ' size 50m; Sql> Select Group#,status,member from v$logfile;     group# status member--------------------------- ----------------------------------------         3/u01/app/oracle/oradata/orcl/redo03.log          2/u01/app/oracle/oradata/orcl/redo02.log         1/u01/app/ oracle/oradata/orcl/redo01.log         4/u01/app/oracle/oradata/orcl/stdredo01.log         5/u01/app/oracle/oradata/orcl/stdredo02.log         6/u01/app/ oracle/oradata/orcl/stdredo03.log        &NBSp;7/u01/app/oracle/oradata/orcl/stdredo04.log7 Rows selected.  Reserve: Sql>alter database Add standby logfile '/ U01/app/oracle/oradata/orcl/stdredo01.log ' size 50m; Sql>alter database Add standby logfile '/u01/app/oracle/oradata/orcl/stdredo02.log ' size 50m; Sql>alter database Add standby logfile '/u01/app/oracle/oradata/orcl/stdredo03.log ' size 50m; Sql>alter database Add standby logfile '/u01/app/oracle/oradata/orcl/stdredo04.log ' size 50m; Sql> select Group#,status,member from V$logfile; Sql> Select Group#,status,member from v$logfile;     group# status member--------------------------- ----------------------------------------------------------------------         3/u01/app/ oracle/flash_recovery_area/sdb/onlinelog/o1_mf_3_b5bt92v2_.log         2/u01/app/oracle/ flash_recovery_area/sdb/onlinelog/o1_mf_2_b5bt90kf_.log         1/u01/app/oracle/flash_ Recovery_area/sdb/onlinelog/o1_mf_1_b5bt8yfc_.log         4/u01/app/oracle/oradata/orcl/stdredo01.log      & nbsp  5/u01/app/oracle/oradata/orcl/stdredo02.log         6/u01/app/oracle/oradata/orcl/ stdredo03.log         7/u01/app/oracle/oradata/orcl/stdredo04.log 7 rows selected.   --enabling the Repository log application: Sql>alter database recover managed standby database disconnect from session; -- Determine whether the related processes are all started in the repository:sql> select Process,status from v$managed_standby; process status------------------- --arch closingarch closingarch connectedarch closingrfs idlerfs idlerfs idlemrp0 wait_for_logrfs IDLE  9 Rows selected.  --Synchronous Authentication:---check if the repository has a log breakpoint:sql> select * From v$archive_gap; no rows Selected if a log breakpoint exists, you will find these logs in the main library:sql> select Sequence#,name from V$archived_log t1,v$archive_gap T2 where t1.thread#= t2.thread#; After locating these log files, copy the files to the repository and register them with the standby library for application: Sql>alter database Register logfile 'xxx ';  main library:sql> alter tablespace test add datafile '/u01/app/oracle/oradata/orcl/test02.dbf ' size 10m autoextend Off; tablespace altered. sql> alter system switch logfile; system altered. sql> select name From V$datafile; name--------------------------------------------------------------------------------/u01/ app/oracle/oradata/orcl/system01.dbf/u01/app/oracle/oradata/orcl/sysaux01.dbf/u01/app/oracle/oradata/orcl/ Undotbs01.dbf/u01/app/oracle/oradata/orcl/users01.dbf/u01/app/oracle/oradata/orcl/example01.dbf/u01/app/oracle /oradata/orcl/users02.dbf/u01/app/oracle/oradata/orcl/test01.dbf/u01/app/oracle/oradata/orcl/users03.dbf/u01/ APP/ORACLE/ORADATA/ORCL/USERS04.DBF/U01/APP/ORACLE/ORADATA/ORCL/TEST02.DBF10 rows selected.  Prepare library: View Standby alert log file: datafile #10: '/u01/app/oracle/oradata/orcl/test02.dbf '  SQL> select name from V$datafile;name  --------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------/u01/app/oracle/ oradata/orcl/system01.dbf/u01/app/oracle/oradata/orcl/sysaux01.dbf/u01/app/oracle/oradata/orcl/undotbs01.dbf/ u01/app/oracle/oradata/orcl/users01.dbf/u01/app/oracle/oradata/orcl/example01.dbf/u01/app/oracle/oradata/orcl/ users02.dbf/u01/app/oracle/oradata/orcl/test01.dbf/u01/app/oracle/oradata/orcl/users03.dbf/u01/app/oracle/ oradata/orcl/users04.dbf/u01/app/oracle/oradata/orcl/test02.dbf 10 rows selected.  -- Modify the protection mode and protection level of the main library:--View the main library protection mode and protection level:sql> Select Protection_mode,protection_level from V$database; protection_ MODE                       Protection_level--------------------&NB Sp                          --------------------MAXIMUM PERF Ormance        maximum performance  If you are not in MAXIMUM availability high-availability mode, turn off the main library and reboot to mount, modifyFor high-availability mode: Sql>shutdown immediate; Sql>alter database mountsql>alter Database set standby database to maximize availability; (ALTER DATABASE set S Tandby database to maximize {protection | availability | performance} ) Sql>select Protection_mode,protection_ Level from V$database; Sql>alter database open; Just modify the main library and the sync to standby will be automatically applied.    so far, Datagurad has been built successfully.

ORACLE11GR2 Dataguard Construction

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.