Creating a physical standby database 11g on windows

Preview:

DESCRIPTION

tao co che standby cho orac

Citation preview

Creating a Physical Standby Database

Cách thực hiện:

1. Tạo 2 máy ảo ping thông mạng và phải có môi trường giống nhau.2. Cấu hình tnsname, listener, sql và kiểm tra kết nối.3. Cấu hình Initialization Parameter File cho primary và standby4. Add redolog file5. Tạo controlfile cho standby từ primary.6. Copy source primary đến standby7. Kiểm tra

Chuẩn bị:

- OS Names: "prime" for the Primary database and "standby" for the Standby database.

Network:

Trên Prime:

Trên Standby:

Next:

+ The primary and standby databases must be using the same version of Oracle Database 11g.

+ The primary database must be opened in ARCHIVELOG mode.

+Install the database, Enterprise edition. (using DBCA)

+Set up Oracle net components (using NETCA)

+Test sql net connectivity.

PRIME:

SQL> Alter system set db_recovery_file_dest_size=2G scope=both;

System altered.

Alter system set db_recovery_file_dest=’C:\BK\FRA’

Select * from v$recovery_file_dest

Oracle Net Services network files must be set up on the primary database and on the standby database.

SQLNET.ORA file of the Primary:

TNSNAMES.ORA file of the Primary:

LISTENER.ORA file of the Primary:

SQLNET.ORA file of the Standby:

TNSNAMES.ORA file of the Standby:

LISTENER.ORA file of the Standby:

You can use "tnsping" to test the sql connectivity: On standby

Next: (On PRIME) Create the password file.

Create standby redo logs(On Prime):

SELECT * from v$logfile;

Alter database add standby logfile group 4 (‘C:\app\oracle\oradata\oraprime\standbyredo01.LOG’) size 50M;

Alter database add standby logfile group 5 (‘C:\app\oracle\oradata\oraprime\standbyredo03.LOG’) size 50M;

Alter database add standby logfile group 6 (‘C:\app\oracle\oradata\oraprime\standbyredo03.LOG’) size 50M;

Alter database add standby logfile group 7 (‘C:\app\oracle\oradata\oraprime\standbyredo04.LOG’) size 50M;

Next: Enable force logging (Optional) (On Prime)

Select log_mode from v$database;

Alter database force logging;

Configure the pfile of the primary:

USING: SQL> ALTER SYSTEM SET ….

alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(oraprime,orastandby)';alter system set LOG_ARCHIVE_DEST_1='LOCATION=+DATA VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oraprime';alter system set LOG_ARCHIVE_DEST_2='SERVICE=orastandby LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME= orastandby’;alter system set LOG_ARCHIVE_DEST_STATE_1=ENABLE;alter system set FAL_SERVER=orastandby;alter system set FAL_CLIENT=oraprime;alter database add standby logfile '+DATA';alter database add standby logfile '+DATA';alter database add standby logfile '+DATA';alter database add standby logfile '+DATA';

On Standby:

Option 1: Create pfile with only one parameter DB_NAME.

Start up no mount the database using the pfile.

Using: - Run RMAN Dupplicate database on primary

rman target sys/@oraprime auxiliary sys/oracle@orastandby

run {allocate channel prmy1 type disk;allocate channel prmy2 type disk;allocate channel prmy3 type disk;allocate channel prmy4 type disk;allocate auxiliary channel stby type disk;duplicate target database for standby from active databasespfile  parameter_value_convert 'oraprime','orastandby'  set db_unique_name='orastandby'  set control_files='+DATA'  set log_archive_max_processes='5'  set fal_client='oraprime'  set fal_server='orastandby'  set standby_file_management='AUTO'  set log_archive_config='dg_config=(oraprime,orastandby)'  set log_archive_dest_2='service=oraprime LGWR ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=prime'

;}

Start apply service on standby & Open for read-only

recover managed standby database using current logfile disconnect from session;recover managed standby database cancel;alter database open;recover managed standby database using current logfile disconnect from session;

Option 2: On PRIME Create a Control File for the Standby DatabaseSQL> SHUTDOWN IMMEDIATE;SQL> STARTUP MOUNT;SQL>ALTER DATABASE CREATE STANDBY CONTROLFILE AS 'C:\tostandby\controlstd.ctl';SQL> ALTER DATABASE OPEN;

Create a pFile for the Standby Database:

Copy pfile to standby and edit:1. FAL_SERVER2. FAL_CLIENT3. CONTROL_FILES: add standby controlfile

*.fal_client='orastandby'*.fal_server='oraprime'*.control_files='C:\app\oracle\oradata\oraprime\control01.ctl','C:\app\oracle\flash_recovery_area\oraprime\control02.ctl','C:\tostandby\CONTROLSTD.CTL'*.log_archive_config='DG_CONFIG=(oraprime,orastandby)'*.log_archive_dest_1='LOCATION=C:\app\oracle\oradata\orastandby VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'*.log_archive_dest_2='SERVICE=oraprime LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=prime'

SQL>Startup mount;SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Check that primary and standby are synchronized

Using:

PRIMARY  SQL> archive log list;Database log mode              Archive ModeAutomatic archival             EnabledArchive destination            /u01/arch1/orcl/Oldest online log sequence     43Next log sequence to archive   45Current log sequence           45SQL> select database_role, open_mode from v$database; DATABASE_ROLE    OPEN_MODE---------------- ----------PRIMARY          READ WRITE  STANDBY  

SQL> archive log list;Database log mode              Archive ModeAutomatic archival             EnabledArchive destination            /u01/arch1/orcl/Oldest online log sequence     43Next log sequence to archive   0Current log sequence           45SQL> select database_role, open_mode from v$database; DATABASE_ROLE    OPEN_MODE---------------- ----------PHYSICAL STANDBY MOUNTED