两台DELL R710服务器,操作系统为WINDOWS SERVER 2008 ENTERPRISE EDTION 64X, 数据库为ORACLE 11G R1.
二.配置前准备: 1.将服务器硬盘配置RAID5与热备后,分为四个区,分别为system、data、log、backup四个区,system存放系统数据,data存放数据库文件,log存放数据库日志和归档文件,backup用于备份. 2.安装操作系统,安装数据库软件,主库ip配置为90.137,从库配置为90.138,在安装oracle时,主库安装数据库,从库只安装软件。 三.正式配置过程: 1.在主库上启动数据库到mount模式,开启归档模式与force logggin. 2.查看当前日志文件组 select group#,member from v$logfile order by group#; GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------- ---
1 ONLINE E:\LOG\REDO01.LOG NO
2 ONLINE E:\LOG\REDO02.LOG NO
3 ONLINE E:\LOG\REDO03.LOG NO 3.为备用库创建三组日志文件: alter database add standby logfile group 4 (E:\LOG\STAN04.LOG’) size 50m; alter database add standby logfile group 5 (E:\LOG\STAN05.LOG’) size 50m; alter database add standby logfile group 6 (E:\LOG\STAN06.LOG’) size 50m; 4.创建standby控制文件: alter database create standby controlfile as ‘d:\standby.ctl’; 5.创建参数文件: create pfile='d:\initora.ora' from spfile; 5.编辑参数文件,框内是要添加的内容: 6.使用修改过的参数文件启动主库: startup pfile=’d:\initora.ora’ nomount; create spfile from pfile=’’d:\initora.ora’ ; shutdown immediate; startup; 7.创建密码文件: 密码文件存放于C:\app\Administrator\product\11.1.0\db_1\database目录,文件名为PWDcenter.ora(center为实例名),如果目录下找不到,则手动创建,创建命令为: orapwd file=C:\app\Administrator\product\11.1.0\db_1\database\PWDcenter.ora password=oracle entries=10 8.配置主库静态网络监听(备用库同理) 修改listener.ora文件,内容如下: # listener.ora Network Configuration File: c:\app\Administrator\product\11.1.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools. LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.137)(PORT = 1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = c:\app\Administrator\product\11.1.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = center)
(ORACLE_HOME = c:\app\Administrator\product\11.1.0\db_1)
(SID_NAME = center)
)
) 修改tnsnames.ora文件,内容如下: primary =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.137)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = center)
)
) standby =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.90.138)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = center)
)
) 9.启用主数据库,开启监听,用网络名连接测试监听是否正常。 alter database open; lsnrctl start; sqlplus username/pwd@primary as sysdba 10. 建立备用库. a.将C:\app\Administrator目录下admin、cfgtollogs和diag目录拷至备用库 b.将d:\oradata目录拷至90.138的d盘下 c.将e:\log目录拷至90.138的e盘下 d.将standby.ctl拷至90.138的d:\oradata\center\目录下,并分别复制为control01.ctl,control02.ctl,control03.ctl. 11.在138上修改网络监听,内容与137类似,注册修改服务器ip即可. 在windows上注意注册oracle实例到服务中,具体命令如下:
oradim -new -sid center(实例名) 12.修改备用库参数文件: 将initora.ora复制到90.138的d盘,修改参数文件,修改内容如下 13.启动备用节点: startup nomount pfile=’d:\initora.ora’; create spfile from pfile=’d:\initora.ora’; shutdown immediate; startup nomount; 14.加截数据库为备用库模式. alter database mount standby database; 15.开启备用库应用重做 alter database recover managed standby database disconnect from session;
关闭应用重做 alter database recover managed standby database cancel; 配置实时应用重做 alter database recover managed standby database using current logfile; 16.查看配置是否成功:
a.查看切换状态: select switchover_status from v$database; b.手动切换归档,查看归档文件是否自动同步到备用库. 切换归档:alter system switch logfile; 在90.137和138上查看归档日志是否同步:SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#; 如果查看从库可以看到归档日志,表示归档日志同步成功,如果APPLIED列的值为yes,表示重做应用成功. 主库 从库: 配置完成.
本文出自 “天知道的技术博客” 博客,谢绝转载!