一步一步实现 oracle data guard

一步一步实现oracle data guard。

Oracle data guard 的实施目标,将主机 guohuiorcl2(IP 192.168.31.128)上的oracle archivelog日志传输到 主机 guohuiorcl1(IP 192.168.31.129)上。

期间用到的主机如下

 

 

1、主机guohuilinuxas31

rman 备份管理服务器,在其上建立 rman catalog,对其他主机进行rman 备份与恢复。

操作系统环境 Linux ES3-U9

IP 192.168.31.130

Netmark 255.255.255.0

Getway 192.168.31.1

主机名 guohuilinuxas31

实例名 orcl

Oracle 版本:Oracle Database 10gEnterprise Edition Release 10.2.0.1.0

主机 guohuiorcl1

 

 

2、备用数据库

操作系统环境 Linux ES5.4

IP 192.168.31.129

Netmark 255.255.255.0

Getway 192.168.31.1

主机名 guohuiorcl1

实例名 orcl

Oracle 版本:Oracle Database 10gEnterprise Edition Release 10.2.0.1.0

主机 guohuiorcl2

 

 

3、主用数据库

操作系统环境 Linux ES5.4

IP 192.168.31.128

Netmark 255.255.255.0

Getway 192.168.31.1

主机名 guohuiorcl2

实例名 orcl

Oracle 版本:Oracle Database 10gEnterprise Edition Release 10.2.0.1.0

 

准备主用数据库的环境变量

主机 guohuiorcl2 oracle 用户环境

[oracle@guohuiorcl2 ~]$ cat .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

TMP=/tmp;export TMP

TMPDIR=$TMP;export TMPDIR

ORACLE_BASE=/home/oracle/oracle;export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME

ORACLE_SID=orcl;export ORACLE_SID

ORACLE_TERM=xterm;export ORACLE_TERM

PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export PATH=$PATH:/sbin

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;

export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;export CLASSPATH

if [$USER = "oracle"]; then

  if [$SHELL = "bin/ksh"]; then

    ulimit -p 16384

    ulimit -n 65536

  else

    ulimit -u 16384 -n 65536

  fi

fi

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME

#xhost local:oracle

 

第一步:检查主用数据库 guohuiorcl2 上的oracle 是否开启了archive 。

[oracle@guohuiorcl2 ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Apr 16 07:10:33 2011

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

SQL> connect /as sysdba

Connected.

SQL> select dbid,name,log_mode from v$database;

      DBID NAME      LOG_MODE

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

1265371036 ORCL      NOARCHIVELOG

系统显示没有开启 archive log 功能。

开启 archive。

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area  243269632 bytes

Fixed Size                  1218748 bytes

Variable Size              62916420 bytes

Database Buffers          176160768 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     3

Next log sequence to archive   5

Current log sequence           5

设置 archvelog 的日志保存地址。

用oracle 用户执行

SQL> host mkdir –p /home/oracle/oracle/oradata/orcl/archive

SQL> alter database force logging;

Database altered.

SQL>

SQL> alter system set log_archive_dest_1=” /home/oracle/oracle/oradata/orcl/archive”;

System altered.

SQL> show parameter log_archive_format;

NAME                                 TYPE        VALUE

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

log_archive_format                   string      %t_%s_%r.dbf

执行archive log 日志切换。

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

检查一下 archive log。

SQL> host ls /home/oracle/oracle/oradata/orcl/archive

1_5_737590303.dbf  1_6_737590303.dbf  1_7_737590303.dbf  1_8_737590303.dbf  1_9_737590303.dbf

可以看到 archivelog 已经生成在指定目录下。

 

 

在主机 guohuiorcl2上创建pfile文件。

SQL> create pfile from spfile;

File created.

查看该pfile 文件

[oracle@guohuiorcl2 dbs]$ cat initorcl.ora

orcl.__db_cache_size=176160768

orcl.__java_pool_size=4194304

orcl.__large_pool_size=4194304

orcl.__shared_pool_size=54525952

orcl.__streams_pool_size=0

*.audit_file_dest='/home/oracle/oracle/admin/orcl/adump'

*.background_dump_dest='/home/oracle/oracle/admin/orcl/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/home/oracle/oracle/oradata/orcl/control01.ctl','/home/oracle/oracle/oradata/orcl/control02.ctl','/home/oracle/oracle/oradata/orcl/control03.ctl'

*.core_dump_dest='/home/oracle/oracle/admin/orcl/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='orcl'

*.db_recovery_file_dest='/home/oracle/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.job_queue_processes=10

*.log_archive_dest_1='location=/home/oracle/oracle/oradata/orcl/archive'

*.open_cursors=300

*.pga_aggregate_target=80740352

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=243269632

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/home/oracle/oracle/admin/orcl/udump'

修改 initorcl.ora 如下

[oracle@guohuiorcl2 dbs]$ cat initorcl.ora

orcl.__db_cache_size=176160768

orcl.__java_pool_size=4194304

orcl.__large_pool_size=4194304

orcl.__shared_pool_size=54525952

orcl.__streams_pool_size=0

*.audit_file_dest='/home/oracle/oracle/admin/orcl/adump'

*.background_dump_dest='/home/oracle/oracle/admin/orcl/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/home/oracle/oracle/oradata/orcl/control01.ctl','/home/oracle/oracle/oradata/orcl/control02.ctl','/home/oracle/oracle/oradata/orcl/control03.ctl'

*.core_dump_dest='/home/oracle/oracle/admin/orcl/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='orcl'

*.db_recovery_file_dest='/home/oracle/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.dg_broker_start=TRUE

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.fal_client='orcl'

*.fal_server='orclsby1'

*.job_queue_processes=10

*.log_archive_dest_1='location=/home/oracle/oracle/oradata/orcl/archive'

*.log_archive_dest_2='service=orclsby1 LGWR'

*.open_cursors=300

*.pga_aggregate_target=80740352

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=243269632

*.standby_archive_dest='/home/oracle/oracle/oradata/orcl/archive'

*.standby_file_management='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/home/oracle/oracle/admin/orcl/udump'

[oracle@guohuiorcl2 dbs]$

注意:

以下是增加的参数

*.dg_broker_start=TRUE

*.fal_client=' orcl'

*.fal_server='orclsby1'

*.log_archive_dest_2='SERVICE='orclsby1 LGWR'

*.standby_archive_dest='/home/oracle/oracle/oradata/orcl/archive'

*.standby_file_management='AUTO'

 

[oracle@guohuiorcl2 dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 17 23:02:02 2011

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

SQL> connect / as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> create spfile from pfile;

File created.

SQL> startup mount;

ORACLE instance started.

Total System Global Area  243269632 bytes

Fixed Size                  1218748 bytes

Variable Size              62916420 bytes

Database Buffers          176160768 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

 

在 主机 guohuilinuxas31 上建立rman 的恢复管理目录,准备把 guoorcl2 上的 orcl 数据库备份到 guohuilinuxas31 ,再恢复到 guoorcl1 上

在主机guohuilinuxas31上 登入oracle

[oracle@guohuilinuxas31 oracle]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 19 14:06:12 2011

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

SQL> connect /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  285212672 bytes

Fixed Size                  1218968 bytes

Variable Size              92276328 bytes

Database Buffers          184549376 bytes

Redo Buffers                7168000 bytes

Database mounted.

Database opened.

SQL> create tablespace cattbs datafile '/u01/app/oracle/oradata/orcl/cattbs01.dbf' size 200M extent management local autoallocate;

Tablespace created.

SQL>  create user rman817 identified by rman temporary tablespace temp default tablespace cattbs quota unlimited on cattbs;

User created.

SQL> grant connect,recovery_catalog_owner to rman817;

Grant succeeded.

 

以上指令在rman主机guohuilinuxas31上创建了rman账户。

在主机guohuilinuxas31上添加主用数据库 guohuiorcl2上oracle的tns链接

[oracle@guohuilinuxas31 network]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

ORCLA =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )

[oracle@guohuilinuxas31 network]$

验证tns可达

[oracle@guohuilinuxas31 network]$ tnsping orcla

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 28-APR-2011 23:16:24

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

Used parameter files:

/u01/app/oracle/product/10.2.0/db_1/network/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.128)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (0 msec)

[oracle@guohuilinuxas31 network]$

在主机guohuilinuxas31上注册主机 guohuiorcl2的oracle为目标数据库

首先改掉主机guohuilinuxas31上 的 .bash_profile 的path变量参数,因为linux有自己的rman指令,会卡住oracle的rman,把oracle的 指令目录前置。

PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin;export PATH

改成

PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin;export PATH

然后 [oracle@guohuilinuxas31 oracle]$ source .bash_profile

让修改的参数生效。

验证一下:

oracle@guohuilinuxas31 oracle]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Apr 28 23:47:01 2011

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

RMAN> connect catalog rman817/rman@orcl

connected to recovery catalog database

RMAN> create catalog tablespace cattbs;

recovery catalog created

退出rman,然后再次进入

[oracle@guohuilinuxas31 oracle]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Apr 28 23:58:10 2011

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

RMAN> connect target sys/kelantas@orcla

connected to target database: ORCL (DBID=1265371036)

RMAN> connect catalog rman817/rman@orcl

connected to recovery catalog database

RMAN> register database

2> ;

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

RMAN> list incarnation;

List of Database Incarnations

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time

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

1       8       ORCL     1265371036       PARENT  1          30-JUN-05

1       2       ORCL     1265371036       CURRENT 446075     12-DEC-10

RMAN> backup database format='/home/oracle/%U_%s.bak';

Starting backup at 29-APR-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=143 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/home/oracle/oracle/oradata/orcl/system01.dbf

input datafile fno=00003 name=/home/oracle/oracle/oradata/orcl/sysaux01.dbf

input datafile fno=00005 name=/home/oracle/oracle/oradata/orcl/example01.dbf

input datafile fno=00002 name=/home/oracle/oracle/oradata/orcl/undotbs01.dbf

input datafile fno=00004 name=/home/oracle/oracle/oradata/orcl/users01.dbf

channel ORA_DISK_1: starting piece 1 at 29-APR-11

channel ORA_DISK_1: finished piece 1 at 29-APR-11

piece handle=/home/oracle/01mavib9_1_1_1.bak tag=TAG20110429T065744 comment=NONE

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

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 29-APR-11

channel ORA_DISK_1: finished piece 1 at 29-APR-11

piece handle=/home/oracle/02mavihq_1_1_2.bak tag=TAG20110429T065744 comment=NONE

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

Finished backup at 29-APR-11

RMAN> Backup filesperset 10 ArchiveLog all format='/home/oracle/%U_%s.bak';

Starting backup at 29-APR-11

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=5 recid=1 stamp=748598287

input archive log thread=1 sequence=6 recid=2 stamp=748598288

input archive log thread=1 sequence=7 recid=3 stamp=748598294

input archive log thread=1 sequence=8 recid=4 stamp=748598296

input archive log thread=1 sequence=9 recid=5 stamp=748598297

input archive log thread=1 sequence=10 recid=6 stamp=748739337

input archive log thread=1 sequence=11 recid=7 stamp=749714659

input archive log thread=1 sequence=12 recid=8 stamp=749718437

channel ORA_DISK_1: starting piece 1 at 29-APR-11

channel ORA_DISK_1: finished piece 1 at 29-APR-11

piece handle=/home/oracle/03mavit7_1_1_3.bak tag=TAG20110429T070718 comment=NONE

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

Finished backup at 29-APR-11

 

 

将备份集对应的文件从 主数据库guohuiorcl2 传到备用数据库guohuiorcl1。

[oracle@guohuiorcl2 ~]$ ftp guohuiorcl1

Connected to guohuiorcl1.

220 (vsFTPd 2.0.5)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (guohuiorcl1:oracle): oracle

331 Please specify the password.

Password:

230 Login successful.

ftp> pwd

257 "/home/oracle"

ftp> bin

200 Switching to Binary mode.

ftp> prompt off

Interactive mode off.

ftp> mput *.bak

local: 01mavib9_1_1_1.bak remote: 01mavib9_1_1_1.bak

227 Entering Passive Mode (192,168,31,129,203,54)

150 Ok to send data.

226 File receive OK.

637140992 bytes sent in 2.5e+02 seconds (2.5e+03 Kbytes/s)

local: 02mavihq_1_1_2.bak remote: 02mavihq_1_1_2.bak

227 Entering Passive Mode (192,168,31,129,145,184)

150 Ok to send data.

226 File receive OK.

7143424 bytes sent in 3.8 seconds (1.8e+03 Kbytes/s)

local: 03mavit7_1_1_3.bak remote: 03mavit7_1_1_3.bak

227 Entering Passive Mode (192,168,31,129,205,39)

150 Ok to send data.

226 File receive OK.

34118144 bytes sent in 5 seconds (6.7e+03 Kbytes/s)

ftp>

在备用数据库上guohuiorcl1上检查传输过来的文件集对应的文件:

[oracle@guohuiorcl1 ~]$ ls -la *.bak

-rw-r--r-- 1 oracle oinstall 637140992 04-30 09:21 01mavib9_1_1_1.bak

-rw-r--r-- 1 oracle oinstall   7143424 04-30 09:21 02mavihq_1_1_2.bak

-rw-r--r-- 1 oracle oinstall  34118144 04-30 09:21 03mavit7_1_1_3.bak

要求安装备用数据库的oracle 的主机 guohuiorcl1的主机分区环境和oracle相关的目录结构和主机 guohuiorcl2的完全相同。其实这个不是强制要求,只是这样做比较省事。否则,需要改pfile.ora 文件,把恢复主机所在目录结构改到 pfile.ora 里面。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

以上的是主用数据库 guohuiorcl2 上的 主机分区结构。

$ORACLE_BASE=/home/oracle/oracle

数据文件、日志文件、控制文件的目录

$ORACLE_BASE/oradata/orcl

归档日志文件目录

$ORACLE_BASE/oradata/orcl/archive

[oracle@guohuiorcl2 admin]$ ls $ORACLE_BASE/admin/orcl

adump  bdump  cdump  dpdump  pfile  udump

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

##############################################################################

 

以上的是主机 guohuiorcl1 上的 主机分区结构。

$ORACLE_BASE=/home/oracle/oracle

数据文件、日志文件、控制文件的目录

$ORACLE_BASE/oradata/orcl

归档日志文件目录(补建一下)

$ORACLE_BASE/oradata/orcl/archive

[oracle@guohuiorcl2 admin]$ ls $ORACLE_BASE/admin/orcl

adump  bdump  cdump  dpdump  pfile  udump

##############################################################################

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

修改备用数据库guohuiorcl1的 环境变量与主用数据库 guohuiorcl2的完全相同。这样搞比较省事,真实的生产环境如果相同,两个库更容易管理。

主用数据库 guohuiorcl2的环境如下:

[oracle@guohuiorcl2 ~]$ cat .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin

#export PATH

TMP=/tmp;export TMP

TMPDIR=$TMP;export TMPDIR

ORACLE_BASE=/home/oracle/oracle;export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME

ORACLE_SID=orcl;export ORACLE_SID

ORACLE_TERM=xterm;export ORACLE_TERM

PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:/sbin:/usr/local/bin:/usr/local/sbin;export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;export CLASSPATH

if [$USER = "oracle"]; then

  if [$SHELL = "bin/ksh"]; then

    ulimit -p 16384

    ulimit -n 65536

  else

    ulimit -u 16384 -n 65536

  fi

fi

#ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME

#xhost local:oracle

[oracle@guohuiorcl2 ~]$

备用数据库 guohuiorcl1的oracle用户的环境如下

[oracle@guohuiorcl1 ~]$ cat .bash_profile

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin

#export PATH

TMP=/tmp;export TMP

TMPDIR=$TMP;export TMPDIR

ORACLE_BASE=/home/oracle/oracle;export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME

ORACLE_SID=orcl;export ORACLE_SID

ORACLE_TERM=xterm;export ORACLE_TERM

PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export PATH=$PATH:/sbin

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;

export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;export CLASSPATH

if [$USER = "oracle"]; then

  if [$SHELL = "bin/ksh"]; then

    ulimit -p 16384

    ulimit -n 65536

  else

    ulimit -u 16384 -n 65536

  fi

fi

#ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1;export ORACLE_HOME

#xhost local:oracle

主用数据库 guohuiorcl2 与 备用数据库 guohuiorcl1 的关于oracle的环境是一样的。其他的环境变量,稍有不同,但不影响我们做data guard。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

创建主机guohuiorcl1备用数据库的参数文件

因为guoorcl1上已经安装过一个可以启动的orcl实例,所有有这个pfile.ora文件,如果guoorcl1上只是安装了软件,就需要重guoorcl2上把 pfile.ora 或者 spfile.ora 文件给传过了,而且还得改这个文件。

 [oracle@guohuiorcl1 dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 1 08:25:56 2011

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

SQL> connect /as sysdba

Connected to an idle instance.

SQL> create pfile from spfile;

File created.

编辑 pfile initorcl.ora

得到如下结果

[oracle@guohuiorcl1 dbs]$ cat initorcl.ora

orcl.__db_cache_size=163577856

orcl.__java_pool_size=4194304

orcl.__large_pool_size=4194304

orcl.__shared_pool_size=67108864

orcl.__streams_pool_size=0

*.audit_file_dest='/home/oracle/oracle/admin/orcl/adump'

*.background_dump_dest='/home/oracle/oracle/admin/orcl/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/home/oracle/oracle/oradata/orcl/control01.ctl','/home/oracle/oracle/oradata/orcl/control02.ctl','/home/oracle/oracle/oradata/orcl/control03.ctl'

*.core_dump_dest='/home/oracle/oracle/admin/orcl/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='orcl'

*.db_recovery_file_dest='/home/oracle/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=2147483648

*.dg_broker_start=TRUE

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.fal_client='orclsby1'

*.fal_server='orcl'

*.job_queue_processes=10

*.log_archive_dest_1='location=/home/oracle/oracle/oradata/orcl/archive'

*.log_archive_dest_2='SERVICE=orcl LGWR'

*.open_cursors=300

*.pga_aggregate_target=80740352

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=243269632

*.standby_archive_dest='/home/oracle/oracle/oradata/orcl/archive'

*.standby_file_management='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/home/oracle/oracle/admin/orcl/udump'

[oracle@guohuiorcl1 dbs]$

注意:

以下是增加的参数

*.dg_broker_start=TRUE

*.fal_client='orclsby1'

*.fal_server='orcl'

*.log_archive_dest_1='location=/home/oracle/oracle/oradata/orcl/archive'

*.log_archive_dest_2='SERVICE=orcl LGWR'

*.standby_archive_dest='/home/oracle/oracle/oradata/orcl/archive'

*.standby_file_management='AUTO'

 

把口令文件从主数据库主机 guohuiorcl2  ftp 到备用数据库主机 guohuiorcl1

ftp> open guohuiorcl1

Connected to guohuiorcl1.

220 (vsFTPd 2.0.5)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (guohuiorcl1:oracle): oracle

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> cd /home/oracle/oracle/product/10.2.0/db_1/dbs

250 Directory successfully changed.

ftp> lcd /home/oracle/oracle/product/10.2.0/db_1/dbs

Local directory now /home/oracle/oracle/product/10.2.0/db_1/dbs

ftp> bin

200 Switching to Binary mode.

ftp> put  orapworcl

local: orapworcl remote: orapworcl

200 PORT command successful. Consider using PASV.

150 Ok to send data.

226 File receive OK.

1536 bytes sent in 0.021 seconds (70 Kbytes/s)

 

配置主服务器主机 guohuiorcl2的网络

[oracle@guohuiorcl2 admin]$ cat listener.ora

# listener.ora Network Configuration File: /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)

      (PROGRAM = extproc)

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

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

    )

  )

# 不要把 guohuiorcl2 改成IP,否则会无法连接到

[oracle@guohuiorcl2 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

#注意,这个参数需要和 pfile.ora 参数里面的*.fal_client 对应

ORCL =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

GUOORCL1 =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

#注意,这个参数需要和 pfile.ora 参数里面的*.fal_server 对应

ORCLSBY1=

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )

 

配置备用服务器主机 guohuiorcl1的网络

[oracle@guohuiorcl1 admin]$ cat listener.ora

# listener.ora Network Configuration File: /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = PLSExtProc)

      (ORACLE_HOME = /home/oracle/oracle/product/10.2.0/db_1)

      (PROGRAM = extproc)

    )

  )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

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

    )

  )

#不要把guohuiorcl1改成ip。

[oracle@guohuiorcl2 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

ORCL =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

GUOORCL1 =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

ORCLSBY1=

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

EXTPROC_CONNECTION_DATA =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))

    )

    (CONNECT_DATA =

      (SID = PLSExtProc)

      (PRESENTATION = RO)

    )

  )

 
 

在主用机 guohuiorcl2上启动监听

[oracle@guohuiorcl1 admin]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 07:29:17

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

Starting /home/oracle/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

Log messages written to /home/oracle/oracle/product/10.2.0/db_1/network/log/listener.log

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.129)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date                01-MAY-2011 07:29:18

Uptime                    0 days 0 hr. 0 min. 1 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

Listener Log File         /home/oracle/oracle/product/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.129)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

在备用机 guohuiorcl1上启动监听

[oracle@guohuiorcl2 admin]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 07:29:38

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

Starting /home/oracle/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production

System parameter file is /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

Log messages written to /home/oracle/oracle/product/10.2.0/db_1/network/log/listener.log

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.128)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))

STATUS of the LISTENER

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

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production

Start Date                01-MAY-2011 07:29:39

Uptime                    0 days 0 hr. 0 min. 1 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora

Listener Log File         /home/oracle/oracle/product/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.128)(PORT=1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully

 

在主用机 guohuiorcl2上测试tns

[oracle@guohuiorcl1 admin]$ tnsping orcl

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 07:30:47

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

Used parameter files:

/home/oracle/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.128)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (30 msec)

 

在备用机 guohuiorcl2上测试tns

[oracle@guohuiorcl1 admin]$ tnsping orclsby1

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 07:30:55

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

Used parameter files:

/home/oracle/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.129)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (10 msec)

 

在备用机 guohuiorcl1上测试tns

[oracle@guohuiorcl2 admin]$ tnsping orcl

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 07:32:05

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

Used parameter files:

/home/oracle/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.128)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (20 msec)

 

主用机 guohuiorcl2上测试tns

[oracle@guohuiorcl2 admin]$ tnsping orclsby1

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 07:32:19

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

Used parameter files:

/home/oracle/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.129)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (20 msec)

 
 

在主数据库 guohuiorcl2 上创建备用服务器控制文件

[oracle@guohuiorcl2 admin]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 1 07:39:56 2011

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

SQL> connect /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  243269632 bytes

Fixed Size                  1218748 bytes

Variable Size              67110724 bytes

Database Buffers          171966464 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

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

Database altered.

将 standby.ctl 由guohuiorcl2传输到 guohuiorcl1 上。

[oracle@guohuiorcl2 ~]$ ftp 192.168.31.129

Connected to 192.168.31.129.

220 (vsFTPd 2.0.5)

530 Please login with USER and PASS.

530 Please login with USER and PASS.

KERBEROS_V4 rejected as an authentication type

Name (192.168.31.129:oracle): oracle

331 Please specify the password.

Password:

230 Login successful.

Remote system type is UNIX.

Using binary mode to transfer files.

ftp> bin  

200 Switching to Binary mode.

ftp> put standby.ctl

local: standby.ctl remote: standby.ctl

227 Entering Passive Mode (192,168,31,129,117,119)

150 Ok to send data.

226 File receive OK.

7061504 bytes sent in 0.28 seconds (2.4e+04 Kbytes/s)

ftp> ls

227 Entering Passive Mode (192,168,31,129,88,118)

150 Here comes the directory listing.

-rw-r--r--    1 501      501      637140992 Apr 30 01:21 01mavib9_1_1_1.bak

-rw-r--r--    1 501      501       7143424 Apr 30 01:21 02mavihq_1_1_2.bak

-rw-r--r--    1 501      501      34118144 Apr 30 01:21 03mavit7_1_1_3.bak

drwxrwx---    7 501      501          4096 Dec 12 14:10 oracle

-rw-r--r--    1 501      501       7061504 May 01 00:00 standby.ctl

-rwxr-xr-x    1 501      501            72 Dec 12 15:48 startora.sh

-rwxr-xr-x    1 501      501            76 Dec 12 15:46 stopora.sh

226 Directory send OK.

 

在备用机 guohuiorcl1 上查证一下

[oracle@guohuiorcl1 ~]$ ls –la

drwx------ 9 oracle oinstall      4096 05-01 08:00 .

drwxr-xr-x 5 root   root          4096 12-12 11:40 ..

-rw-r--r-- 1 oracle oinstall 637140992 04-30 09:21 01mavib9_1_1_1.bak

-rw-r--r-- 1 oracle oinstall   7143424 04-30 09:21 02mavihq_1_1_2.bak

-rw-r--r-- 1 oracle oinstall  34118144 04-30 09:21 03mavit7_1_1_3.bak

-rw------- 1 oracle oinstall      4009 04-30 10:40 .bash_history

-rw-r--r-- 1 oracle oinstall        33 12-12 11:27 .bash_logout

-rw-r--r-- 1 oracle oinstall       864 04-30 09:34 .bash_profile

-rw-r--r-- 1 oracle oinstall       860 12-12 22:44 .bash_profile~

-rw-r--r-- 1 oracle oinstall       124 12-12 11:27 .bashrc

-rw-r--r-- 1 oracle oinstall       515 12-12 11:27 .emacs

drwx------ 3 oracle oinstall      4096 12-12 22:42 .gconf

drwx------ 2 oracle oinstall      4096 12-12 22:44 .gconfd

drwx------ 3 oracle oinstall      4096 12-12 22:44 .gnome2

drwx------ 2 oracle oinstall      4096 12-12 11:57 .gnome2_private

drwxr-xr-x 3 oracle oinstall      4096 12-12 11:27 .kde

drwxr-xr-x 4 oracle oinstall      4096 12-12 11:27 .mozilla

drwxrwx--- 7 oracle oinstall      4096 12-12 22:10 oracle

-rw-r--r-- 1 oracle oinstall       775 12-12 22:44 .recently-used.xbel

-rw-r--r-- 1 oracle oinstall   7061504 05-01 08:00 standby.ctl

-rwxr-xr-x 1 oracle oinstall        72 12-12 23:48 startora.sh

-rwxr-xr-x 1 oracle oinstall        76 12-12 23:46 stopora.sh

-rw------- 1 oracle oinstall      6477 05-01 07:22 .viminfo

-rw-r--r-- 1 oracle oinstall       658 12-12 11:27 .zshrc

把备用机guoorcl1老的文件备份一下

[oracle@guohuiorcl1 ~]$ cd $ORACLE_BASE/

[oracle@guohuiorcl1 oracle]$ ls

admin  flash_recovery_area  oradata  oraInventory  product

[oracle@guohuiorcl1 oracle]$ tar –cvfz oradata.tar.20110430.gz oradata

用guoorcl2上新生成的控制文件覆盖guoorcl1的控制文件

[oracle@guohuiorcl1 oracle]$cd $HOME

[oracle@guohuiorcl1 ~]$ cp standby.ctl /home/oracle/oracle/oradata/orcl/control01.ctl

[oracle@guohuiorcl1 ~]$ cp standby.ctl /home/oracle/oracle/oradata/orcl/control02.ctl

[oracle@guohuiorcl1 ~]$ cp standby.ctl /home/oracle/oracle/oradata/orcl/control03.ctl

 

启动备用数据库guohuiorcl1到mount模式下

[oracle@guohuiorcl1 dbs]$ lsnrctl start

[oracle@guohuiorcl1 dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 1 09:20:21 2011

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

SQL> create spfile from pfile;

SP2-0640: Not connected

SQL> connect /as sysdba

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup mount

ORACLE instance started.

Total System Global Area  243269632 bytes

Fixed Size                  1218748 bytes

Variable Size              75499332 bytes

Database Buffers          163577856 bytes

Redo Buffers                2973696 bytes

Database mounted.

SQL>

 
 

在rman数据库上加上guohuiorcl1 的tns地址

Tnsnames.ora 中添加

ORCLB =

  (DESCRIPTION =

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

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

    )

  )

Rman服务器上验证地址可达。

[oracle@guohuilinuxas31 network]$ tnsping ORCLB

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 01-MAY-2011 02:34:26

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

Used parameter files:

/u01/app/oracle/product/10.2.0/db_1/network/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.129)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))

OK (0 msec)

恢复 备用数据库guohuiorcl1

[oracle@guohuilinuxas31 network]$ rman

Recovery Manager: Release 10.2.0.1.0 - Production on Sun May 1 02:56:43 2011

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

RMAN> connect target sys/kelantas@orclb

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

RMAN> connect catalog rman817/rman@orcl

connected to recovery catalog database

RMAN> restore database;

Starting restore at 01-MAY-11

Starting implicit crosscheck backup at 01-MAY-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=151 devtype=DISK

Crosschecked 3 objects

Finished implicit crosscheck backup at 01-MAY-11

Starting implicit crosscheck copy at 01-MAY-11

using channel ORA_DISK_1

Finished implicit crosscheck copy at 01-MAY-11

searching for all files in the recovery area

cataloging files...

no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore

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

restoring datafile 00001 to /home/oracle/oracle/oradata/orcl/system01.dbf

restoring datafile 00002 to /home/oracle/oracle/oradata/orcl/undotbs01.dbf

restoring datafile 00003 to /home/oracle/oracle/oradata/orcl/sysaux01.dbf

restoring datafile 00004 to /home/oracle/oracle/oradata/orcl/users01.dbf

restoring datafile 00005 to /home/oracle/oracle/oradata/orcl/example01.dbf

channel ORA_DISK_1: reading from backup piece /home/oracle/01mavib9_1_1_1.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/home/oracle/01mavib9_1_1_1.bak tag=TAG20110429T065744

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

Finished restore at 01-MAY-11

RMAN> restore archivelog all;

Starting restore at 01-MAY-11

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=5

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=6

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=7

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=8

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=9

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=10

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=11

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=12

channel ORA_DISK_1: reading from backup piece /home/oracle/03mavit7_1_1_3.bak

channel ORA_DISK_1: restored backup piece 1

piece handle=/home/oracle/03mavit7_1_1_3.bak tag=TAG20110429T070718

channel ORA_DISK_1: restore complete, elapsed time: 00:00:28

Finished restore at 01-MAY-11

RMAN> recover database;

Starting recover at 01-MAY-11

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 12 is already on disk as file /home/oracle/oracle/oradata/orcl/archive/1_12_737590303.dbf

archive log filename=/home/oracle/oracle/oradata/orcl/archive/1_12_737590303.dbf thread=1 sequence=12

unable to find archive log

archive log thread=1 sequence=13

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 05/01/2011 03:06:06

RMAN-06054: media recovery requesting unknown log: thread 1 seq 13 lowscn 535329

备用数据库进入到后台管理恢复状态

 

[oracle@guohuiorcl1 admin]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 1 10:02:51 2011

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

SQL> connect /as sysdba

Connected.

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

Database altered.

SQL>

 

采用Lgwr进程传递联日志机的最大性能模式

1. 在备用数据库上创建备用日志

(

alter database recover managed standby database cancel;

alter database add standby LOGFILE GROUP 5 ('/home/oracle/oracle/oradata/orcl/stdy_redo05.log') size 10m;

alter database add standby LOGFILE GROUP 6 ('/home/oracle/oracle/oradata/orcl/stdy_redo06.log') size 10m;

alter database add standby LOGFILE GROUP 7 ('/home/oracle/oracle/oradata/orcl/stdy_redo07.log') size 10m;

alter database add standby LOGFILE GROUP 8 ('/home/oracle/oracle/oradata/orcl/stdy_redo08.log') size 10m;

alter database recover managed standby database disconnect from session;

)

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database add standby LOGFILE GROUP 5 ('/home/oracle/oracle/oradata/orcl/stdy_redo05.log') size 10m;

Database altered.

SQL> alter database add standby LOGFILE GROUP 6 ('/home/oracle/oracle/oradata/orcl/stdy_redo06.log') size 10m;

Database altered.

SQL> alter database add standby LOGFILE GROUP 7 ('/home/oracle/oracle/oradata/orcl/stdy_redo07.log') size 10m;

Database altered.

SQL> alter database add standby LOGFILE GROUP 8 ('/home/oracle/oracle/oradata/orcl/stdy_redo08.log') size 10m;

Database altered.

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

Database altered.

2. 修改主库的归档路径

alter system set LOG_ARCHIVE_DEST_2='SERVICE=orclsby1 LGWR' scope=both;

另外,如果考虑到以后该库可能被切换到备用数据库,也可以创建同样的备用日志

组:

alter database add standby LOGFILE GROUP 5 ('/home/oracle/oracle/oradata/orcl/stdy_redo05.log') size 10m;

alter database add standby LOGFILE GROUP 6 ('/home/oracle/oracle/oradata/orcl/stdy_redo06.log') size 10m;

alter database add standby LOGFILE GROUP 7 ('/home/oracle/oracle/oradata/orcl/stdy_redo07.log') size 10m;

alter database add standby LOGFILE GROUP 8 ('/home/oracle/oracle/oradata/orcl/stdy_redo08.log') size 10m;

[oracle@guohuiorcl2 ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Sun May 1 10:23:24 2011

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

SQL> connect /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

Total System Global Area  243269632 bytes

Fixed Size                  1218748 bytes

Variable Size              62916420 bytes

Database Buffers          176160768 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

SQL> alter system set log_archive_dest_2='service=orclsby1 LGWR' scope=both;

System altered.

SQL> alter database add standby LOGFILE GROUP 5 ('/home/oracle/oracle/oradata/orcl/stdy_redo05.log') size 10m;

Database altered.

SQL> alter database add standby LOGFILE GROUP 6 ('/home/oracle/oracle/oradata/orcl/stdy_redo06.log') size 10m;

Database altered.

SQL> alter database add standby LOGFILE GROUP 7 ('/home/oracle/oracle/oradata/orcl/stdy_redo07.log') size 10m;

Database altered.

SQL> alter database add standby LOGFILE GROUP 8 ('/home/oracle/oracle/oradata/orcl/stdy_redo08.log') size 10m;

Database altered.

SQL>

 
 

四、验证备用服务器是否工作

在备库中查看日志

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

在主库中执行

alter system switch logfile;

在备库中查看日志是否被传送过来

SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

备用数据库查询

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 SEQUENCE# FIRST_TIM NEXT_TIME APP

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

         5 15-APR-11 16-APR-11 YES

         6 16-APR-11 16-APR-11 YES

         7 16-APR-11 16-APR-11 YES

         8 16-APR-11 16-APR-11 YES

         9 16-APR-11 16-APR-11 YES

        10 16-APR-11 17-APR-11 YES

        11 17-APR-11 29-APR-11 YES

        12 29-APR-11 29-APR-11 YES

        13 29-APR-11 01-MAY-11 YES

        14 01-MAY-11 01-MAY-11 YES

10 rows selected.

主用数据库执行

alter system switch logfile;

在备库中查看日志是否被传送过来

SQL> alter system switch logfile;

System altered.

执行时间明显变长,因为要传输日志。

备用数据库查询

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

 SEQUENCE# FIRST_TIM NEXT_TIME APP

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

         5 15-APR-11 16-APR-11 YES

         6 16-APR-11 16-APR-11 YES

         7 16-APR-11 16-APR-11 YES

         8 16-APR-11 16-APR-11 YES

         9 16-APR-11 16-APR-11 YES

        10 16-APR-11 17-APR-11 YES

        11 17-APR-11 29-APR-11 YES

        12 29-APR-11 29-APR-11 YES

        13 29-APR-11 01-MAY-11 YES

        14 01-MAY-11 01-MAY-11 YES

        15 01-MAY-11 01-MAY-11 YES

11 rows selected.

 可以看到,日志已从guohuiorcl2传输到guohuiorcl1.至此,oracle 的 data guard 配置完毕。

posted @ 2011-05-02 01:47  疯狂的毛豆  阅读(896)  评论(0编辑  收藏  举报