本文檔只是部署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