ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 物理DG!Oracle 10G Data Guard Demo

物理DG!Oracle 10G Data Guard Demo

原创 Linux操作系统 作者:chicken0915 时间:2012-07-12 00:37:13 0 删除 编辑

Oracle 10G Data Guard Demo
===============================================
monitor
name:liuzk
ipv :192.168.44.102
ip :192.168.1.80
OS :XP

name:lzk101
ip :192.168.44.101
OS :Redhat 4
DB:oracle10g r2

name:lzk103
ip :192.168.44.103
OS :Redhat 4
DB:oracle10g r2

===============================================
-- Data Guard Concepts and Administration
1:Introduction to Oracle Data Guard
3:Creating a Physical Standby Database

--Data Guard Workshop Steps
1、Configure Oracle Net
2、Configure Primary Database
3、Confiture Physical Standby Database
4、Testing & Troubleshooting

-----------------------------------------------
#:lzk101
$env | grep ORA
ORACLE_SID=lzk101
ORACLE_BASE=/u01
ORACLE_HOME=/u01/home

TNSNAMES:
lzk101 ip:101
lzk103 ip:103

SQL>alter database force logging;

SQL>create pfile from spfile;

$ orapwd file=orapwdorcl password=oracle entries=5

$ cd /u01/oracle/dbs/
$ vi initlzk101.ora
...
...
log_archive_dest_1='location=/u01/oradata/arch'
log_archive_dest_state_1=enable
log_archive_dest_2='service=lzk103'
log_archive_dest_state_2=enable
log_archive_start=true   :10G not
log_archive_format='%t_%s_%r.arc'
log_archive_max_processes=2
fal_server=lzk103
fal_client=lzk101
db_unique_name=lzk101

Esc :x
-----------------------------------------------
SQL>shutdown immediate
SQL>startup mount
SQL>alter database create standby controlfile as '/u01/oradata/lzk101/lzk101.ctl'
SQL>alter database open
SQL>shutdown immediate
-----------------------------------------------
vi /etc/hosts
192.168.1.101 lzk101
192.168.1.103 lzk103

copys files
/u01/oradata/
/u01/admin
/u01/oracle/dbs/

$cd /u01/oradata/
$scp -r lzk101 lzk103:/u01/oradata/

$cd ../admin
$scp -r lzk101 lzk103:/u01/admin

$cd /u01/oracle/dbs/
$scp initlzk101.ora orapwdlzk101 lzk103:/u01/oracle/dbs

-----------------------------------------------
===============================================
#:lzk103 只安装软件不安装库

$env | grep ORA
ORACLE_SID=lzk101  或者|export ORACLE_SID=lzk101
ORACLE_BASE=/u01
ORACLE_HOME=/u01/home

TNSNAMES:
lzk101 ip:101
lzk103 ip:103

检测TNSNAMES配置正常状态,可以互联测试。

$cd /u01/oradata/lzk101
rm -rf control*
$mv lzk101.ctl control01.ctl
$cp control01.ctl control02.ctl
$cp control01.ctl control03.ctl

$cd /u01/oracle/dbs
vi initlzk101.ora
...
...
log_archive_dest_1='location=/u01/oradata/arch'
log_archive_dest_state_1=enable
log_archive_dest_2='service=lzk101'
log_archive_dest_state_2=enable
log_archive_start=true  :10G not
log_archive_format='%t_%s_%r.arc'
log_archive_max_processes=2
fal_server=lzk101
fal_client=lzk103
db_unique_name=lzk103

Esc :x
-----------------------------------------------
===============================================
全部配置完成:

启动主库:
启动主端的LSNRCTL Server

$sqlplus /nolog
SQL>conn /as sysdba
SQL>create spfile from pfile
SQL>startup

SQL>alter system set log_archive_dest_2='SERVICE=lzk203 LGWR ASYNC NOAFFIRM db_unique_name=orcl' scope=both;
启动备库:
启动备端的LSNRCTL Server
$sqlplus /nolog
SQL>conn /as sysdba
SQL>create spfile from pfile
SQL>startup nomount;
SQL>alter database mount standby database;
SQL> alter system set log_archive_dest_2='SERVICE=lzk201 LGWR ASYNC NOAFFIRM db_unique_name=orcl' scope=both;

SQL>select name,database_role from v$database;
NAME           DATABASE_ROLE
------------   ---------------
LZK101         PHYSICAL STANDBY

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

 


=============================================================
SQL>conn sys/sys@lzk101 as sysdba

SQL>select name,database_role from v$database;
NAME           DATABASE_ROLE
------------   ---------------
LZK101         PRIMARY

SQL>create table dgtest(id int,name char(10));
SQL>insert into dgtest values(1,'lzk');
SQL>insert into dgtest values(2,'lzk');
SQL>commit;

SQL>alter system switch logfile;

SQL>alter system switch logfile;

SQL>alter system switch logfile;

SQL>alter system switch logfile;

=============================================================
lzk103

SQL>select sequence#,first_time,next_time from v$archived_log order by sequence#;
...
...
...
SQL>select sequence#,applied from v$archived_log order by sequence#;
NO
...
..
...

YES

SQL>alter database recover managed standby database cancel;

SQL>alter database open read only;

SQL>select * from dgtest;
...
...

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

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

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

注册时间:2012-07-01

  • 博文量
    41
  • 访问量
    75586