电脑技术学习

单机创建物理Oracle9istandby数据库

dn001
说明:Oracle9i数据库的Data Guard 特性确保对数据进行完整的保护,是Oracle 9i的一个要害特性之一。Data Guard可以创建物理的Standby数据库,也可以创建逻辑的Standby数据库,还可以混合使用,灵活性比较强。 系统环境:windows 2000 专业版 SP3 512M 内存 现有的数据库实例(Primary)名字:Demo 预创建的Standby 数据库实例名字:Pstandby 数据库版本信息:
     SQL> select * from v$version;      BANNER   ----------------------------------------------------------------   Oracle9i Enterprise Edition Release 9.2.0.1.0 - ProdUCtion   PL/SQL Release 9.2.0.1.0 - Production   CORE  9.2.0.1.0    Production   TNS for 32-bit Windows: Version 9.2.0.1.0 - Production   NLSRTL Version 9.2.0.1.0 - Production
   预备工作 首先确认Primary数据库是否在归档模式下:
  SQL> show user   USER is "SYS"   SQL>   SQL> archive log list   Database log mode       Archive Mode   Automatic archival       Enabled   Archive destination      d:oracleoradatademoarchive   Oldest online log sequence   42   Next log sequence to archive  44   Current log sequence      44
   注:假如不在归档模式下,调整数据库。 首先提交命令修改SPfile:SQL>alter system set LOG_ARCHIVE_START=TRUE scope=spfile;然后关闭数据库实例:SQL>SHUTDOWN 备份数据库
     SQL>STARTUP MOUNT      SQL>ALTER DATABASE ARCHIVELOG;   SQL>ALTER DATABASE OPEN;      SQL>SHUTDOWN IMMEDIATE
备份 1. Primary Database 需要做的预备工作: 1.1 激活 Forced Logging:   SQL> ALTER DATABASE FORCE LOGGING; 1.2 设置本地归档目标: SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_1='LOCATION=D:oracleoradataDEMOArchive' SCOPE=BOTH;此操作直接生效。 2.创建物理的Standby数据库: 2.1 标记出Primary数据库的数据文件:
     SQL> select name from v$datafile;      NAME   -----------------------------------------------------      D:ORACLEORADATADEMOSYSTEM01.DBF   D:ORACLEORADATADEMOUNDOTBS01.DBF   D:ORACLEORADATADEMOCWMLITE01.DBF   D:ORACLEORADATADEMODRSYS01.DBF   D:ORACLEORADATADEMOEXAMPLE01.DBF   D:ORACLEORADATADEMOINDX01.DBF   D:ORACLEORADATADEMOODM01.DBF   D:ORACLEORADATADEMOTOOLS01.DBF   D:ORACLEORADATADEMOUSERS01.DBF   D:ORACLEORADATADEMOXDB01.DBF   D:ORACLEORADATADEMOOEM_REPOSITORY.DBF      11 rows selected.      SQL>
   2.2 关闭Instance 拷贝数据文件到既定目的地: SQL> SHUTDOWN IMMEDIATE; 2.3 为Standby 数据库创建控制文件:
     SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE   AS 'C:DataGuardPstandbyDEMODEMOSTANDBY.CTL';
要注重这个控制文件的名字不要和Primary的控制文件名字重复。 2.4 为Standby数据库预备初始化参数文件名字: SQL> CREATE PFILE='C:DataGuardPstandbyDEMOinitpstandby' FROM SPFILE; 2.5 设定初始化Physical Standby Database参数:
     *.aq_tm_processes=1   *.background_dump_dest=' D:oracleadminDEMObdump'   *.compatible='9.2.0.0.0'   *.control_files=' C:DataGuardPstandbyDEMODEMOSTANDBY.CTL'   *.core_dump_dest='D:oracleadminDEMOcdump'   *.db_block_size=8192   *.db_cache_size=19922944   *.db_domain=''   *.db_file_multiblock_read_count=32   *.db_name='DEMO'   *.dispatchers='(PROTOCOL=TCP) (SERVICE=DEMOXDB)'   *.fast_start_mttr_target=300   *.hash_area_size=1048576   *.hash_join_enabled=TRUE   *.instance_name='pstandby'   *.Java_pool_size=20971520   *.job_queue_processes=10   *.large_pool_size=7340032   *.log_archive_dest_1=' location=d:oracleoradatademoarchive'   *.log_archive_start=TRUE   *.open_cursors=300   *.optimizer_mode='FIRST_ROWS'   *.pga_aggregate_target=17825792   *.processes=150   *.query_rewrite_enabled='TRUE'   *.remote_login_passWordfile='EXCLUSIVE'   *.shared_pool_size=33554432   *.sort_area_size=1048576   *.star_transformation_enabled='TRUE'   *.timed_statistics=TRUE   *.undo_management='AUTO'   *.undo_retention=10800   *.undo_tablespace='UNDOTBS1'   *.user_dump_dest='D:oracleadminDEMOudump'      lock_name_space=pstandby   standby_file_management=AUTO   remote_archive_enable=TRUE   standby_archive_dest=' C:DataGuardPstandbyDEMOArchive'   db_file_name_convert= ('D:oracleoradataDEMO', 'C:DataGuardPstandbyDEMO')   log_file_name_convert= ('D:oracleoradataDEMO', 'C:DataGuardPstandbyDEMO')   log_archive_dest_1= ('LOCATION=C:DataGuardPstandbyDEMOArchive')
   整个操作的过程中,轻易出现错误的地方几乎都集中在此处。必须认真仔细的对待这个文件。标记为黑色的地方是需要进行修改的。 2.6 创建一个Windows服务: WINNT> oradim -NEW -SID Pstandby -STARTMODE manual 2.7 Create a Server Parameter File for the Standby Database。 可参考执行如下操作:
  C:>set oracle_sid=pstandby   C:>sqlplus /nolog   SQL> connect / as sysdba   SQL> CREATE SPFILE FROM PFILE='C:DataGuardPstandbyDEMOinitPstandby.ora';;
2.8 启动物理Standby数据库:
     C:>set oracle_sid=pstandby   C:>sqlplus /nolog   SQL> connect / as sysdba   SQL> STARTUP NOMOUNT;   SQL> ALTER DATABASE MOUNT STANDBY DATABASE;
   2.9 在Standby数据库上,初始化Log Apply 服务: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; 2.10 激活到物理Standby数据库的归档:  
    SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=Pstandby' SCOPE=BOTH;   SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=BOTH;
   2.11 启动远程归档: SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; 3.安装完的的验证: 3.1在database, 查询V$ARCHIVED_LOG(其实也可以直接到相关目录下查看Log是否创建):
     SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME   2 FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;      SEQUENCE# FIRST_TIME NEXT_TIME   ---------- ---------- ----------   38 23-7? -02 23-7? -02   39 23-7? -02 23-7? -02   40 23-7? -02 23-7? -02   41 23-7? -02 23-7? -02   42 23-7? -02 23-7? -02  
3.2 在Primary数据库上,归档当前的Log SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; 3.3 验证是否收到:
     SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME   2> FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;      SEQUENCE# FIRST_TIME NEXT_TIME   ---------- ---------- ----------   38 23-7? -02 23-7? -02   39 23-7? -02 23-7? -02   40 23-7? -02 23-7? -02   41 23-7? -02 23-7? -02   42 23-7? -02 23-7? -02   43 23-7? -02 23-7? -02
3.4 验证是否新的归档Redo日志已经被应用:
     SQL> select sequence#,applied from v$archived_log   2 order by sequence#;      SEQUENCE# APP   ---------- ---   38 YES   39 YES   40 YES   41 YES   42 YES   43 YES

上一篇 在hp-ux10.20系统下配置oracle8.0.5

下一篇 Oracle 数据库设计阶段性能优化策略