Creating a physical standby database 11g on windows

15
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à standby 4. Add redolog file 5. Tạo controlfile cho standby từ primary. 6. Copy source primary đến standby 7. Kiểm tra Chuẩn bị: - OS Names: "prime" for the Primary database and "standby" for the Standby database. Network: Trên Prime:

description

tao co che standby cho orac

Transcript of Creating a physical standby database 11g on windows

Page 1: Creating a physical standby database 11g on windows

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:

Page 2: Creating a physical standby database 11g on windows

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)

Page 3: Creating a physical standby database 11g on windows

+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:

Page 4: Creating a physical standby database 11g on windows

TNSNAMES.ORA file of the Primary:

Page 5: Creating a physical standby database 11g on windows

LISTENER.ORA file of the Primary:

SQLNET.ORA file of the Standby:

TNSNAMES.ORA file of the Standby:

Page 6: Creating a physical standby database 11g on windows

LISTENER.ORA file of the Standby:

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

Page 7: Creating a physical standby database 11g on windows

Next: (On PRIME) Create the password file.

Page 8: Creating a physical standby database 11g on windows

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;

Page 9: Creating a physical standby database 11g on windows

Configure the pfile of the primary:

USING: SQL> ALTER SYSTEM SET ….

Page 10: Creating a physical standby database 11g on windows

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.

Page 11: Creating a physical standby database 11g on windows

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'

Page 12: Creating a physical standby database 11g on windows

;}

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:

Page 13: Creating a physical standby database 11g on windows

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'

Page 14: Creating a physical standby database 11g on windows

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  

Page 15: Creating a physical standby database 11g on windows

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