码迷,mamicode.com
首页 > 其他好文 > 详细

搭建rac对单实例的MAA

时间:2014-08-26 19:12:26      阅读:344      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   java   io   for   

一:实验环境

 系统:redhat 4

 三台计算机rac1,rac2,dg.

  --其中rac为主库,单实例为备库

 已在虚拟机里搭建好集群环境(rac1,rac2);

 dg计算机里没有建任何数据库(只安装了Oracle软件)。

  bubuko.com,布布扣

  bubuko.com,布布扣

 

二:实验步骤

 

单实例环境部署请参考文档‘Linux下安装Oracle 10g(redhat 4)’

3.1:enable forced logging

--将主库设为强制归档

SQL> select force_logging from v$database;

 

FOR

---

NO

 

SQL> alter database force logging;

 

Database altered.

 

SQL> select force_logging from v$database;

 

FOR

---

YES

3.2:创建密码文件

在rac的两个节点上执行:

SQL> alter user sys identified by oracle;

 

User altered.

建密码文件:

cd /u01/app/oracle/product/10.2.0/db_1/dbs --注意,一定要在该路径下建密码文件

[oracle@rac1 dbs]$ orapwd file=orapwprod1 password=oracle entries=3 force=y

[oracle@rac2 dbs]$ orapwd file=orapwprod2 password=oracle entries=3 force=y

 

在备库上建密码文件

cd /u01/app/oracle/product/10.2.0/db_1/dbs

[oracle@dg dbs]$ orapwd file=orapwsdyprod password=oracle entries=3

3.3:configure a standby redo log

在任意一个节点上查询日志情况:

SQL> select group#,thread#,sequence#,bytes/1024/1024mb

  2  from v$log;

 

     GROUP#    THREAD#  SEQUENCE#  MB

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

 1     1        4  50

 2     1        5  50

 3     2        3  50

 4     2        4  50

SQL> select member from v$logfile;

 

MEMBER

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

+DATA/prod/onlinelog/group_2.262.856078815

+REDOLOG/prod/onlinelog/group_2.258.856078819

+DATA/prod/onlinelog/group_1.261.856078807

+REDOLOG/prod/onlinelog/group_1.257.856078813

+DATA/prod/onlinelog/group_3.266.856079013

+REDOLOG/prod/onlinelog/group_3.259.856079015

+DATA/prod/onlinelog/group_4.267.856079017

+REDOLOG/prod/onlinelog/group_4.260.856079019

 

8 rows selected.

 

用下面这个公式决定standby redo log file group的数量:

(每个节点日志组最大数+1)*节点数量

比如,这里每个节点都有两组日志,有两个节点,因此需要配置(2+1)*2=6组standby redo log file group.

 

建立standby redo log;

SQL> alter database add standby logfile thread 1 group 5 ‘+DATA‘ size 50m;

 

Database altered.

 

SQL> alter database add standby logfile thread 1 group 6 ‘+DATA‘ size 50m;

 

Database altered.

 

SQL> alter database add standby logfile thread 1 group 7 ‘+DATA‘ size 50m;

 

Database altered

SQL> alter database add standby logfile thread 2 group 8 ‘+DATA‘ size 50m;

 

Database altered.

 

SQL> alter database add standby logfile thread 2 group 9 ‘+DATA‘ size 50m;

 

Database altered.

 

SQL> alter database add standby logfile thread 2 group 10 ‘+DATA‘ size 50m;

 

Database altered.

 

在两个节点上都查看一下建的standby log file:

SQL> select group#,thread#,status

  2  from v$standby_log;

 

    GROUP#    THREAD# STATUS

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

         5          1 UNASSIGNED

         6          1 UNASSIGNED

         7          1 UNASSIGNED

         8          2 UNASSIGNED

         9          2 UNASSIGNED

        10          2 UNASSIGNED

 

6 rows selected.

 

3.4:Set Primary Database Initialization Parameters

 

在rac1节点上创建pfile(由于它原本Pfile内容只有SPFILE=‘+DG1/prod/spfileprod.ora‘这一句)

SQL> create pfile=‘/home/oracle/initprod1.ora‘ from spfile;

 

File created.

vi initprod.ora

 

添加如下内容:

*.LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(prod,sdyprod)‘

LOG_ARCHIVE_DEST_1=

 ‘LOCATION=+DATA/prod 

  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

  DB_UNIQUE_NAME=prod‘

LOG_ARCHIVE_DEST_2=

 ‘SERVICE=sdyprod LGWR ASYNC

  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 

  DB_UNIQUE_NAME=sdyprod‘

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_MAX_PROCESSES=3

 

 

FAL_SERVER=sdyprod

prod1.FAL_CLIENT=prod1

prod2.FAL_CLIENT=prod2

DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/datafile/‘,‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/tempfile/‘

LOG_FILE_NAME_CONVERT= ‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/onlinelog/‘,‘/u01/app/oracle/oradata/sdyprod/‘,‘+REDOLOG/prod/onlinelog/‘ 

STANDBY_FILE_MANAGEMENT=AUTO

 

 

看以该pfile文件能否登陆成功,并创建spfile(rac里建spfile时,不指定位置的话,会默认放在本地磁盘上)

SQL> startup force nomount pfile=‘/home/oracle/initprod1.ora‘;

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

SQL> create spfile=‘+DATA/prod/spfileprod.ora‘ from pfile=‘/home/oracle/initprod1.ora‘;

 

File created

 

在打开rac1之前,先把rac2的实例关掉,因为现在spfile已经改变了。

rac2上:shutdown immediate;

rac1上:startup force;

rac2上:startup;

 

/*

若rac2的库没关,rac1以修改后的spfile启动,会报错:

SQL> startup force;        

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

ORA-01105: mount is incompatible with mounts by other instances

ORA-01677: standby file name convert parameters differ from other instance

*/

 

3.5:enable archiving

 --若已经归档,这步可以隔过去了

3.6:Create a Backup Copy of the Primary Database Datafiles

(由于是rac环境,只能用rman备份了)

在rac1下做一个热备份(由于rac默认备份放在ASM下,所以这里备份需要手工指定位置):

RMAN> run {

2> allocate channel c1 type disk;

3> allocate channel c2 type disk;

4> backup full database format ‘/home/oracle/backup/%d_%s.bak‘;

5> }

 

--在rac1下的/home/oracle/backup可以看到备份集,rac2下的/home/oracle/backup下看不到。

3.7:create a control file for the standby database

--在任意一个节点上皆可

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              96470608 bytes

Database Buffers          184549376 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database create standby controlfile as ‘/home/oracle/sdyprod_control01.ctl‘;

 

Database altered.

 

SQL> alter database open;

 

Database altered.

3.8: Prepare an Initialization Parameter File for the Standby Database

 

将rac1下建的初始化参数文件远程拷贝到备库192.168.8.225上:

[oracle@rac1 ~]$ 

scp initprod1.ora 192.168.8.225:/u01/app/oracle/product/10.2.0/db_1/dbs/initsdyprod.ora

 

The authenticity of host ‘192.168.8.225 (192.168.8.225)‘ can‘t be established.

RSA key fingerprint is 6d:1d:6b:1a:34:63:f2:f4:4c:15:0d:eb:60:e0:13:4d.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘192.168.8.225‘ (RSA) to the list of known hosts.

oracle@192.168.8.225‘s password: 

initprod1.ora                                                                                                                                                100% 2214     2.2KB/s   00:00  

  

拷贝过来的initprod1.ora文件内容:

prod1.__db_cache_size=163577856

prod2.__db_cache_size=155189248

prod1.__java_pool_size=4194304

prod2.__java_pool_size=4194304

prod1.__large_pool_size=4194304

prod2.__large_pool_size=4194304

prod1.__shared_pool_size=109051904

prod2.__shared_pool_size=117440512

prod1.__streams_pool_size=0

prod2.__streams_pool_size=0

*.audit_file_dest=‘/u01/app/oracle/admin/prod/adump‘

*.background_dump_dest=‘/u01/app/oracle/admin/prod/bdump‘

*.cluster_database_instances=2

*.cluster_database=true

*.compatible=‘10.2.0.1.0‘

*.control_files=‘+DATA/prod/controlfile/current.260.856078805‘,‘+REDOLOG/prod/controlfile/current.256.856078805‘

*.core_dump_dest=‘/u01/app/oracle/admin/prod/cdump‘

*.db_block_size=8192

*.db_create_file_dest=‘+DATA‘

*.db_domain=‘‘

*.db_file_multiblock_read_count=16

*.db_name=‘prod‘

*.db_recovery_file_dest=‘+REDOLOG‘

*.db_recovery_file_dest_size=2147483648

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=prodXDB)‘

prod1.instance_number=1

prod2.instance_number=2

*.job_queue_processes=10

*.log_archive_dest_1=‘LOCATION=+DATA/prod‘

*.log_archive_format=‘%t_%s_%r.dbf‘

*.open_cursors=300

*.pga_aggregate_target=94371840

*.processes=150

*.remote_listener=‘LISTENERS_PROD‘

*.remote_login_passwordfile=‘exclusive‘

*.sga_target=285212672

prod2.thread=2

prod1.thread=1

*.undo_management=‘AUTO‘

prod2.undo_tablespace=‘UNDOTBS2‘

prod1.undo_tablespace=‘UNDOTBS1‘

*.user_dump_dest=‘/u01/app/oracle/admin/prod/udump‘

 

*.LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(prod,sdyprod)‘

LOG_ARCHIVE_DEST_1=

 ‘LOCATION=+DATA/prod/

  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

  DB_UNIQUE_NAME=prod‘

LOG_ARCHIVE_DEST_2=

 ‘SERVICE=sdyprod LGWR ASYNC

  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 

  DB_UNIQUE_NAME=sdyprod‘

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_MAX_PROCESSES=3

 

 

FAL_SERVER=sdyprod

prod1.FAL_CLIENT=prod1

prod2.FAL_CLIENT=prod2

DB_FILE_NAME_CONVERT=‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/datafile/‘,‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/tempfile/‘

LOG_FILE_NAME_CONVERT= ‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/onlinelog/‘,‘/u01/app/oracle/oradata/sdyprod/‘,‘+REDOLOG/prod/onlinelog/‘ 

STANDBY_FILE_MANAGEMENT=AUTO

 

相对于修改前的参数文件,修改后的initsdyprod.ora如下(改动的地方已用黄色阴影标出):

prod1.__db_cache_size=163577856

prod2.__db_cache_size=155189248

prod1.__java_pool_size=4194304

prod2.__java_pool_size=4194304

prod1.__large_pool_size=4194304

prod2.__large_pool_size=4194304

prod1.__shared_pool_size=109051904

prod2.__shared_pool_size=117440512

prod1.__streams_pool_size=0

prod2.__streams_pool_size=0

*.audit_file_dest=‘/u01/app/oracle/admin/sdyprod/adump‘

*.background_dump_dest=‘/u01/app/oracle/admin/sdyprod/bdump‘

#*.cluster_database_instances=2

#*.cluster_database=true

*.compatible=‘10.2.0.1.0‘

*.control_files=‘/u01/app/oracle/admin/sdyprod/sdyprod_control01.ctl‘

*.core_dump_dest=‘/u01/app/oracle/admin/sdyprod/cdump‘

*.db_block_size=8192

*.db_create_file_dest=‘/u01/app/oracle/oradata‘

*.db_domain=‘‘

*.db_file_multiblock_read_count=16

*.db_name=‘prod‘

*.db_recovery_file_dest=‘‘

*.db_recovery_file_dest_size=2147483648

*.dispatchers=‘(PROTOCOL=TCP) (SERVICE=prodXDB)‘

prod.instance_number=1

*.job_queue_processes=10

#*.log_archive_dest_1=‘LOCATION=+DATA/prod‘

#*.log_archive_format=‘%t_%s_%r.dbf‘

*.open_cursors=300

*.pga_aggregate_target=94371840

*.processes=150

*.remote_listener=‘LISTENERS_PROD‘

*.remote_login_passwordfile=‘exclusive‘

*.sga_target=285212672

sdyprod.thread=1

*.undo_management=‘AUTO‘

sdyprod.undo_tablespace=‘UNDOTBS1‘

*.user_dump_dest=‘/u01/app/oracle/admin/sdyprod/udump‘

db_unique_name=sdyprod

*.LOG_ARCHIVE_CONFIG=‘DG_CONFIG=(prod,sdyprod)‘

LOG_ARCHIVE_DEST_1=

 ‘LOCATION=/arch/sdyprod

  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)

  DB_UNIQUE_NAME=sdyprod

LOG_ARCHIVE_DEST_2=

 ‘SERVICE=prod LGWR ASYNC

  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) 

  DB_UNIQUE_NAME=prod

LOG_ARCHIVE_DEST_STATE_1=ENABLE

LOG_ARCHIVE_DEST_STATE_2=ENABLE

REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

LOG_ARCHIVE_FORMAT=%t_%s_%r.arc

LOG_ARCHIVE_MAX_PROCESSES=3

 

 

FAL_SERVER=prod

FAL_CLIENT=sdyprod

DB_FILE_NAME_CONVERT=‘+DATA/prod/datafile/‘,‘/u01/app/oracle/oradata/sdyprod/‘,‘+DATA/prod/tempfile/‘,‘/u01/app/oracle/oradata/sdyprod/‘

LOG_FILE_NAME_CONVERT= ‘+DATA/prod/onlinelog/‘,‘/u01/app/oracle/oradata/sdyprod/‘,‘+REDOLOG/prod/onlinelog/‘ ,‘/u01/app/oracle/oradata/sdyprod/‘

STANDBY_FILE_MANAGEMENT=AUTO

 

3.9:在备库上建立相关目录

 

--建归档路径:/arch/sdyprod

 

[root@dg~]# mkdir -p /arch/sdyprod

[root@dg ~]# chown oracle:dba /arch/sdyprod

 

[oracle@dg ~]$  mkdir -p /u01/app/oracle/admin/sdyprod

[oracle@dg ~]$  mkdir -p /u01/app/oracle/oradata/sdyprod

[oracle@dg admin]$ cd sdyprod/

[oracle@dg sdyprod]$ ls

[oracle@dg sdyprod]$ mkdir adump bdump cdump udump

 

--创建备份文件夹

[oracle@dg ~]$  cd /home/oracle

[oracle@dg ~]$ ls

Desktop  initsdyprod.ora  software

[oracle@dg ~]$ mkdir backup

3.10:Copy Files from the Primary System to the Standby System(用RMAN方式)

  [oracle@rac1 backup]$ scp *.bak 192.168.8.225:/home/oracle/backup/

oracle@192.168.8.225‘s password: 

PROD_1.bak                                                                                                                                                100%  362MB  14.5MB/s   00:25    

PROD_2.bak                                                                                                                                                   100%  257MB  13.5MB/s   00:19    

PROD_3.bak                                                                                                                                                   100%   15MB  14.6MB/s   00:01    

PROD_4.bak                                                                                                                                                   100%   96KB  96.0KB/s   00:00    

 

                           

[oracle@rac1 backup]$ cd /home/oracle

[oracle@rac1 ~]$ scp sdyprod_control01.ctl 192.168.8.225:/home/oracle/

oracle@192.168.8.225‘s password: 

sdyprod_control01.ctl                         100%   15MB   7.3MB/s   00:02

 注意:拷贝的数据文件和控制文件必须得和原来的路径一模一样,否则会出错。

3.11:Configure listeners for the primary and standby databases

--配监听和tnsnames.ora

[oracle@rac1 admin]$ cd /u01/app/oracle/product/10.2.0/db_1/network/admin

[oracle@rac1 admin]$ ls

listener.ora  samples  shrept.lst  tnsnames.ora

 

在rac1,rac2的tnsnames.ora中添加如下内容:

sdyprod=

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = sdyprod)

      (UR=A)

    )

  )

在备库192.168.8.225中添加如下内容:

LISTENERS_PROD =

  (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))

  )

 

PROD =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))

    (LOAD_BALANCE = yes)

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = prod)

    )

  )

 

PROD2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = prod)

      (INSTANCE_NAME = prod2)

    )

  )

 

PROD1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = prod)

      (INSTANCE_NAME = prod1)

    )

  )

tnsping一下,看能否Ping,如以tnsping prod1为例:

 bubuko.com,布布扣

看到‘OK’字样,表示ping通了。

 

在备库lsnrctl start

lsnrctl status

 

3.12 在备库上修改/etc/hosts文件

 

# vi /etc/hosts

 

 

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1        localhost

192.168.8.225   dg

 

 

192.168.8.220  rac1

192.168.8.222  rac1-vip

10.10.10.1    rac1-priv

 

 

192.168.8.221  rac2

192.168.8.223  rac2-vip

10.10.10.2    rac2-priv

 

 

3.13: Create a server parameter file for the standby database

--在备库上:

SQL> startup nomount; 

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size              92276304 bytes

Database Buffers          188743680 bytes

Redo Buffers                2973696 bytes

SQL> create spfile from pfile;

 

File created

3.14:在主库恢复数据库

-------在主库通过rman duplicate standby db

 

[oracle@rac1 admin]$ rman target /

 

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Dec 12 07:35:04 2012

 

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

 

connected to target database: PROD (DBID=212879047)

 

RMAN> connect auxiliary sys/oracle@sdyprod;

 

connected to auxiliary database: PROD (not mounted)

RMAN> duplicate target database for standby

2> ;

 

Starting Duplicate Db at 26-AUG-14

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: sid=155 devtype=DISK

 

contents of Memory Script:

{

   restore clone standby controlfile;

   sql clone ‘alter database mount standby database‘;

}

executing Memory Script

 

Starting restore at 26-AUG-14

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: copied control file copy

input filename=/home/oracle/sdyprod_control01.ctl

output filename=/u01/app/oracle/admin/sdyprod/sdyprod_control01.ctl

Finished restore at 26-AUG-14

 

sql statement: alter database mount standby database

released channel: ORA_AUX_DISK_1

 

contents of Memory Script:

{

   set newname for tempfile  1 to 

 "/u01/app/oracle/oradata/sdyprod/temp.263.856078825";

   switch clone tempfile all;

   set newname for datafile  1 to 

 "/u01/app/oracle/oradata/sdyprod/system.256.856078713";

   set newname for datafile  2 to 

 "/u01/app/oracle/oradata/sdyprod/undotbs1.258.856078719";

   set newname for datafile  3 to 

 "/u01/app/oracle/oradata/sdyprod/sysaux.257.856078715";

   set newname for datafile  4 to 

 "/u01/app/oracle/oradata/sdyprod/users.259.856078719";

   set newname for datafile  5 to 

 "/u01/app/oracle/oradata/sdyprod/example.264.856078831";

   set newname for datafile  6 to 

 "/u01/app/oracle/oradata/sdyprod/undotbs2.265.856078943";

   restore

   check readonly

   clone database

   ;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed temporary file 1 to /u01/app/oracle/oradata/sdyprod/temp.263.856078825 in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 26-AUG-14

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: sid=155 devtype=DISK

 

skipping datafile 2; already restored to file /u01/app/oracle/oradata/sdyprod/undotbs1.258.856078719

skipping datafile 3; already restored to file /u01/app/oracle/oradata/sdyprod/sysaux.257.856078715

skipping datafile 5; already restored to file /u01/app/oracle/oradata/sdyprod/example.264.856078831

skipping datafile 1; already restored to file /u01/app/oracle/oradata/sdyprod/system.256.856078713

skipping datafile 4; already restored to file /u01/app/oracle/oradata/sdyprod/users.259.856078719

skipping datafile 6; already restored to file /u01/app/oracle/oradata/sdyprod/undotbs2.265.856078943

restore not done; all files readonly, offline, or already restored

Finished restore at 26-AUG-14

 

contents of Memory Script:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy recid=4 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/system.256.856078713

datafile 2 switched to datafile copy

input datafile copy recid=5 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/undotbs1.258.856078719

datafile 3 switched to datafile copy

input datafile copy recid=6 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/sysaux.257.856078715

datafile 4 switched to datafile copy

input datafile copy recid=7 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/users.259.856078719

datafile 5 switched to datafile copy

input datafile copy recid=8 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/example.264.856078831

datafile 6 switched to datafile copy

input datafile copy recid=9 stamp=856594930 filename=/u01/app/oracle/oradata/sdyprod/undotbs2.265.856078943

Finished Duplicate Db at 26-AUG-14

 

RMAN> 

 

 

3.15:在备库上应用日志

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

查看报警日志或者v$archived_log,看是否同步归档日志。

在主库上scott用户下的表t插入一条数据:

SQL> insert into t values(3);

 

1 row created.

 

SQL> commit;

 

Commit complete.

在备库上查看一下:

SQL> select * from t;

select * from t

              *

ERROR at line 1:

ORA-01219: database not open: queries allowed on fixed tables/views only

由于,在read only下查看,会导致应用日志的延迟,于是决定,在备库切换成主库后再查看。

3.16:角色切换

在主库上关掉其他实例,只剩一个实例以切换到备库:

进rac2

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

rac1

 

SQL> select switchover_status from v$database;

 

SWITCHOVER_STATUS

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

SESSIONS ACTIVE  --表示有活动的会话,需要kill掉

 

 

SQL> select sid,serial#,username from v$session where username is not null;

 

       SID    SERIAL# USERNAME

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

       124          8 SYS

       131          3 SYS

       132          9 SYS

       151         17 SYS

       152          9 SYS

 

SQL> select distinct sid from v$mystat;

 

       SID

----------

       124

 

SQL> alter system kill session ‘131,3‘;

 

System altered.

 

SQL> alter system kill session ‘132,9‘;

 

System altered.

 

SQL> alter system kill session ‘151,17‘;

 

System altered.

 

SQL> alter system kill session ‘152,9‘;

 

System altered.

SQL> alter database commit to switchover to physical standby with session shutdown;

 

Database altered.

 

SQL> select status from v$instance;

 

STATUS

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

STARTED

 

SQL> shutdown immediate;

ORA-01507: database not mounted

 

 

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area  285212672 bytes

Fixed Size                  1218992 bytes

Variable Size             100664912 bytes

Database Buffers          180355072 bytes

Redo Buffers                2973696 bytes

--必须得先关库,再startup mount,而不是alter database mount;否则报错

Database mounted.

 

进备库:

 

SQL> alter database commit to switchover to primary with session shutdown ;

alter database commit to switchover to primary with session shutdown

*

ERROR at line 1:

ORA-16139: media recovery required

 

 

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

 

Database altered.

 

SQL> alter database commit to switchover to primary with session shutdown ;

 

Database altered.

 

SQL> alter database open;

 

 

SQL> select open_mode

  2  from v$database;

 

OPEN_MODE

----------

READ WRITE

 

SQL> select *

  2  from scott.t;

 

ID

----------

 3

 1

 2

 

--备库切换为主库后,看到了之前的主库插入的数据3。

 

搭建rac对单实例的MAA

标签:des   style   blog   http   color   os   java   io   for   

原文地址:http://www.cnblogs.com/yabingshi/p/3937856.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!