ITPub博客

首页 > 数据库 > Oracle > Oracle10.2.0.1 DataGuard部署

Oracle10.2.0.1 DataGuard部署

原创 Oracle 作者:蓦然princes 时间:2015-10-17 17:20:51 0 删除 编辑

Oracle10.2.0.1 DataGuard部署--王清清


一、实验环境

rhel-server-5.5-x86_64-dvd.iso

Oracle 10201_database_linux_x86_64

INSTANCE SID

DB NAME

IP

STORAGE

orcl

orcl

192.168.248.19

File system

wood

orcll

192.168.248.151

file system

 

 

 

 

 

二、开始配置primarystandby

2.1启用强制日志功能

主库备库启用强制日志功能

SQL> select force_logging from v$database;

SQL> ALTER DATABASE FORCE LOGGING;

2.2启用归档模式

主库备库启用归档模式


点击(此处)折叠或打开

  1. shutdown immediate;
  2. startup mount;
  3. alter database archivelog;
  4. alter database open


2.3 PrimaryStandby创建口令文件

主库备库创建口令文件


点击(此处)折叠或打开

  1. #su – oracle
  2. orapwd FILE='/u01/app/oracle/product/10.2.0/db_1/dbs/orapworcl' PASSWORD=oracle ENTRIES=5;
  3. #su - oracle
  4. orapwd FILE='/u01/app/oracle/product/10.2.0/db_1/dbs/orapwwood' PASSWORD=oracle ENTRIES=5;


2.4配置standby redo logfile

在主库和备库分别添加standby redo logfile

  1. alter database add standby logfile thread 1 group 4('/u01/app/oracle/oradata/orcl/redo04.log') size 50M;
  2.  alter database add standby logfile thread 1 group 5('/u01/app/oracle/oradata/orcl/redo05.log') size 50M;
  3.  alter database add standby logfile thread 1 group 6('/u01/app/oracle/oradata/orcl/redo06.log') size 50M;
  4.  alter database add standby logfile thread 1 group 7('/u01/app/oracle/oradata/orcl/redo07.log') size 50M



2.5配置network service

2.5.1静态注册主、备库


点击(此处)折叠或打开

  1. 主库:192.168.248.19
  2. $more listener.ora
  3. #########################使用静态注册
  4.   SID_LIST_LISTENER=
  5.   (SID_LIST=
  6.     (SID_DESC=
  7.       (GLOBAL_DBNAME=cxdb)
  8.       (SID_NAME=orcl)
  9.       (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
  10.     )
  11.   )
  12.  
  13. LISTENER=
  14.   (DESCRIPTION_LIST=
  15.     (DESCRIPTION=
  16.       (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.248.19)(PORT=1521))
  17.       (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
  18.     )
  19.   )
  20. ###
  21.  
  22. 备库192.168.248.151
  23. $more listener.ora
  24. ###############################使用静态注册
  25. SID_LIST_LISTENER=
  26.   (SID_LIST=
  27.     (SID_DESC=
  28.       (GLOBAL_DBNAME=xxdb)
  29.       (SID_NAME=wood)
  30.       (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
  31.     )
  32.   )
  33.  
  34. LISTENER=
  35.   (DESCRIPTION_LIST=
  36.     (DESCRIPTION=
  37.       (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.248.151)(PORT=1521))
  38.       (ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0))
  39.     )
  40.   )
  41. #######


2.5.2配置tnsnames.ora


点击(此处)折叠或打开

  1. 主库和备库的tnsnames.ora如下
  2. $more tnsnames.ora
  3. # Generated by Oracle configuration tools.
  4. xxnet =
  5.   (DESCRIPTION =
  6.     (ADDRESS_LIST =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.248.151)(PORT = 1521))
  8.     )
  9.     (CONNECT_DATA =
  10.       (SID = wood)
  11.       (SERVICE_NAME = xxdb)
  12.     )
  13.   )
  14.  
  15. cxnet =
  16.   (DESCRIPTION =
  17.     (ADDRESS_LIST =
  18.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.248.19)(PORT = 1521))
  19.     )
  20.     (CONNECT_DATA =
  21.       (SID = orcl)
  22.       (SERVICE_NAME = cxdb)
  23.     )
  24.   )
  25. ########


 

2.5.3启动listener、测试网络

启动主、备库监听,测试网络通畅

$lsnrctl start

2.6配置主、备库初始化参数文件

主库:192.168.248.19,添加以下参数


点击(此处)折叠或打开

  1. DB_UNIQUE_NAME=cxdb
  2. LOG_ARCHIVE_CONFIG='DG_CONFIG=(cxdb,xxdb)'
  3. LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/flash_recovery_area/ORCL/arch1/ VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)'
  4. LOG_ARCHIVE_DEST_2='LOCATION=/u01/app/oracle/flash_recovery_area/ORCL/arch2/ VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)'
  5. LOG_ARCHIVE_DEST_3='SERVICE=xxnet LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=xxdb'
  6. LOG_ARCHIVE_DEST_STATE_1=ENABLE
  7. LOG_ARCHIVE_DEST_STATE_2=ENABLE
  8. REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
  9. DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/'
  10. LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/'
  11. STANDBY_FILE_MANAGEMENT=AUTO
  12. FAL_SERVER=xxnet
  13. FAL_CLIENT=cxnet
  14. ######################


备库:192.168.248.151,添加以下参数


点击(此处)折叠或打开

  1. DB_UNIQUE_NAME=cxdb
  2. LOG_ARCHIVE_CONFIG='DG_CONFIG=(cxdb,xxdb)'
  3. LOG_ARCHIVE_DEST_1='LOCATION=/u01/app/oracle/flash_recovery_area/arch1/ VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)'
  4. LOG_ARCHIVE_DEST_2='LOCATION=/u01/app/oracle/flash_recovery_area/arch2/ VALID_FOR=(STANDBY_LOGFILE,STANDBY_ROLE)'
  5. LOG_ARCHIVE_DEST_3='SERVICE=cxnet LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=cxdb'
  6. LOG_ARCHIVE_DEST_STATE_1=ENABLE
  7. LOG_ARCHIVE_DEST_STATE_2=ENABLE
  8. REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
  9. DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/','/u01/app/oracle/oradata/orcl/'
  10. LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/','/u01/app/oracle/oradata/orcl/'
  11. STANDBY_FILE_MANAGEMENT=AUTO
  12. FAL_SERVER=cxnet
  13. FAL_CLIENT=xxnet
  14. #####################


三、一步一步创建physical standby

3.1 备份主库


点击(此处)折叠或打开

  1. run{
  2.       backup database format '/u01/backup/full_%U' plus archivelog format
  3. '/u01/backup/arc_%U';
  4.  }

3.2 创建standby controlfile


点击(此处)折叠或打开

  1. SQL> STARTUP MOUNT;
  2. SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/u01/backup/st.ctl';
  3. SQL> ALTER DATABASE OPEN

3.3 使用RMAN进行创建standby database


3.3.1 将主库的备份集和controlfile拷贝到备库相同目录下

3.3.2 使用rman进行创建standby DB


点击(此处)折叠或打开

  1. [oracle@localhost~]$ rman target / auxiliary sys/oracle@xxnet
  2. RMAN> duplicate target database for standby


四、创建完检查physical standby状态

4.1 physical standby创建完检查

4.1.1检查主、备角色

SQL> select database_role, switchover_status from v$database;

DATABASE_ROLE    SWITCHOVER_STATUS

---------------- --------------------

PHYSICAL STANDBY SESSIONS ACTIVE

4.1.2启动备库recovery进程

alter database recover managed standby database disconnect from session;

4.1.3 检查standby DB进程状态

SQL>select PROCESS,STATUS,CLIENT_PROCESS ,THREAD#,SEQUENCE# 

from V$MANAGED_STANDBY;

 

PROCESS   STATUS       CLIENT_P    THREAD#  SEQUENCE#

--------- ------------ -------- ---------- ----------

ARCH      CLOSING      ARCH              1         40

ARCH      CLOSING      ARCH              1         41

RFS       IDLE         LGWR              1         42

RFS       IDLE         UNKNOWN           0          0

MRP0      WAIT_FOR_LOG N/A               1         42

RFS       IDLE         UNKNOWN           0          0

 

6 rows selected.

 

SQL>

4.1.4主库切换日志,备库查看sequence#

主库切换日志:

SQL> alter system switch logfile;

备库查看进程等待日志序列号:

 

SQL> select PROCESS,STATUS,CLIENT_PROCESS ,THREAD#,SEQUENCE# 

from V$MANAGED_STANDBY;

 

PROCESS   STATUS       CLIENT_P    THREAD#  SEQUENCE#

--------- ------------ -------- ---------- ----------

ARCH      CLOSING      ARCH              1         42

ARCH      CLOSING      ARCH              1         41

RFS       IDLE         UNKNOWN           0          0

MRP0      WAIT_FOR_LOG N/A               1         43

RFS       IDLE         UNKNOWN           0          0

RFS       IDLE         LGWR              1         43

 

6 rows selected.

 

SQL>

五、主、备角色切换

顺序:

主库-》备库

备库-》主库

5.1 主库切换成备库

alter database commit to switchover to physical standby;

alter database recover managed standby database disconnect from session;

select database_role from v$database;

5.2 备库切换成主库

alter database commit to switchover to physical primary;

alter database open;

 

5.3 主库切换日志、备库查看日志应用

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

请登录后发表评论 登录
全部评论

注册时间:2015-08-03

  • 博文量
    21
  • 访问量
    31152