ITPub博客

首页 > Linux操作系统 > Linux操作系统 > INSTALL--Oracle9i DataGuard Setup ON Win2k

INSTALL--Oracle9i DataGuard Setup ON Win2k

原创 Linux操作系统 作者:vongates 时间:2019-07-17 21:39:02 0 删除 编辑

Oracle 9i在Win2k下创建DataGuard database 步骤

操作系統:Win2k Server + sp4
數據庫:Oracle 9201
主庫SID:orcl9i
從庫SID:orcl9i
主庫IP:192.168.60.224
從庫IP:192.168.60.225


0.安裝ORACLE(主從機上選擇相同的路徑安裝)
主庫上安裝Oracle并建立數據庫(按OMF的架構來安裝)
d:oracleadmin...
  ora92...
  oradata...
從庫上僅安裝軟體部分(選擇只安裝Software不建立數據)
d:oracleora92...

1.在從庫中建立相關必需的文件目錄(可以直接從主庫中copy,然后刪除各文件夾中的所有文件)
d:oracleadmin...
  oradata...

2.切換主庫到logging模式下
SQL> conn sys/password@primary as sysdba;
SQL> select force_logging from v$database;

FORCE_
------
NO

SQL> alter database force logging;

已更改資料庫.

SQL> select force_logging from v$database;

FORCE_
------
YES

SQL>

3.確定主庫中需復制的文件的存放路徑(數據文件和聯機日志文件)
其實在本實驗中所有需要copy的文件都放在d:oracleoradataorcl9i中
我們只需在主數據庫關閉的條件下把d:oracleoradata...全部copy過去。
C:Documents and SettingsAdministrator>sqlplus /nolog

SQL*Plus: Release 9.2.0.1.0 - Production on 星期日 4月 24 09:34:18 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SQL> conn sys/password@primary as sysdba
已連線.
SQL> select file_name from dba_data_files;

FILE_NAME
---------------------------------------------------------------------------
D:ORACLEORADATAORCL9ISYSTEM01.DBF
D:ORACLEORADATAORCL9IUNDOTBS01.DBF
D:ORACLEORADATAORCL9IVONGATES01.DBF

SQL> select member from v$logfile;

MEMBER
---------------------------------------------------------------------------
D:ORACLEORADATAORCL9IREDO01.LOG
D:ORACLEORADATAORCL9IREDO02.LOG
D:ORACLEORADATAORCL9IREDO03.LOG

SQL>

4.更改主庫為歸當(archivelog)模式
先建立存放歸檔日志存放的路徑:
d:oracleoradataorcl9iarch  --存放歸檔日志用
   starch  --設置主從互為Standby時用
sqlplus /nolog
SQL> conn / as sysdba;
Connected.
SQL> startup mount;
SQL> alter database archivelog;
SQL> archive log start;
SQL> archive log list;
SQL> alter database open;
SQL> alter system set LOG_ARCHIVE_DEST_1='LOCATION=d:oracleoradataorcl9iarch';
SQL> alter system set log_archive_start=true scope=spfile;
SQL> startup force;
SQL> archive log list;
資料庫日誌模式              儲存模式
可自動儲存             開啟
儲存目的地            D:oracleoradataorcl9iarch
最早的線上日誌順序     35
下一個日誌順序以儲存   37

目前日誌順序           37
SQL>

5.在主庫上為從庫生成control file和pfile
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS 'd:control01.ctl';

已更改資料庫.

SQL> create pfile='d:initorcl9i.ora' from spfile;

已建立檔案.

SQL>

6.修改pfile(d:initorcl9i.ora)
在文件最后新增如下4行內容
STANDBY_ARCHIVE_DEST='location=d:oracleoradataorcl9iStarch'
FAL_SERVER='PRIMARY'
FAL_CLIENT='STANDBY'
standby_file_management='AUTO'
另外需注意修改控制文件的存放路徑(本實驗中不做修改只需copy三份建好的standby的controlfile)
其中standby_file_management不是必须要,为了后面主库添加數據文件,从库能自动处理,則需加上这个参数,避免麻烦。

7.復制主庫的listener.ora文件到d:listener.ora,修改當中的host的值為從庫的主機名或IP
listener.ora文件存放在{ORACLE_HOME}networkadmin中
從庫中的listener.ora可以通過net manager來建立,
我們可以直接copy主庫中的listener.ora,只需修改當中的host的值。
e.g.
主庫:
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.224)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
      )
    )
  )
從庫:
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.225)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
      )
    )
  )

8.修改主庫的tnsnames.ora文件并復制到d:tnsnames.ora作為從庫的tnsnames.ora
主從庫的tnsnames.ora中都需包含對方的連接字串。
為了兩台主機之間的順利連通(能偵測到對方的存在)我們定義如下兩個連接字串(PRIMARY,STANDBY)
(且需配合在pfile中設定的FAL_SERVER和FAL_CLIENT值)
e.g.
PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.224)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl9i.vongates.com)
    )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.225)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl9i.vongates.com)
    )
  )

9.關閉主庫復制相關目錄及相關文件
其中d:oracleoradataorcl9i中只保留數據文件及聯機日志文件
并且清空d:oracleadmin中各相關子目錄中的所有存在的文件。

SQL> shutdown immediate;
需復制的目錄:
d:oracleadmin  ==>192.168.60.225d:oracle
  oradata ==>192.168.60.225d:oracle 
需復制的文件:
d:control01.ctl ==>192.168.60.225d:oracleoradataorcl9icontrol01.ctl
d:control01.ctl ==>192.168.60.225d:oracleoradataorcl9icontrol02.ctl
d:control01.ctl ==>192.168.60.225d:oracleoradataorcl9icontrol03.ctl
d:initorcl9i.ora==>192.168.60.225d:oracleora9idatabaseinitorcl9i.ora
d:tnsnames.ora  ==>192.168.60.225d:oracleora9inetworkadmintnsnames.ora
d:listener.ora  ==>192.168.60.225d:oracleora9inetworkadminlistener.ora
d:oracleora92databasePWDorcl9i.ora
   ==>192.168.60.225d:oracleora9idatabasePWDorcl9i.ora
啟動主庫
SQL> startup;

10 測試主從庫的tnsnames.ora配置
主库 tnsping standby
从库 tnsping primary
看分别到主从库的服务名是否配置正确
C:>tnsping standby

TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0 - Production on 24-4月 -2005 08:38:04

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

已使用的參數檔案:
D:oracleora92networkadminsqlnet.ora


使用 TNSNAMES 介面程式來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.60.225)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SER
VICE_NAME = orcl9i.vongates.com)))
OK (20 msec)

C:>tnsping primary

TNS Ping Utility for 32-bit Windows: Version 9.2.0.1.0 - Production on 24-4月 -2005 08:38:16

Copyright (c) 1997 Oracle Corporation.  All rights reserved.

已使用的參數檔案:
D:oracleora92networkadminsqlnet.ora


使用 TNSNAMES 介面程式來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.60.224)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SER
VICE_NAME = orcl9i.vongates.com)))
OK (20 msec)

C:>


11.為從庫建立實例名并啟動監聽器
c:>oradim -new -sid orcl9i
c:>lsnrctl start

12.啟動從庫到恢復模式下
sqlplus /nolog
SQL> conn sys/password@standby as sysdba
SQL> startup nomount;
已啟動 ORACLE 執行處理.

Total System Global Area  227613456 bytes
Fixed Size                   453392 bytes
Variable Size              75497472 bytes
Database Buffers          150994944 bytes
Redo Buffers                 667648 bytes

SQL> alter database mount standby database;

已更改資料庫.

SQL> alter database recover managed standby database disconnect from session;

已更改資料庫.

SQL>


13.在主库上设置到从库的归档
SQL> conn / as sysdba
已連線.
SQL> alter system set log_archive_dest_2='service=standby mandatory reopen=60';

已更改系統.

SQL> alter system switch logfile;

已更改系統.

SQL> archive log list;
資料庫日誌模式              儲存模式
可自動儲存             開啟
儲存目的地            D:oracleoradataorcl9iarch
最早的線上日誌順序     36
下一個日誌順序以儲存   38

目前日誌順序           38
SQL> /

已更改系統.

SQL>
到從庫(192.168.60.225)的D:oracleadminorcl9ibdumporcl9i_arler.log
看当前归档日志是否已经正常完成恢复
相關內容如下:
Sun Apr 24 08:49:32 2005
Completed: alter database recover managed standby database di
Sun Apr 24 08:52:47 2005
Media Recovery Log D:ORACLEORADATAORCL9ISTARCHARC00036.001
Media Recovery Log D:ORACLEORADATAORCL9ISTARCHARC00037.001
Media Recovery Waiting for thread 1 seq# 38
Media Recovery Log D:ORACLEORADATAORCL9ISTARCHARC00038.001
Media Recovery Waiting for thread 1 seq# 39
Media Recovery Log D:ORACLEORADATAORCL9ISTARCHARC00039.001
Media Recovery Waiting for thread 1 seq# 40
也可以在從(192.168.60.225)的d:oracleoradataorcl9istarch中看是不有對應該的歸檔日志文件存在
至此data guard配置完成。

14.使從庫在只讀方式和恢復模式之間切換。
從恢復模式切換到只讀方式
SQL> conn sys/password@standby as sysdba;
SQL> alter database recover managed standby database cancel;
SQL> alter database open read only;
從只讀到恢復模式
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE disconnect from session;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29987/viewspace-51752/,如需转载,请注明出处,否则将追究法律责任。

下一篇: Essay--學習吧
请登录后发表评论 登录
全部评论

注册时间:2018-09-11

  • 博文量
    449
  • 访问量
    292703