Vous êtes sur la page 1sur 8

Data guard setup:

================
192.168.234.153
192.168.234.154

primary
standby

DATA GUARD CONFIGURATION WITH PHYSICAL STANDBY MACHINE


------------------------------------------------------1.In the standby db have only the Oracle software not the database.
2.In the primary server side database must be present and also the database in a
rchivelog mode.
3.both machine IP Adress must be set on primary and standby on operating level.
on the primary side ping standby machine.
# ping 192.168.234.154
on the standby side ping primary machine.
# ping 192.168.234.153
NOTE:- Operating system version must be same both machines.
SQL> select instance_name,status from v$instance;
INSTANCE_NAME
STATUS
---------------- -----------PRIMEDB
OPEN
SQL> select name,open_mode from v$database;
NAME
OPEN_MODE
--------- -------------------PRIMEDB READ WRITE
Primary database must be in Archivelog mode.
> create pfile='$ORACLE_HOME/dbs/pfile/initprimary.ora' from spfile;
> shu immediate
(after shutdown primary instance open the initprimary.ora parameter file of prim
ary side .) and
modify primary machine parameters.
#
#
#
#
#
#
#
#
#
#
#
#
#
#

db_unique_name='PRIMARY'
FAL_Client='to_primary'
FAL_Server='to_standby'
Log_archive_config='DG_CONFIG=(primary,standby)'
Log_archive_dest_1='Location=c:\oracle\backup
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
db_unique_name=primary'
Log_archive_dest_2='Service=to_standby
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
db_unique_name=standby'
Log_archive_dest_state_1=ENABLE
Log_archive_dest_state_2=DEFER
Service_names='primary'
Standby_File_Management='AUTO'

db_unique_name='PRIMARY'
FAL_Client='primary'
FAL_Server='standby'
Log_archive_config='DG_CONFIG=(primary,standby)'
Log_archive_dest_1='Location=use_db_recovery_file_dest
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
db_unique_name=primary'
Log_archive_dest_2='Service=standby
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
db_unique_name=standby'
Log_archive_dest_state_1=ENABLE
Log_archive_dest_state_2=ENABLE
Service_names='PRIMEDB'
Standby_File_Management='AUTO'
and save it
Rename the pfile from initprimedb.ora to initprimary.ora
Create the password file
[oracle@primary ~]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwpri
mary password=sys force=y ignorecase=y
[oracle@primary dbs]$ export ORACLE_SID=primary
[oracle@primary dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 21 15:18:10 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprimary.ora' mou
nt
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size
2217912 bytes
Variable Size
490735688 bytes
Database Buffers
335544320 bytes
Redo Buffers
2433024 bytes
Database mounted.
SQL> archive log list
Database log mode
Automatic archival
Archive destination
Oldest online log sequence
Next log sequence to archive
Current log sequence

Archive Mode
Enabled
USE_DB_RECOVERY_FILE_DEST
2
4
4

SQL> alter database force logging;


Database altered.

SQL> alter database flashback on;


Database altered.

SQL> alter database add standby logfile '/u01/app/oracle/oradata/PRIMEDB/stdredo


1.log' size 150m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/PRIMEDB/stdredo
2.log' size 150m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/PRIMEDB/stdredo
3.log' size 150m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/PRIMEDB/stdredo
4.log' size 150m;
Database altered.
SQL> shut immediate
ORA-01109: database not open
Create same folder structure in standby machine.
[oracle@primary ~]$ scp /u01/app/oracle/oradata/PRIMEDB/*.log standby:/u01/app/o
racle/oradata/PRIMEDB
The authenticity of host 'standby (192.168.234.154)' can't be established.
RSA key fingerprint is c9:b7:f6:21:68:75:60:9d:bd:c8:8a:67:db:d1:6d:2c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'standby,192.168.234.154' (RSA) to the list of known
hosts.
oracle@standby's password:
Permission denied, please try again.
oracle@standby's password:
stdredo1.log
100% 150MB 10.0MB/s 00:15
stdredo2.log
100% 150MB 11.5MB/s 00:13
stdredo3.log
100% 150MB 16.7MB/s 00:09
stdredo4.log
100% 150MB 10.7MB/s 00:14
[oracle@primary ~]$ scp /u01/app/oracle/oradata/PRIMEDB/datafile/*.log standby:/
u01/app/oracle/oradata/PRIMEDB/datafile
[oracle@primary ~]$ export ORACLE_SID=primary
[oracle@primary ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 21 15:56:14 2016


Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprimary.ora' mou
nt
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size
2217912 bytes
Variable Size
490735688 bytes
Database Buffers
335544320 bytes
Redo Buffers
2433024 bytes
Database mounted.
SQL> alter database create standby controlfile as '/u01/app/oracle/oradata/PRIME
DB/stdcontrol01.ctl';
Database altered.
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64
bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@primary ~]$ scp /u01/app/oracle/oradata/PRIMEDB/stdcontrol01.ctl standby
:/u01/app/oracle/oradata/PRIMEDB
oracle@standby's password:
stdcontrol01.ctl
[oracle@primary ~]$ scp /u01/app/oracle/oradata/PRIMEDB/stdcontrol01.ctl standby
:/u01/app/oracle/oradata/PRIMEDB
oracle@standby's password:
stdcontrol01.ctl
[oracle@primary ~]$ scp /u01/app/oracle/oradata/PRIMEDB/stdcontrol01.ctl standby
:/u01/app/oracle/flash_recovery_area/PRIMEDB/controlfile/control02.ctl
oracle@standby's password:
stdcontrol01.ctl
100% 9520KB 9.3MB/s 00:01
[oracle@primary ~]$ export ORACLE_SID=primary
[oracle@primary ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 21 16:07:46 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initprimary.ora' mou


nt
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size
2217912 bytes
Variable Size
490735688 bytes
Database Buffers
335544320 bytes
Redo Buffers
2433024 bytes
Database mounted.
SQL> create spfile from pfile;
File created.
SQL> shu immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size
2217912 bytes
Variable Size
490735688 bytes
Database Buffers
335544320 bytes
Redo Buffers
2433024 bytes
Database mounted.
Database opened.
SQL> host
Create the Listener
[oracle] netmgr
host: primary.oracle.com
port: 1521
Global database name: primary_DGMGRL
SID: primary
[oracle@primary ~]$ lsnrctl start LISTENER
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-OCT-2016 16:22:41
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/liste
ner.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/primary/listener/alert/log.
xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=primary.oracle.com)(PORT


=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=primary.oracle.com)(PORT
=1521)))
STATUS of the LISTENER
-----------------------Alias
LISTENER
Version
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date
21-OCT-2016 16:22:42
Uptime
0 days 0 hr. 0 min. 1 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/list
ener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/primary/listener/alert/lo
g.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=primary.oracle.com)(PORT=1521)))
Services Summary...
Service "Oracle8" has 1 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "primary_DGMGRL" has 1 instance(s).
Instance "primary", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@primary dbs]$ scp initprimary.ora standby:/u01/app/oracle/product/11.2.0
/db_1/dbs/initstandby.ora
oracle@standby's password:
initprimary.ora
100% 1553
1.5KB/s 00:00
[oracle@primary dbs]$

STANDBY SERVER
===============
vi initstandby.ora
*.dispatchers='(protocol=TCP) (service=standby_DGMGRL)'
db_unique_name='STANDBY'
FAL_Client='standby'
FAL_Server='primary'
Log_archive_config='DG_CONFIG=(primary,standby)'
Log_archive_dest_1='Location=use_db_recovery_file_dest
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
db_unique_name=standby'
Log_archive_dest_2='Service=primary
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
db_unique_name=primary'
Log_archive_dest_state_1=ENABLE
Log_archive_dest_state_2=ENABLE
Service_names='PRIMEDB'
Standby_File_Management='AUTO'
[oracle@standby ~]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwsta

ndby password=sys force=y ignorecase=y


Create the Listener
[oracle] netmgr
host: standby.oracle.com
port: 1521
Global database name: standby_DGMGRL
SID: standby
[oracle@standby ~]$ lsnrctl start LISTENER
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 21-OCT-2016 16:42:34
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/liste
ner.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/standby/listener/alert/log.
xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=standby.oracle.com)(PORT
=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=standby.oracle.com)(PORT
=1521)))
STATUS of the LISTENER
-----------------------Alias
LISTENER
Version
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date
21-OCT-2016 16:42:35
Uptime
0 days 0 hr. 0 min. 0 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/list
ener.ora
Listener Log File
/u01/app/oracle/diag/tnslsnr/standby/listener/alert/lo
g.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=standby.oracle.com)(PORT=1521)))
Services Summary...
Service "standby_DGMGRL" has 1 instance(s).
Instance "standby", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@standby ~]$ export ORACLE_SID=standby
[oracle@standby ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 21 16:44:13 2016
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initstandby.ora' mou


nt
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'LISTENER_PRIMEDB'
Here there is a problem with tnslister.ora entry, so i have updated it.
SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initstandby.ora' mou
nt
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size
2217912 bytes
Variable Size
490735688 bytes
Database Buffers
335544320 bytes
Redo Buffers
2433024 bytes
Database mounted.
SQL>
SQL> create spfile from pfile;
File created.
SQL> shut immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 830930944 bytes
Fixed Size
2217912 bytes
Variable Size
490735688 bytes
Database Buffers
335544320 bytes
Redo Buffers
2433024 bytes
Database mounted.
SQL> alter database force logging;
alter database force logging
*
ERROR at line 1:
ORA-12920: database is already in force logging mode
SQL> alter database flashback on;
Database altered.

Vous aimerez peut-être aussi