简单配置Oracle10g DataGuard物理备库

primary主库
IP:192.168.50.4/24
dbname:ora10g
数据库版本:10g R2
操作系统版本:rhel6.0 64位

standby物理备库
IP:192.168.50.230/24
dbname:ora10g
数据库版本:10g R2
操作系统版本:rhel5.4 64位

一:配置Oracle网络,主库和备库两边都需要配置

  
  
  
  
  1. [oracle@rhel6 ~]$ vi /u01/app/oracle/network/admin/tnsnames.ora  
  2. PRIMARY =  
  3.   (DESCRIPTION =  
  4.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.4)(PORT = 1521))  
  5.     (CONNECT_DATA =  
  6.       (SERVER = DEDICATED)  
  7.       (SERVICE_NAME = ora10g.766.com)  
  8.     )  
  9.   )  
  10.  
  11. STANDBY =  
  12.   (DESCRIPTION =  
  13.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.230)(PORT = 1521))  
  14.     (CONNECT_DATA =  
  15.       (SERVER = DEDICATED)  
  16.       (SERVICE_NAME = ora10g.766.com)  
  17.     )  
  18.   )  

二:主库端配置,修改初始化参数,生成备库的控制文件

  
  
  
  
  1. SQL> alter database force logging;  
  2. Database altered.  
  3.  
  4. SQL> select force_logging from v$database;  
  5.  
  6. FORCE_LOG  
  7. ---------  
  8. YES    
  9.  
  10. SQL> create pfile='/home/oracle/initora10g.ora' from spfile;  
  11. File created.  
  12.  
  13. 文件末尾处添加  
  14. log_archive_dest_1='LOCATION=/u01/arch/' 
  15. log_archive_dest_state_1=enable 
  16. log_archive_dest_2='SERVICE=standby' 
  17. log_archive_dest_state_2=enable 
  18. log_archive_format='%t_%s_%r.arc' 
  19. log_archive_max_processes=2 
  20. fal_server=standby 
  21. fal_client=primary 
  22. db_unique_name=ora10g 
  23.  
  24. SQL> alter database create standby controlfile as '/u01/app/oradata/ora10g/standby.ctl';  
  25. Database altered. 

关闭主库 

  
  
  
  
  1. SQL> shutdown immediate;  
  2. Database closed.  
  3. Database dismounted.  
  4. ORACLE instance shut down. 

三:备库端配置

  
  
  
  
  1. [oracle@localhost ~]$ scp -rvp 192.168.50.4:/u01/app/oradata/ora10g /u01/app/oradata  
  2. [oracle@localhost ~]$ scp  192.168.50.4:/home/oracle/initora10g.ora /u01/app/oracle/dbs/  
  3.  
  4. 修改参数内容如下:  
  5. log_archive_dest_1='LOCATION=/u01/arch/' 
  6. log_archive_dest_state_1=enable 
  7. log_archive_dest_2='SERVICE=primary' 
  8. log_archive_dest_state_2=enable 
  9. log_archive_format='%t_%s_%r.arc' 
  10. log_archive_max_processes=2 
  11. fal_server=primary   
  12. fal_client=standby 
  13. db_unique_name=ora10g 
  14.  
  15. 创建相关目录和文件  
  16. [oracle@localhost ~]$ mkdir /u01/arch/  
  17. [oracle@localhost ~]$ mkdir -p /u01/app/admin/ora10g/{adump,bdump,cdump,udump}  
  18. [oracle@localhost ~]$ cd /u01/app/oradata/ora10g/  
  19. [oracle@localhost ora10g]$ mv standby.ctl control01.ctl   
  20. [oracle@localhost ora10g]$ cp control01.ctl control02.ctl  
  21. [oracle@localhost ora10g]$ cp control01.ctl control03.ctl  
  22. [oracle@localhost ~]$ orapwd file=$ORACLE_HOME/dbs/orapwora10g password=123456 entries=5 

四:测试

  
  
  
  
  1. 启动主库:  
  2. Connected to an idle instance.  
  3. SQL> create spfile from pfile='/home/oracle/initora10g.ora';  
  4. File created.  
  5.  
  6. SQL> startup  
  7. SQL> select name,database_role from v$database;  
  8.  
  9. NAME                        DATABASE_ROLE  
  10. --------------------------- ------------------  
  11. ORA10G                      PRIMARY  
  12.  
  13. 启动备库:  
  14. [oracle@localhost ~]$ sqlplus /nolog  
  15. SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 4 16:49:39 2011  
  16. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  17.  
  18. SQL> conn /as sysdba  
  19. Connected to an idle instance.  
  20. SQL> create spfile from pfile;  
  21. File created.  
  22.  
  23. SQL> startup nomount;  
  24. ORACLE instance started.  
  25. Total System Global Area  629145600 bytes  
  26. Fixed Size                  2022824 bytes  
  27. Variable Size             180355672 bytes  
  28. Database Buffers          440401920 bytes  
  29. Redo Buffers                6365184 bytes  
  30.  
  31. SQL> alter database mount standby database; 
  32. SQL>  select name,database_role from v$database;  
  33.  
  34. NAME                        DATABASE_ROLE  
  35. --------------------------- ----------------------  
  36. ORA10G                      PHYSICAL STANDBY  
  37.  
  38. SQL>  alter database recover managed standby database disconnect from session;  
  39. Database altered.  
  40.  
  41.  
  42. 主库上新建表,切换在线日志组测试:  
  43. SQL> create table hr.dg01 as select * from dba_source;  
  44. Table created.  
  45.  
  46. SQL> alter system switch logfile;  
  47. System altered.  
  48.  
  49. SQL> /  
  50. System altered.  
  51.  
  52. SQL> /  
  53. System altered.  
  54.  
  55.  
  56. 备库:  
  57. SQL> select sequence#,first_time,next_time,applied from v$archived_log;  
  58.  
  59.  SEQUENCE# FIRST_TIME          NEXT_TIME           APPLIED  
  60. ---------- ------------------- ------------------- ---------  
  61.         91 2011-08-04-14:38:52 2011-08-04-14:41:21 YES  
  62.         92 2011-08-04-14:41:21 2011-08-04-15:13:44 YES  
  63.         93 2011-08-04-15:13:44 2011-08-04-15:15:07 YES  
  64.         94 2011-08-04-15:15:07 2011-08-04-15:42:58 YES  
  65.         95 2011-08-04-15:42:58 2011-08-04-16:55:53 YES  
  66.         96 2011-08-04-16:55:53 2011-08-04-16:56:11 YES  
  67.         97 2011-08-04-16:56:11 2011-08-04-16:56:18 YES  
  68.         98 2011-08-04-16:56:18 2011-08-04-16:56:33 YES  
  69.  
  70. 8 rows selected.  
  71.  
  72. 将备库置为只读状态,验证数据:  
  73. SQL> alter database recover managed standby database cancel;  
  74. Database altered.  
  75.  
  76. SQL> alter database open read only;  
  77. Database altered.  
  78.  
  79. SQL> select count(*) from hr.dg01;  
  80.  
  81.   COUNT(*)  
  82. ----------  
  83.     323203  
  84.       
  85. 重新将备库置为应用redo log状态   
  86. SQL> alter database recover managed standby database disconnect from session;  
  87. Database altered. 

 

本文出自 “斩月” 博客,谢绝转载!

你可能感兴趣的:(oracle,职场,dataguard,休闲,standby,Physical)