物理DG!Oracle 10G Data Guard Demo

chicken0915發表於2012-07-12

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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章