• 博客访问: 1057567
  • 博文数量: 442
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-30 18:35
个人简介

暂无介绍

ITPUB论坛APP

ITPUB论坛APP



APP发帖 享双倍积分

文章分类

全部博文(442)

文章存档

2011年(22)

2010年(13)

2008年(22)

2007年(229)

2006年(106)

2005年(50)

我的朋友
微信关注

IT168企业级官微



微信号:IT168qiye



系统架构师大会



微信号:SACC2013

分类: Linux

五、备库环境准备

 

1、在备库添加指向主库的tnsnames

       在备库的tnsnames.ora添加如下内容:

primary =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.11)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = 200.200.200.22)(PORT = 1521))

    (LOAD_BALANCE = yes)

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = primary)

      (FAILOVER_MODE =

        (TYPE = SELECT)

        (METHOD = BASIC)

        (RETRIES = 180)

        (DELAY = 5)

      )

    )

  )2、在备库创建相关目录

       包括adump,bdump,cdump,udump及数据文件目录等。

3、拷贝主库的密码文件到备库上

--拷贝rac1的密码文件到备库的$ORACLE_HOME/dbs下,并把该密码文件修改为orapwd。这里我的sid就用rac1,所以,不用改名。

[oracle@rac1 dbs]$ scp orapwrac1 172.25.0.35:`pwd`

orapwrac1                                                                                         100% 1536     1.5KB/s   00:00   

 

4、配置备库的监听

[oracle@standby admin]$ more listener.ora

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = standby)

      (ORACLE_HOME = /opt/oracle/product/10.2/database)

      (SID_NAME = rac1)

    )

  )

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = standby)(PORT = 1521))

    )

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))

    )

  )

 

启动备库监听:lsnrctl start

 

5、设置备库参数文件

       从主库rac1上根据spfile创建一个pfile文件,并传到备库上。

       SQL> create pfile from spfile;

 

File created.

 

SQL> exit

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

With the Partitioning, Real Application Clusters and Data Mining options

[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs

[oracle@rac1 dbs]$ scp initrac1.ora 172.25.0.35:`pwd`

initrac1.ora        

 

在备库上修改参数文件:

 

Ø         删除所有非”*”打头的参数设置及rac相关参数

Ø         设置dataguard参数

 

修改后参数如下:

[oracle@standby dbs]$ more initrac1.ora

*.audit_file_dest='/opt/oracle/admin/rac/adump'

*.background_dump_dest='/opt/oracle/admin/rac/bdump'

*.compatible='10.2.0.3'

*.control_files='/soft/oradata/rac/control01.ctl','/soft/oradata/rac/control02.ctl','/soft/oradata/rac/control03.ctl'

*.core_dump_dest='/opt/oracle/admin/rac/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'

*.db_name='rac'

*.db_unique_name='STANDBY'

*.fal_client='STANDBY'

*.fal_server='PRIMARY'

*.job_queue_processes=10

*.log_archive_config='DG_CONFIG=(primary,standby)'

*.log_archive_dest_1='LOCATION= /soft/oradata/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby'

*.log_archive_dest_2='SERVICE=primary LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.log_archive_format='%t_%s_%r.arc'

*.log_archive_max_processes=4

*.log_file_name_convert='/DEV/RAW/','/SOFT/ORADATA/RAC/'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_max_size=157286400

*.sga_target=157286400

*.standby_file_management='AUTO'

*.undo_management='AUTO'

undo_tablespace='UNDOTBS1'

*.user_dump_dest='/opt/oracle/admin/rac/udump'

以上有些参数非必须设置的,但是为了switchover更方便,建议都修改上。

Undo表空间保留其中一个就可以。

路径转换相关参数要设置对,否则会报错。

 

6、把备库启动到nomount状态

[oracle@standby ~]$ sqlplus "/as sysdba"

 

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Apr 30 18:42:39 2008

 

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

 

Connected to an idle instance.

 

SQL> startup nomount

ORACLE instance started.

 

Total System Global Area  159383552 bytes

Fixed Size                  1260672 bytes

Variable Size              62915456 bytes

Database Buffers           92274688 bytes

Redo Buffers                2932736 bytes

 

7、从主库拷贝备份到备库上

       之前备份的所有文件都拷贝到备库上,路径要和主库备份路径保持一致。如果不一致,linux下可以用ln的方式解决。

       注意:两个节点都有归档的备份,要把这些备份都拷贝到备库上。

       RAC1

       [oracle@rac1 backup]$ scp * 172.25.0.35:`pwd`

01jf4fqq_1_1                                                                                      100%   23MB   3.8MB/s   00:06   

03jf4fr9_1_1                                                                                      100%  194KB 194.0KB/s   00:00   

04jf4frg_1_1                                                                                      100%  315MB   3.4MB/s   01:34   

08jf4fv9_1_1                                                                                      100%   13KB  13.0KB/s   00:00   

09jf4fvf_1_1                                                                                      100% 4608     4.5KB/s   00:00   

CON_0ajf4gqi_1_1                                                                                  100%   15MB   3.7MB/s   00:04  

 

       RAC2

       [oracle@rac2 backup]$ scp * 172.25.0.35:`pwd`

02jf4fql_1_1                                                                                      100% 7145KB   3.5MB/s   00:02   

05jf4frg_1_1                                                                                      100%  175MB   3.4MB/s   00:52   

06jf4ft0_1_1                                                                                      100%   15MB   1.5MB/s   00:10   

07jf4ftm_1_1                                                                                      100%   96KB  96.0KB/s   00:00   

 

 

、恢复备库

1、在主库添加指向备库的tnsname

       在主库的tnsnames.ora添加如下内容:

       STANDBY =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST =200.200.200.123)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = standby)

    )

 

2、在主库执行,利用auxiliary来恢复备库

[oracle@rac1 ~]$ $ORACLE_HOME/bin/rman target /  auxiliary sys/6212327@standby

 

Recovery Manager: Release 10.2.0.3.0 - Production on Wed Apr 30 19:37:05 2008

 

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

 

connected to target database: RAC (DBID=2232067446)

connected to auxiliary database: RAC (not mounted)

 

RMAN> run

 {

 allocate channel c1 device type disk format '/soft/backup/%U' connect sys/6212327@rac1;

2> 3> 4>  allocate channel c2 device type disk format '/soft/backup/%U' connect sys/6212327@rac2;

5>  allocate auxiliary channel ac1 device type disk format '/soft/backup/%U';    

6>  allocate auxiliary channel ac2 device type disk format '/soft/backup/%U';

7>  duplicate target database for standby;

8>  }

 

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: sid=132 instance=rac1 devtype=DISK

 

allocated channel: c2

channel c2: sid=134 instance=rac2 devtype=DISK

 

allocated channel: ac1

channel ac1: sid=155 devtype=DISK

 

allocated channel: ac2

channel ac2: sid=154 devtype=DISK

 

Starting Duplicate Db at 30-APR-08

 

contents of Memory Script.:

{

   restore clone standby controlfile;

   sql clone 'alter database mount standby database';

}

executing Memory Script

 

Starting restore at 30-APR-08

 

channel ac1: starting datafile backupset restore

channel ac1: restoring control file

channel ac1: reading from backup piece /soft/backup/CON_0ajf4gqi_1_1

channel ac1: restored backup piece 1

piece handle=/soft/backup/CON_0ajf4gqi_1_1 tag=TAG20080430T150554

channel ac1: restore complete, elapsed time: 00:00:04

output filename=/soft/oradata/rac/control01.ctl

output filename=/soft/oradata/rac/control02.ctl

output filename=/soft/oradata/rac/control03.ctl

Finished restore at 30-APR-08

 

sql statement: alter database mount standby database

 

contents of Memory Script.:

{

   set newname for tempfile  1 to

 "/soft/oradata/rac/raw6";

   switch clone tempfile all;

   set newname for datafile  1 to

 "/soft/oradata/rac/raw1";

   set newname for datafile  2 to

 "/soft/oradata/rac/raw3";

   set newname for datafile  3 to

 "/soft/oradata/rac/raw2";

   set newname for datafile  4 to

 "/soft/oradata/rac/raw5";

   set newname for datafile  5 to

 "/soft/oradata/rac/raw7";

   restore

   check readonly

   clone database

   ;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed temporary file 1 to /soft/oradata/rac/raw6 in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 30-APR-08

 

channel ac1: starting datafile backupset restore

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

restoring datafile 00002 to /soft/oradata/rac/raw3

restoring datafile 00004 to /soft/oradata/rac/raw5

channel ac1: reading from backup piece /soft/backup/05jf4frg_1_1

channel ac2: starting datafile backupset restore

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

restoring datafile 00001 to /soft/oradata/rac/raw1

restoring datafile 00003 to /soft/oradata/rac/raw2

restoring datafile 00005 to /soft/oradata/rac/raw7

channel ac2: reading from backup piece /soft/backup/04jf4frg_1_1

channel ac1: restored backup piece 1

piece handle=/soft/backup/05jf4frg_1_1 tag=TAG20080430T144919

channel ac1: restore complete, elapsed time: 00:01:22

channel ac2: restored backup piece 1

piece handle=/soft/backup/04jf4frg_1_1 tag=TAG20080430T144919

channel ac2: restore complete, elapsed time: 00:01:32

Finished restore at 30-APR-08

 

contents of Memory Script.:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy recid=6 stamp=653426781 filename=/soft/oradata/rac/raw1

datafile 2 switched to datafile

阅读(862) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册