第7章:备用数据库之初始化备用数据库

本文介绍如何在Windows XP环境下使用Oracle 10.2.0.1版本初始化备用数据库,包括创建必要的目录结构、备份主数据库、配置参数文件、创建口令文件及启动备用数据库等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/* 2008/05/30
*环境:Windows XP +Oracle10.2.0.1
*Oracle 备份与恢复培训教程 Kenny Smith,Stephan Haisley著 周琪、韩岷、李渝琳等译
*第二部分:用户管理的备份与恢复
*第7章:备用数据库
*/

练习7.1:初始化备用数据库
1、为备用数据库做准备
为准备建立standby数据库创建所有路径:
C:\>set oracle_sid=standby

C:\>set oracle_base=G:\oracle

C:\>set ORACLE_HOME=G:\oracle\product\10.2.0\db_1

C:\>mkdir G:\oracle\product\10.2.0\admin\standby

C:\>mkdir G:\oracle\product\10.2.0\admin\standby\pfile

C:\>mkdir G:\oracle\product\10.2.0\admin\standby\bdump

C:\>mkdir G:\oracle\product\10.2.0\admin\standby\cdump

C:\>mkdir G:\oracle\product\10.2.0\admin\standby\udump

C:\>mkdir G:\oracle\product\10.2.0\admin\standby\create

C:\>mkdir G:\oracle\product\10.2.0\oradata\standby

C:\>mkdir G:\oracle\product\10.2.0\oradata\standby\archive


2、制作打开数据库的备份
热备份数据到standby数据库
在e:\open_backup.sql脚本,内容为:
Set feedback off pagesize 0 heading off verify off linesize 200 trimspool on
define dir='G:\oracle\product\10.2.0\oradata\standby'
define fil='e:\open_backup_commands.sql'
define spo='&dir\open_backup_output.lst'
prompt *** Spooling to &fil

set serveroutput on
spool &fil
prompt spool &spo

prompt archive log list;;
prompt alter system switch logfile;;

declare
   cursor cur_tablespace is
    select tablespace_name from dba_tablespaces
     where status<>'READ ONLY' and tablespace_name<>'TEMP';
   cursor cur_datafile (tn varchar) is
    select file_name
      from dba_data_files
    where tablespace_name=tn;
   begin
    for ct in cur_tablespace loop
      dbms_output.put_line('alter tablespace '||ct.tablespace_name||' begin backup;');
     for cd in cur_datafile (ct.tablespace_name) loop
       dbms_output.put_line('host copy '||cd.file_name||' &dir');
  end loop;
    dbms_output.put_line('alter tablespace '|| ct.tablespace_name||' end backup;');
  end loop;
end;
/

prompt alter system switch logfile;;
prompt alter database create standby controlfile as 'G:\oracle\product\10.2.0\oradata\standby\standby.ctl' reuse;;
prompt archive log list;;
prompt spool off;;
spool off;
@&fil


在risenet数据库上运行该脚本
SQL> @e:\open_backup.sql


3、配置备用参数文件
SQL> create pfile from spfile;
在G:\oracle\product\10.2.0\db_1\database\生成initrisenet.ora文件

拷贝risenet数据库的参数文件:G:\oracle\product\10.2.0\db_1\database\initrisenet.ora,到G:\oracle\product\10.2.0\db_1

\database\initstandby.ora,并修改相关数据库名称。

修改后内容:
standby.__db_cache_size=163577856
standby.__java_pool_size=4194304
standby.__large_pool_size=4194304
standby.__shared_pool_size=92274688
standby.__streams_pool_size=0
*.audit_file_dest='G:\oracle\product\10.2.0/admin/standby/adump'
*.background_dump_dest='G:\oracle\product\10.2.0/admin/standby/bdump'
*.compatible='10.2.0.1.0'
*.control_files='G:\oracle\product\10.2.0/oradata/standby/\standby.ctl'
*.core_dump_dest='G:\oracle\product\10.2.0/admin/standby/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='risenet'
*.db_recovery_file_dest='G:\oracle\product\10.2.0/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=standbyXDB)'
*.job_queue_processes=10
*.log_archive_format='ARC%S_%R.%T'
*.open_cursors=300
*.pga_aggregate_target=89128960
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=269484032
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='G:\oracle\product\10.2.0/admin/standby/udump'
*.db_file_name_convert='G:\oracle\product\10.2.0\oradata\risenet','G:\oracle\product\10.2.0\oradata\standby'

创建口令:
C:\>oradim -new -sid standby -intpwd standby
实例已创建。


4、加载备用数据库
C:\>set oracle_sid=standby

C:\>sqlplus  /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 1月 30 11:36:14 2008

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

SQL> connect sys/standby as sysdba
已连接到空闲例程。

SQL> startup nomount;
ORACLE 例程已经启动。

Total System Global Area  272629760 bytes
Fixed Size                  1248476 bytes
Variable Size             100664100 bytes
Database Buffers          163577856 bytes
Redo Buffers                7139328 bytes

SQL> alter database mount standby database;
alter database mount standby database
*
第 1 行出现错误:
ORA-01102: ??? EXCLUSIVE ????????


eygle提到:http://www.eygle.com/archives/2007/08/stepbs_oracle_chp1_06.html
注意,此时试图加载数据库时出现错误,因为当前数据库被另外一个实例(instance)加载。在非并行模式(OPS/RAC)下,一个数据库同时只能被

一个实例加载。

来自:http://www.itpub.net/313101.html
主数据库和备用数据库不能同时启动的问题已经找到了,原因是两个数据库在同一台电脑上,只要在pfile后加*.lock_name_space=standby
更改initstandby.ora内容为:
standby.__db_cache_size=163577856
standby.__java_pool_size=4194304
standby.__large_pool_size=4194304
standby.__shared_pool_size=92274688
standby.__streams_pool_size=0
*.audit_file_dest='G:\oracle\product\10.2.0/admin/standby/adump'
*.background_dump_dest='G:\oracle\product\10.2.0/admin/standby/bdump'
*.compatible='10.2.0.1.0'
*.control_files='G:\oracle\product\10.2.0/oradata/standby/\standby.ctl'
*.core_dump_dest='G:\oracle\product\10.2.0/admin/standby/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='risenet'
*.db_recovery_file_dest='G:\oracle\product\10.2.0/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=standbyXDB)'
*.job_queue_processes=10
*.log_archive_format='ARC%S_%R.%T'
*.open_cursors=300
*.pga_aggregate_target=89128960
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=269484032
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='G:\oracle\product\10.2.0/admin/standby/udump'
*.db_file_name_convert='G:\oracle\product\10.2.0\oradata\risenet','G:\oracle\product\10.2.0\oradata\standby'
*.lock_name_space=standby

 

重新启动

C:\>set oracle_sid=standby

C:\>sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 1月 30 12:27:30 2008

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

已连接到空闲例程。

SQL> startup nomount
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE 例程已经启动。

Total System Global Area  272629760 bytes
Fixed Size                  1248476 bytes
Variable Size             100664100 bytes
Database Buffers          163577856 bytes
Redo Buffers                7139328 bytes
SQL> alter database mount standby database;

数据库已更改。

成功!!!

 

问答:
1、为什么要恢复备用数据库?
A、备用数据库崩溃了
B、来自主数据库归档日志的变化必须要应用到备用数据库上
C、备用数据库的联机重做日志已经重新设置了
D、在备用数据库上进行的恢复使之与主数据库保持一致

答案:BD

2、当备用数据库打开以备查询时,可以继续恢复该数据库
A、True
B、False

答案:B

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12778571/viewspace-324461/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/12778571/viewspace-324461/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值