本文档只是部署dataguard的过程,不涉及概念的解释和说明,更没有dataguard理论原理的介绍,关于这方面内容,请查看oracle官方文档。
操作系统:RedHat 4.2
[oracle@dg1 ~]$ uname -a
Linux dg1 2.6.9-22.EL #1 Mon Sep 19 18:20:28 EDT 2005 i686 i686 i386 GNU/Linux
Oracle 软件:ORACLE 10g Release 10.2.0.1.0
主机信息:
机器名:dg1 IP地址:192.168.1.90
备机信息:
机器名:dg2 IP地址:192.168.1.91
以下操作,[root@dg1 ~]#表示主机root用户登录 [oracle@dg1 ~]$表示主机oracle用户登录
[root@dg2 ~]#表示备机root用户登录 [oracle@dg2 ~]$表示备机oracle用户登录
操作前提:在主机dg1上,数据库软件和oracle数据库(db01)已经安装和创建完毕,在备机dg2上,只安装了oracle软件,没有数据库,物理备数据库通过RMAN命令来创建,主库的归档已经打开。
第一步:主机数据库设置force logging,只在主库上执行操作
[oracle@dg1 oracle]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Apr 27 19:49:13 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
SQL> alter database force logging;
第二步:配置主、备机器的网络环境
通过修改主、备机器tnsnames.ora 文件配置客户端连接,通过修改主、备机器的listener.ora文件配置服务器端监听,在文件中加入静态注册
文件位置都在 /u01/app/oracle/product/10.2.0/network/admin下
以下仅以主机dg1上的文件举例,备机文件 listener.ora中的主机ip要改成192.168.1.91
关闭监听,编辑listener.ora文件内容,在备库关闭监听的操作不需要做,备库本身就没有监听
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.90)(PORT=1521)))
The command completed successfully
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = db01)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0)
(SID_NAME = db01)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.90)(PORT = 1521))
)
启动监听 ,LSNRCTL> start
tnsnames.ora文件内容
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
DB01 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.90)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db01)
)
)
PRIMARY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.90)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db01)
)
)
STANDBY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.91)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db01)
)
)
第三步:使用oracle用户在备机$ORACLE_HOME/dbs目录创建口令文件,口令要和主机sys用户的口令一致,本例中是oracle
[oracle@dg2 oracle]$orapwd file=orapwdb01 password=oracle entries=5
第四步:使用oracle用户在备机上创建standby db需要的目录结构
[root@dg2 ~]# su - oracle
[oracle@dg2 ~]$ pwd
/home/oracle
[oracle@dg2 ~]$ mkdir backup
[oracle@dg2 ~]$ cd /u01/app/oracle
[oracle@dg2 oracle]$ pwd
/u01/app/oracle
[oracle@dg2 oracle]$ mkdir -p admin/db01/adump
[oracle@dg2 oracle]$ mkdir -p admin/db01/bdump
[oracle@dg2 oracle]$ mkdir -p admin/db01/cdump
[oracle@dg2 oracle]$ mkdir -p admin/db01/ddump
[oracle@dg2 oracle]$ mkdir -p admin/db01/udump
[oracle@dg2 oracle]$ mkdir flash_recovery_area
[oracle@dg2 oracle]$ mkdir archdest
[oracle@dg2 oracle]$ mkdir -p oradata/db01
第五步:修改主备机的参数文件,添加和编辑dataguard db环境需要的参数,此步骤也可以通过alter system命令实现,以下仅以主机dg1举例,
如果数据库是打开状态,执行下面的命令
SQL> create pfile from spfile;
File created.
关闭数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
到dbs目录下,找到initdb01.ora 使用vi编辑器添加和修改相关的参数,保存退出。具体编辑过程省略。
[oracle@dg1 ~]$ cd $ORACLE_HOME/dbs
[oracle@dg1 dbs]$ ls -l
total 6960
-rw-rw---- 1 oracle oinstall 1544 Jan 13 16:16 hc_db01.dat
-rw-r--r-- 1 oracle oinstall 1421 Feb 17 17:34 initdb01.ora
-rw-r----- 1 oracle oinstall 12920 May 3 2001 initdw.ora
-rw-r----- 1 oracle oinstall 8385 Sep 11 1998 init.ora
-rw-rw---- 1 oracle oinstall 24 Jan 13 16:17 lkDB01