我是在以前从未接触Oracle的情况下来配置Data Guard的。付费下载了一份很详细的data guard 11g在windows下的配置文档(需要的留下邮箱),但是对于一个其中很多参数都得需要根据自己的环境修改,这对我这个新手来说颇有难度。配了整整8天终于初步成功,现把经验及配置过程中可能遇到的问题和大家分享一下。
以下介绍均根据配置文档同步说明。
文档2:“在安装 oracle 时,主库安装数据库,从库只安装软件。
安装路径为 E 盘,实例名为 orcl
数据文件放在e:\app\Administrator\oradata\orcl\文件夹下,归档日志放在e:\app\Administrator\oradata\orcl\文件夹下
oracl是安装oracle数据库后默认的实例名,在oracle中每个一个实例名对应一个数据库。
主库上运行sqlplus来进行配置,开始——运行——cmd
sqlplus / as sysdba; 这个命令的意思是仅连接当前空闲实例不启动数据库。
sqlplus /nolog; conn sys/123@tt as sysdba; 这个命令连接指定数据库
3.5 编辑参数文件
光标拖到最后。 添加如下内容并保存:。。。。。。。。
这一步如果按照其添加参数后,发现无法启动。
主要问题出在,原文配置*.log_archive_dest_1参数不能识别
*.log_archive_dest_1='location=D:\arch_log\VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=primary'
改成:
*.log_archive_dest_1='location=e:\APP\ADMINISTRATOR\ORADATA\ORCL\'
我的完整主机initora.ora
orcl.__db_cache_size=5704253440 orcl.__java_pool_size=67108864 orcl.__large_pool_size=67108864 orcl.__oracle_base='E:\app\Administrator'#ORACLE_BASE set from environment orcl.__pga_aggregate_target=17381195776 orcl.__sga_target=10133438464 orcl.__shared_io_pool_size=0 orcl.__shared_pool_size=4160749568 orcl.__streams_pool_size=0 *.audit_file_dest='E:\app\Administrator\admin\orcl\adump' *.audit_trail='db' *.compatible='11.2.0.0.0' *.control_files='E:\app\Administrator\oradata\orcl\control01.ctl','E:\app\Administrator\flash_recovery_area\orcl\control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='orcl' *.db_recovery_file_dest='E:\app\Administrator\flash_recovery_area' *.db_recovery_file_dest_size=6710886400 *.deferred_segment_creation=FALSE *.diagnostic_dest='E:\app\Administrator' *.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)' *.job_queue_processes=1000 *.memory_target=27476885504 *.open_cursors=50000 *.processes=2000 *.remote_login_passwordfile='EXCLUSIVE' *.undo_tablespace='UNDOTBS1' *.db_unique_name='primary' *.log_archive_config='DG_CONFIG=(primary,standby)' *.log_archive_dest_1='location=e:\APP\ADMINISTRATOR\ORADATA\ORCL\' *.log_archive_dest_2='service=standby lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=standby' *.log_archive_dest_state_1='enable' *.log_archive_dest_state_2='enable' *.fal_server='standby' *.fal_client='primary' *.archive_lag_target=1800 *.log_archive_format='%t_%s_%r.arc' *.standby_file_management='auto' *.DB_FILE_NAME_CONVERT='e:\app\Administrator\oradata\orcl\','e:\app\Administrator\oradata\orcl\' *.LOG_FILE_NAME_CONVERT='e:\app\Administrator\oradata\orcl\','e:\app\Administrator\oradata\orcl\'
3.8 配置主库网络监听(备用库同理)
完整主机listener.ora
# listener.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = E:\app\Administrator\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:E:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) (SID_NAME = orcl) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.3)(PORT = 1521)) ) ) ADR_BASE_LISTENER = E:\app\Administrator
完整 tnsnames.ora 文件,内容如下:
# tnsnames.ora Network Configuration File: E:\app\Administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. primary = (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.4)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) ) standby = (DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.3)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) ) ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) ) ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.4)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
3.12 备库新建实例
实例名称必须和主库的一致
oradim -new-sid orcl
3.14 备库参数文件
在备库中需要新加系统变量,变量名:oracle_sid 变量值:orcl
注:orcl为实例名
原文没有做这一步,导致启动出错。
3.15.3 复制数据库(在主库上操作)
RMAN> connect auxiliary sys/sys@standby
此次的意思是连接备库,如果出现问题打开命令窗口输入tnsping 192.168.1.121
IP地址为备库IP。
如果无法连接通,重启备库电脑上服务里的OracleOraDb11g_homeTNSListener.
验证数据库是否成功:
在主库执行一条插入命令后。但此时不能直接从库不能直接看到主库上进行到底修改。
在从库上执行:1.启动REDO应用
alter database recover managed standby database disconnect from session;
2.暂停REDO应用
alter database recover managed standby database cancel;
注意:在测试完成后,需要重写执行接受redo。执行 startup mount;
3.打开从库数据库并查询,即可验证是否配置成功。
如果有外部软件连接的oracl数据库,测试是否成功的方法:
1.用软件连接主库的数据库,插入一条数据。2.在从库上执行“启动redo应用”,然后打开数据库3.用软件连接从库数据库,查看能否找到新插入的数据 4.验证成功后,在从库数据库startup mount,重新接受redo日志。