当前位置:数据库 > Oracle >>

[Oracle]Data Guard之-创建物理Standby

[Oracle]Data Guard之-创建物理Standby
 
实验环境
Primary:
主机: jabdw1241
SID: O01DMS0
DB_UNIQUE_NAME: O01DMS0
Standby:
主机: jabdw1242
SID: O01DMS0
DB_UNIQUE_NAME: O01DMS0DR
 
1. Primary的配置和操作
1) 确认primary处于归档模式
PRIMARY>archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            H:\INTEL_ARCH\O01DMS0
Oldest online log sequence     468
Next log sequence to archive   470
Current log sequence           470
2) 确认primary处于force logging模式
PRIMARY>select force_logging from v$database;
 
FOR
---
NO
结果为NO,通过下面语句把primary设为force logging:
PRIMARY>alter database force logging;
 
Database altered.
 
3) 配置primary的参数
增加以下必须参数:
*.db_unique_name=O01DMS0
*.log_archive_config='DG_CONFIG=(O01DMS0,O01DMS0DR)'
*.log_archive_dest_2='service=O01DMS0DR ARCH VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=O01DMS0DR'
*.log_archive_dest_state_2=defer
以下参数虽然不是必须的,但在角色切换中有用,建议配置:
*.fal_server=O01DMS0DR
*.fal_client=O01DMS0
*.standby_file_management=auto
重建spfile启动primary:
PRIMARY>shutdown immediate;
PRIMARY>create spfile from pfile;
 
File created.
 
PRIMARY>startup
4) 创建standby的控制文件
PRIMARY>alter database create standby controlfile as 'H:\CONTROL01.O01DMS0';
 
Database altered.
 
5) 创建password file
C:\Documents and Settings\a105024>orapwd file=G:\Oracle\Ora102\database\PWDO01DMS0.ora password=oracle entries=30
 
6) 复制数据文件到standby服务器
查出primary端的所有数据文件:
PRIMARY>select name from v$datafile;
 
NAME
-----------------------------------------------
 
I:\INTEL_DATA\O01DMS0\SYSTEM01.O01DMS0
I:\INTEL_DATA\O01DMS0\UNDOTBS01.O01DMS0
I:\INTEL_DATA\O01DMS0\USERS01.O01DMS0
I:\INTEL_DATA\O01DMS0\SECURITY_D.O01DMS0
K:\INTEL_INDEX\O01DMS0\SECURITY_I.O01DMS0
I:\INTEL_DATA\O01DMS0\SYSAUX01.O01DMS0
I:\INTEL_DATA\O01DMS0\STREAMS_TBS.DBF
I:\INTEL_DATA\O01DMS0\DMS01.O01DMS0
I:\INTEL_DATA\O01DMS0\UNDOTBS02.O01DMS0
 
关闭数据库:
PRIMARY>shutdown immediate;
 
把上面的所有数据文件拷贝到standby服务器对应的目录下。
 
再把刚生成的控制文件拷贝到standby服务器对应的目录下,注意控制文件要复制三份,且要修改文件名。
 
最后再把pfile和password file拷贝到standby服务器对应的目录下。
 
注意:online 和 archived redo log不需要复制。
 
启动数据库:
PRIMARY>startup
 
2. Standby的配置和操作
1) 创建OracleService
C:\Documents and Settings\a105024>oradim -new -sid O01DMS0
Instance created.
2) 修改standby参数
打开刚刚从primary复制过来的pfile,修改以下参数:
*.db_unique_name=O01DMS0DR
*.log_archive_dest_2='service=O01DMS0 ARCH VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=O01DMS0'
*.log_archive_dest_state_2=enable
*.fal_server=O01DMS0
*.fal_client=O01DMS0DR
创建spfile:
STANDBY> create spfile from pfile;
 
File created.
 
3) 启动数据库至mount状态
注意:在启动至mount之前,一定要仔细检查参数文件和控制文件中指定的目录和文件都已在standby服务器存在。
STANDBY>startup mount;
ORACLE instance started.
 
Total System Global Area  629145600 bytes
Fixed Size                  1296652 bytes
Variable Size             339740404 bytes
Database Buffers          251658240 bytes
Redo Buffers               36450304 bytes
Database mounted.
 
3. 配置primary和standby的通讯
1) standby listener 的配置
DRO01DMS0 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = JABDW1242)(PORT = 1521))
  )
 
SID_LIST_DRO01DMS0 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = O01DMS0)
      (ORACLE_HOME = G:\Oracle\ora102)
      (SID_NAME = O01DMS0)
    )
  )
通过lsnrctl启动listener
2) primary tnsnames 的配置
O01DMS0DR =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = jabdw1242)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = O01DMS0)
    )
  )
测试primary是否能连standby:
C:\Documents and Settings\a105024>tnsping O01DMS0DR
 
TNS Ping Utility for 32-bit Windows: Version 10.2.0.4.0 - Production on 18-OCT-2
011 02:49:47
 
Copyright (c) 1997,  2007, Oracle.  All rights reserved.
 
Used parameter files:
G:\Oracle\Ora102\network\admin\sqlnet.ora
 
 
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = jabdw1242)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = O01DMS0)))
OK (40 msec)
 
3) standby tnsnames 配置
 
O01DMS0 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = jabdw1241)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = O01DMS0)
    )
  )
测试standby是否能连primary:
C:\Documents and Settings\a105024>tnsping O01DMS0
 
TNS Ping Utility for 32-bit Windows: Version 10.2.0.4.0 - Production on 18-OCT-2
011 02:54:32
 
Copyright (c) 1997,  2007, Oracle.  All rights reserved.
 
Used parameter files:
G:\oracle\ora102\network\admin\sqlnet.ora
 
 
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = jabdw1241)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = O01DMS0)))
OK (50 msec)
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,