primary主库
IP:192.168.50.4/24
dbname:ora10g
数据库版本:10g R2
操作系统版本:rhel6.0 64位
standby物理备库
IP:192.168.50.230/24
dbname:ora10g
数据库版本:10g R2
操作系统版本:rhel5.4 64位
一:配置Oracle网络,主库和备库两边都需要配置
[oracle@rhel6 ~]$ vi /u01/app/oracle/network/admin/tnsnames.ora
PRIMARY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.4)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora10g.766.com)
)
)
STANDBY =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.50.230)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora10g.766.com)
)
)
二:主库端配置,修改初始化参数,生成备库的控制文件
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FORCE_LOG
---------
YES
SQL> create pfile='/home/oracle/initora10g.ora' from spfile;
File created.
文件末尾处添加
log_archive_dest_1='LOCATION=/u01/arch/'
log_archive_dest_state_1=enable
log_archive_dest_2='SERVICE=standby'
log_archive_dest_state_2=enable
log_archive_format='%t_%s_%r.arc'
log_archive_max_processes=2
fal_server=standby
fal_client=primary
db_unique_name=ora10g
SQL> alter database create standby controlfile as '/u01/app/oradata/ora10g/standby.ctl';
Database altered.
关闭主库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
三:备库端配置
[oracle@localhost ~]$ scp -rvp 192.168.50.4:/u01/app/oradata/ora10g /u01/app/oradata
[oracle@localhost ~]$ scp 192.168.50.4:/home/oracle/initora10g.ora /u01/app/oracle/dbs/
修改参数内容如下:
log_archive_dest_1='LOCATION=/u01/arch/'
log_archive_dest_state_1=enable
log_archive_dest_2='SERVICE=primary'
log_archive_dest_state_2=enable
log_archive_format='%t_%s_%r.arc'
log_archive_max_processes=2
fal_server=primary
fal_client=standby
db_unique_name=ora10g
创建相关目录和文件
[oracle@localhost ~]$ mkdir /u01/arch/
[oracle@localhost ~]$ mkdir -p /u01/app/admin/ora10g/{adump,bdump,cdump,udump}
[oracle@localhost ~]$ cd /u01/app/oradata/ora10g/
[oracle@localhost ora10g]$ mv standby.ctl control01.ctl
[oracle@localhost ora10g]$ cp control01.ctl control02.ctl
[oracle@localhost ora10g]$ cp control01.ctl control03.ctl
[oracle@localhost ~]$ orapwd file=$ORACLE_HOME/dbs/orapwora10g password=123456 entries=5
四:测试
启动主库:
Connected to an idle instance.
SQL> create spfile from pfile='/home/oracle/initora10g.ora';
File created.
SQL> startup
SQL> select name,database_role from v$database;
NAME DATABASE_ROLE
--------------------------- ------------------
ORA10G PRIMARY
启动备库:
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 4 16:49:39 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> create spfile from pfile;
File created.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 629145600 bytes
Fixed Size 2022824 bytes
Variable Size 180355672 bytes
Database Buffers 440401920 bytes
Redo Buffers 6365184 bytes
SQL> alter database mount standby database;
SQL> select name,database_role from v$database;
NAME DATABASE_ROLE
--------------------------- ----------------------
ORA10G PHYSICAL STANDBY
SQL> alter database recover managed standby database disconnect from session;
Database altered.
主库上新建表,切换在线日志组测试:
SQL> create table hr.dg01 as select * from dba_source;
Table created.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
备库:
SQL> select sequence#,first_time,next_time,applied from v$archived_log;
SEQUENCE# FIRST_TIME NEXT_TIME APPLIED
---------- ------------------- ------------------- ---------
91 2011-08-04-14:38:52 2011-08-04-14:41:21 YES
92 2011-08-04-14:41:21 2011-08-04-15:13:44 YES
93 2011-08-04-15:13:44 2011-08-04-15:15:07 YES
94 2011-08-04-15:15:07 2011-08-04-15:42:58 YES
95 2011-08-04-15:42:58 2011-08-04-16:55:53 YES
96 2011-08-04-16:55:53 2011-08-04-16:56:11 YES
97 2011-08-04-16:56:11 2011-08-04-16:56:18 YES
98 2011-08-04-16:56:18 2011-08-04-16:56:33 YES
8 rows selected.
将备库置为只读状态,验证数据:
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open read only;
Database altered.
SQL> select count(*) from hr.dg01;
COUNT(*)
----------
323203
重新将备库置为应用redo log状态
SQL> alter database recover managed standby database disconnect from session;
Database altered.
©著作权归作者所有:来自51CTO博客作者ylw6006的原创作品,谢绝转载,否则将追究法律责任
oracle职场dataguardData guard
共同学习,写下你的评论
评论加载中...
作者其他优质文章