天天看點

【Oracle】實體DATAGUARD最大性能模式部署

實體DATAGUARD最大性能模式配置過程

主庫主機edbjr2p1 

備庫主機edbjr2p2

1.建立主庫

[[email protected] ~]# xhost +

access control disabled, clients can connect from any host

[[email protected] ~]# su - oracle

[[email protected] ~]$ dbca

建庫過程略。。。ORACLE_SID=ORCL

2.主庫參數

[[email protected] ~]$ export ORACLE_SID=ORCL

[[email protected] ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 31 09:20:03 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

[email protected]>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

[email protected]>startup mount

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218968 bytes

Variable Size              88082024 bytes

Database Buffers          188743680 bytes

Redo Buffers                7168000 bytes

Database mounted.

[email protected]>select status from v$instance;

STATUS

------------

MOUNTED

[email protected]>alter database force logging;

Database altered.

[email protected]>select log_mode from v$database;

LOG_MODE

------------

NOARCHIVELOG

[email protected]>

[email protected]>alter database archivelog;

Database altered.

[email protected]>alter system set log_archive_config='dg_config=(orcl,aux1)';

System altered.

[email protected]>alter system set log_archive_dest_10='location=/home/oracle/orcl_arclog valid_for=(online_logfiles,all_roles) db_unique_name=orcl';

System altered.

[email protected]>

建立目錄用于存放歸檔

[[email protected] admin]$ mkdir /home/oracle/orcl_arclog

繼續更改參數

[email protected]>alter system set log_archive_dest_1='service=aux1 valid_for=(online_logfiles,primary_role) db_unique_name=aux1';

System altered.

[email protected]>alter system set log_archive_max_processes=4;

System altered.

[email protected]>create pfile from spfile;

File created.

傳輸pfile檔案和密碼檔案

[[email protected] admin]$ scp $ORACLE_HOME/dbs/initORCL.ora edbjr2p2:$ORACLE_HOME/dbs/initAUX1.ora

[email protected]'s password: 

initORCL.ora                                  100% 1178     1.2KB/s   00:00    

[[email protected] admin]$ scp $ORACLE_HOME/dbs/orapwORCL edbjr2p2:$ORACLE_HOME/dbs/orapwAUX1

[email protected]'s password: 

orapwORCL                                     100% 1536     1.5KB/s   00:00    

[[email protected] admin]$ 

3.在備庫中修改傳輸過來的pfile檔案

[[email protected] ~]# su - oracle

[[email protected] ~]$ cd $ORACLE_HOME/dbs

[[email protected] dbs]$ ls

initAUX1.ora  initdw.ora  init.ora  orapwAUX1

[[email protected] dbs]$ vi initAUX1.ora 

以下是在檔案中修改的

*.audit_file_dest='/u01/app/oracle/admin/AUX1/adump'

*.background_dump_dest='/u01/app/oracle/admin/AUX1/bdump'

*.control_files='/u01/app/oracle/oradata/AUX1/control01.ctl','/u01/app/oracle/oradata/AUX1/control02.ctl','/u01/app/oracle/oradata/AUX1/control03.ctl'

*.core_dump_dest='/u01/app/oracle/admin/AUX1/cdump'

*.log_archive_dest_10='location=/home/oracle/aux1_arclog valid_for=(online_logfiles,all_roles) db_unique_name=aux1'

*.user_dump_dest='/u01/app/oracle/admin/AUX1/udump'

以下是在檔案中添加的

*.db_unique_name='AUX1'

*.standby_archive_dest='/home/oracle/aux1_stdlog'

*.db_file_name_convert=('/u01/app/oracle/oradata/ORCL/','/u01/app/oracle/oradata/AUX1/')

*.log_file_name_convert=('/u01/app/oracle/oradata/ORCL/','/u01/app/oracle/oradata/AUX1/')

*.standby_file_management='auto'

在備庫中建立目錄

[[email protected] dbs]$ mkdir -p $ORACLE_BASE/admin/AUX1/{a,b,c,u}dump

[[email protected] dbs]$ mkdir /home/oracle/aux1_arclog

[[email protected] dbs]$ mkdir /home/oracle/aux1_stdlog

[[email protected] dbs]$ mkdir $ORACLE_BASE/oradata/AUX1

4.建立監聽和TNS

主庫中:

[[email protected] admin]$ netca

【Oracle】實體DATAGUARD最大性能模式部署

然後一路下一步建立完監聽

之後建立TNS

【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署
【Oracle】實體DATAGUARD最大性能模式部署

因為主庫和備庫使用的tnsnames相同  則把tnsname.ora從主庫傳到備庫

[[email protected] admin]$ scp $ORACLE_HOME/network/admin/tnsnames.ora edbjr2p2:$ORACLE_HOME/network/admin/tnsnames.ora

[email protected]'s password: 

tnsnames.ora                                  100%  700     0.7KB/s   00:00    

[[email protected] admin]$ 

備庫中:

在備庫上建立監聽,過程略。。。

5.在主庫中穿件rman備份

[[email protected] admin]$ export ORACLE_SID=ORCL

[[email protected] admin]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 31 09:56:56 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1363387608, not open)

RMAN> backup database;

Starting backup at 31-DEC-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/u01/app/oracle/oradata/ORCL/system01.dbf

input datafile fno=00002 name=/u01/app/oracle/oradata/ORCL/undotbs01.dbf

input datafile fno=00003 name=/u01/app/oracle/oradata/ORCL/sysaux01.dbf

input datafile fno=00004 name=/u01/app/oracle/oradata/ORCL/users01.dbf

channel ORA_DISK_1: starting piece 1 at 31-DEC-13

channel ORA_DISK_1: finished piece 1 at 31-DEC-13

piece handle=/u01/app/oracle/product/10.2.0/db_1/dbs/01osspjr_1_1 tag=TAG20131231T095715 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

including current control file in backupset

including current SPFILE in backupset

channel ORA_DISK_1: starting piece 1 at 31-DEC-13

channel ORA_DISK_1: finished piece 1 at 31-DEC-13

piece handle=/u01/app/oracle/product/10.2.0/db_1/dbs/02ossplt_1_1 tag=TAG20131231T095715 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 31-DEC-13

RMAN> exit;

Recovery Manager complete.

[[email protected] admin]$ 

然後在主庫中建立備庫的controlfile

[email protected]>alter database create standby controlfile as '/home/oracle/control.ctl';

Database altered.

把控制檔案傳輸到備庫主機中

[[email protected] admin]$ scp /home/oracle/control.ctl edbjr2p2:$ORACLE_BASE/oradata/AUX1/control01.ctl

[email protected]'s password: 

control.ctl                                   100% 6896KB   6.7MB/s   00:01    

[[email protected] admin]$ scp /home/oracle/control.ctl edbjr2p2:$ORACLE_BASE/oradata/AUX1/control02.ctl

[email protected]'s password: 

control.ctl                                   100% 6896KB   6.7MB/s   00:00    

[[email protected] admin]$ scp /home/oracle/control.ctl edbjr2p2:$ORACLE_BASE/oradata/AUX1/control03.ctl

[email protected]'s password: 

control.ctl                                   100% 6896KB   6.7MB/s   00:00    

[[email protected] admin]$ 

傳輸rman備份的檔案到備庫主機的相同位置

[[email protected] dbs]$ scp 01osspjr_1_1 edbjr2p2:$ORACLE_HOME/dbs/01osspjr_1_1

[email protected]'s password: 

01osspjr_1_1                                  100%  656MB   5.7MB/s   01:55    

[[email protected] dbs]$ scp 02ossplt_1_1 edbjr2p2:$ORACLE_HOME/dbs/02ossplt_1_1

[email protected]'s password: 

02ossplt_1_1                                  100% 6976KB   6.8MB/s   00:01    

[[email protected] dbs]$ 

6.備庫中開始恢複檔案

[[email protected] dbs]$ export ORACLE_SID=AUX1

[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 31 10:09:23 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount 

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218968 bytes

Variable Size              88082024 bytes

Database Buffers          188743680 bytes

Redo Buffers                7168000 bytes

SQL> alter database mount standby database;

Database altered.

SQL> exit

Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

[[email protected] dbs]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Tue Dec 31 10:12:20 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1363387608, not open)

RMAN> restore database

2> ;

Starting restore at 31-DEC-13

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=151 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/app/oracle/oradata/AUX1/system01.dbf

restoring datafile 00002 to /u01/app/oracle/oradata/AUX1/undotbs01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/AUX1/sysaux01.dbf

restoring datafile 00004 to /u01/app/oracle/oradata/AUX1/users01.dbf

channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/10.2.0/db_1/dbs/01osspjr_1_1

channel ORA_DISK_1: restored backup piece 1

piece handle=/u01/app/oracle/product/10.2.0/db_1/dbs/01osspjr_1_1 tag=TAG20131231T095715

channel ORA_DISK_1: restore complete, elapsed time: 00:01:07

Finished restore at 31-DEC-13

RMAN> exit;

Recovery Manager complete.

[[email protected] dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 31 10:14:25 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

SQL> alter database recover managed standby database disconnect from session;

Database altered.

主庫和備庫都執行alter system register;確定資料庫都已經注冊到監聽

至此配置ok

6.測試

現在來進行測試,打開主庫,在主庫中建立表空間,檢視備庫中alert日志中能否看到表空間建立。

主庫:

[email protected]>create tablespace test

  2  datafile '/u01/app/oracle/oradata/ORCL/test01.dbf' size 5m;

Tablespace created.

[email protected]>alter system archive log current;

System altered.

[email protected]>

備庫中檢視alert日志

[[email protected] ~]$ cd $ORACLE_HOME/dbs

[[email protected] dbs]$ ls

initAUX1.ora  initdw.ora  init.ora  orapwAUX1

[[email protected] dbs]$ cd /u01/app/oracle/admin/AUX1/bdump/

[[email protected] bdump]$ ls

alert_AUX1.log       aux1_arc2_14480.trc  aux1_mrp0_14551.trc

aux1_arc0_14476.trc  aux1_arc3_14482.trc

aux1_arc1_14478.trc  aux1_dbw0_12923.trc

[[email protected] bdump]$ tail -100f alert_AUX1.log 

如果能看到以下内容則代表配置成功

Recovery created file /u01/app/oracle/oradata/AUX1/test01.dbf

Successfully added datafile 7 to media recovery

Datafile #7: '/u01/app/oracle/oradata/AUX1/test01.dbf'

Media Recovery Waiting for thread 1 sequence 30