Upload
vucong
View
257
Download
3
Embed Size (px)
Citation preview
Oracle 11g r2 Data guard Implementation with Physical Standby Using RMAN and Active Dataguard Broker-MFINO HA-DR Implementation------------------------------------------------------------------------
Abstract: Oracle Data Guard is a crucial part of the Oracle Database 11g Enterprise Edition that guarantees against unrecoverable disasters. Each new release of Oracle has augmented these disaster recovery features, and Oracle Database 11g r2 expands them dramatically to include the capability to keep a standby database open for read-only queries while still accepting change vectors from the primary database. I am going to explain how to set up a standby database environment using Oracle 11g’s new Recovery Manager Features and then implementing Dataguard broker for automating Switchover using FSFO.
Assumptions: Below talks about minimal configuration required for ADG HA-DR Configuration and for UAT purpose. The configuration needs to be tuned for actual production. Scripts and configuration files are only for guidelines.
1. Make sure Oracle 11g r2 software is installed on both the nodes including Primary and Secondary. I will be using two machines RedHat Enterprise Linux 5.3 Servers each with having more than 1 GB of physical RAM, 2GB of SWAP space and sufficient Temp space.
2. While installing software make sure you use OFA for mount points which makes DBA task easier for maintaining DB.
3. Create Database on Primary Node using OMF(Oracle Managed Files). You can select Flashback recovery option during Database creation as it is one of the pre-requisite for the FSFO(Fast Start Failover). At the same time you can enable archive log options which designate Log_archive_dest_1. I won’t suggest to keep archive log files into DB_RECOVERY_FILE_DEST(place used for keeping flashback logs). Create a separate folder on the file system say /u01/app/oracle/archive – to hold archive logs. The same will be designated as log_archive_dest_1. While setting up archive log you can specify any specific format you want say i have used log_%s_%t_%r.arc as the archive log format.
4. On both the machines use same mount points for ORACLE_HOME and ORACLE_BASE for easier creation.
5. Assuming Primary DB is mfinop and Secondary DB is mfinos i mean instances or DB_UNIQUE_NAME)
Preparing primary database for Physical Standby
Query the primary database for archive log and Flashback settings- If you have already followed the steps mentioned above it should reflect teh required changes else you need to manually do it explained below.
SQL> archive log list Database log mode Archive Mode
Automatic archival EnabledArchive destination /u01/app/oracle/archiveOldest online log sequence 1Next log sequence to archive 3Current log sequence 3
If the query reflects like above it mean archive log is enabled. Else issue following on primary DB: For doing so go to mount mode and issue these
-- Set an appropriate format for archived redo logsALTER SYSTEM SET log_archive_format = 'log_%s_%t_%r.arc' SCOPE=SPFILE;
-- Set the new DB_UNIQUE_NAME parameter (it can't be set dynamically)ALTER SYSTEM SET db_unique_name = 'primarydb' SCOPE=SPFILE; Issue following on Primary:SQL> alter database force logging;
Set Up Standby Redo Log Groups. Oracle has recommended the configuration of standby redo log (SRL) groups since they became available in Oracle 9i Release 2. SRLs are required for the Real Time Apply feature or if the DBA wants to implement the ability to cascade redo log destinations; otherwise, they are still optional for configuration of a standby database. Another advantage of Oracle 11g is that if SRLs have already been configured on the primary database, then the DUPLICATE DATABASE command will automatically create them on the standby database during execution of its memory script. Notice that I also multiplexed the SRL files to protect against the loss of a complete SRL group, just as is recommended for online redo log groups.
A Standby Redo log is added to enable Data Guard Maximum Availability and Maximum Protection modes. It is important to configure the Standby Redo Logs (SRL) with the same size as the online redo logs. In this example I'm using Oracle Managed Files, that's why I don't need to provide the SRL path and file name. If you are not using OMF's you then must pass the full qualified name. Listing 1.2 shows the commands I issued to create SRLs on the primary site;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 50M;Database altered. SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 50M;Database altered. SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 50M;Database altered.SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 SIZE 50M;Database altered.
--You can see the size of log file using: - Just for verification Purpose.SQL> select bytes from v$log; It will display the size of redo Log; in BYTES; BYTES---------- 52428800 52428800 52428800—- - Just for verification Purpose.
/* || Listing 1.3:|| Setting up appropriate initialization parameter values for primary database*/
ALTER SYSTEM SET log_archive_dest_state_1 = 'ENABLE';ALTER SYSTEM SET standby_file_management = 'AUTO';ALTER SYSTEM SET log_archive_config = 'DG_CONFIG=(mfinop,mfinos)';
ALTER SYSTEM SET log_archive_dest_1 = 'LOCATION=/u01/app/oracle/archive/ DB_UNIQUE_NAME=mfinop VALID_FOR=(ALL_LOGFILES,ALL_ROLES)' scope = spfile;ALTER SYSTEM SET log_archive_dest_2='service=mfinos LGWR ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=mfinos' scope = spfile;ALTER SYSTEM SET log_archive_dest_state_2 = 'ENABLE';
Network Configuration Changes. Finally, I need to insure that the primary and standby databases can communicate over the network. The only required change to the primary database server’s network configuration is the addition of the standby database’s instance to the local naming configuration file (TNSNAMES.ORA). The standby database server’s LISTENER.ORA configuration file also requires a listener with a static listening endpoint for the standby database’s instance. These changes are shown in Listing 1.4.
alter system set local_listener='(address=(host=IP_OF_PRIMARY)(port=1521)(protocol=tcp))'; ---On Primary with primary addressalter system set local_listener='(address=(host=IP_OF_STDBY)(port=1521)(protocol=tcp))';--On Secondary with secondary address(After RMAN Duplication).alter system register;
alter system set local_listener='(address=(host=10.49.49.2)(port=1521)(protocol=tcp))';
Verify SQL> show parameter local_listener
NAME TYPE VALUE------------------------------------ ----------- ------------------------------local_listener string (address=(host=dbhost-a)(port= 1522)(protocol=tcp))
Note: Your configuration for network should look like above- place these files appropriately on primary and physical standby.
Preparing to Clone: Preparing the Standby Site
Now that the primary site is ready for cloning, I need to make some additional adjustments to its corresponding standby site:
Create Required Directories. I’ll need to create the appropriate destination directories for the database’s control files, data files, online redo logs, and standby redo logs. I’ll also create an appropriate directory for the database’s audit trails. Create similar structure on Secondary machine for adump, flash_recovery_area, oradata etc.
Set Up Password File. Since the primary database will need to communicate with the standby database using remote authentication, I’ll create a new password file via the orapwd utility, making sure that the password for SYS matches that of the primary database. (Note that I could have also copied it directly from the primary database’s site to the standby database’s primary site.) Check $ORACLE_HOME/dbs for the created file.
[StandbyNode] > orapwd file=orapwmfinos password=syspassword force=y
Or
scp -p orapwmfinop stdbyhost:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwmfinos
Create Standby initialization file.
Cd $ORACLE_HOME
[Stdby]vi initmfinos.ora
Add DB_NAME=mfinos
Save and Close.
/*
|| Listing 1.5:
|| "Temporary" initialization parameter file for standby database
*/
####
# File: initmfinos.ora
# Purpose: "Dummy" PFILE to enable startup of standby database
# instance during DUPLICATE DATABASE over the network
#####
DB_NAME=mfinos
To give DUPLICATE DATABASE a target for the cloning operation, I’ll start the standby site’s
listener, and then I’ll start the standby database instance in NOMOUNT mode using the PFILE I created above:
$> export ORACLE_SID=mfinos
$> sqlplus / as sysdba
SQL> startup nomount pfile='/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initmfinos.ora';
Start Cloning using RMAN:
Go To Primary Type RMAN You should get RMAN prompt
RMAN> connect target sys@mfinop
Connected message should come
RMAN>connect auxiliary sys@mfinos
connected to db in nomount mode.
Now execute the RMAN script.
RMAN>@/home/oracle/rman.rman
The content of this script is as follows:
Verify The RMAN Output: It should complete without any error.
Creating a trigger and Service for FSFO implementation:
On Primary:
SQL> conn sys as sysdba
Enter password:
Connected.
SQL> exec DBMS_SERVICE.CREATE_SERVICE ( service_name => 'fsfo',network_name => 'fsfo', failover_method => 'BASIC',failover_type =>'SELECT',failover_retries => 180,failover_delay => 1);
PL/SQL procedure successfully completed.
SQL> CREATE OR REPLACE TRIGGER manage_dgservice
2 after startup on database
3 DECLARE
4 role VARCHAR(30);
5 BEGIN
6 SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
7 IF role = 'PRIMARY' THEN
8 DBMS_SERVICE.START_SERVICE('fsfo');
9 END IF;
10 END;
11 /
Trigger created.
Verification on Standby Machine
Login with hr user on primary and create some table followed by insert few values. Check on Secondary(physical Standby) for the same. You may need to do alter system switch logfile on primary.
Now you have active standby database ready which applies redo in background and database is in read only mode for reporting purposes.
Few commands for standby verification:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL>SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG WHERE APPLIED='NO';
Then, open the database as read only:
SQL> alter database open read only;
Up until this point, the process is identical to that in pre-11g versions. Now, the 11g feature shows its advantage: While the standby database is open in read-only mode, you can resume the managed recovery process.
Open database with real time apply: If you want to enable real-time apply of redo, use this:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.
SQL> alter database recover managed standby database disconnect;
SELECT MAX(SEQUENCE#), THREAD# FROM V$ARCHIVED_LOG GROUP BY THREAD#;
Archive log gaps can be monitored by examining the low and high sequence numbers in
the V$ARCHIVE_GAP view, as shown here:
SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;
By reviewing the THREAD# column, you can detect missing sequences at the Real Application Clusters (RAC) instance level.
Verifying That the Standby Has Received All Redo
If you are running in a zero data loss mode (Maximum Availability or Maximum Protection), you can ensure that the target of your switchover is synchronized by examining the V$ARCHIVE_DEST_STATUS view on the primary database:
Data Guard Implementation for FSFO:
Starting the Observer in the backgroundOne question that I get asked often is how to start the observer for Fast-Start Failover in the background.
Many customers use a remote terminal emulation to manage their Data Guard configuration, so it would be a problem if it would be required to keep the window open on which they started the dgmgrl-shell for the observer. This is also not very well documented in our – apart from that very helpful – Online Documentation. On the Linux command line, it works like this:
nohup dgmgrl -silent sys/oracle@prima "start observer" &
This gives you a text file on your current directory called nohup.out on which you can do a tail -f later on, if you would like to see the actions of the observer. The Data Guard Observer is kind of quiet, it waits with messages until there is actually something to do. You can verify its presence with dgmgrl from the primary site with the command
DGMGRL> show configuration verboseConfiguration Name: myconf Enabled: YES Protection Mode: MaxAvailability Fast-Start Failover: ENABLED Databases: prima - Primary database physt - Physical standby database - Fast-Start Failover targetFast-Start Failover Threshold: 30 seconds Observer: uhesseCurrent status for "myconf":SUCCESS
Alternatively, you can query v$database like this:
SQL> select FS_FAILOVER_STATUS,FS_FAILOVER_OBSERVER_PRESENT,FS_FAILOVER_OBSERVER_HOST from v$database;Or you can create a script like following :
#!/bin/ksh
# startobserver
export ORACLE_BASE=/u01/app/oracle/
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1/ ---check for proper client home
export PATH=$ORACLE_HOME/bin:$PATH
dgmgrl << eof
connect sys/password@primary
START OBSERVER;
eof
—————- script end on previous line ——————–
$nohup ./startobserver &
Set the following parameter for DG implementation
Enable database broker on primary databaseThe broker configuration files are automatically created when the broker is started using ALTER SYSTEM SET DG_BROKER_START=TRUE.
SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;System altered.SQL> show parameters dg_brokerNAME TYPE VALUE------------------------------------ ----------- ------------------------------dg_broker_config_file1 string C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DR1SATI.DATdg_broker_config_file2 string C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DR2SATI.DATdg_broker_start boolean TRUEEnable database broker on standby databaseSQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;System altered.SQL> show parameters dg_brokerNAME TYPE VALUE------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DR1SATISTD.DATdg_broker_config_file2 string C:\ORACLE\PRODUCT\10.2.0\DB_1\DATABASE\DR2SATISTD.DATdg_broker_start boolean TRUE
Quicky: alter system set dg_broker_start=true scope=both;----do this on both primary and secondary
Connect to Observer machine and do following:
Make sure you copy the listener and tnsnames.ora file on observer machine in $ORACLE_HOME/network/admin folder. It is assumed that you have Oracle 11g r2 client software with administrator option already installed.
DGMGRL> connect sys@mfinop
Password:
Connected.
DGMGRL> create configuration fsfodg as PRIMARY DATABASE IS MFINOP CONNECT IDENTIFIER IS MFINOP;
Configuration "fsfodg" created with primary database "mfinop"
DGMGRL> ADD DATABASE MFINOS AS CONNECT IDENTIFIER IS MFINOS MAINTAINED AS PHYSICAL;
Database "mfinos" added
DGMGRL> show configuration;
Configuration - fsfodg
Protection Mode: MaxPerformance
Databases:
mfinop - Primary database
mfinos - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
Set the “LogXptMode” Property to SYNCDGMGRL> EDIT DATABASE MFINOP SET PROPERTY 'LogXptMode'='SYNC';Property "LogXptMode" updatedDGMGRL> EDIT DATABASE MFINOS SET PROPERTY 'LogXptMode'='SYNC';Property "LogXptMode" updatedSet the “FastStartFailoverTarget” Property for Both the Primary and Physical DatabasesDGMGRL> EDIT DATABASE MFINOP SET PROPERTY FastStartFailoverTarget='MFINOS';Property "faststartfailovertarget" updatedDGMGRL> EDIT DATABASE MFINOS SET PROPERTY FastStartFailoverTarget='MFINOP';Property "faststartfailovertarget" updatedChange the Protection Mode to Maximum AvailabilityDGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;Succeeded.
Enable Fast Start FailoverDGMGRL> show configuration;ConfigurationNamZ: fsfodgEnabled: YESProtection ModZ: MaxAvailabilityFast-Start Failover: DISABLED
Databases:SATI - Primary databaseSATISTD - Physical standby databaseCurrent status for "fsfodg":SUCCESSDGMGRL> ENABLE FAST_START FAILOVER;Enabled.DGMGRL> show configuration;ConfigurationNamZ: fsfodgEnabled: YESProtection ModZ: MaxAvailabilityFast-Start Failover: ENABLEDDatabases:SATI - Primary databaseSATISTD - Physical standby database- Fast-Start Failover targetCurrent status for "fsfodg":
[oracle@OTRS ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.1.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@mfinop
Password:
Connected.
DGMGRL> show database mfinop
Database - mfinop
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
mfinop
Database Status:
SUCCESS
DGMGRL> show database mfinos
Database - mfinos
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds
Apply Lag: 0 seconds
Real Time Query: ON
Instance(s):
mfinos
Database Status:
SUCCESS
DGMGRL> EDIT DATABASE MFINOP SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE MFINOS SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE MFINOP SET PROPERTY FastStartFailoverTarget='MFINOS'
> ;
Property "faststartfailovertarget" updated
DGMGRL> EDIT DATABASE MFINOS SET PROPERTY FastStartFailoverTarget='MFINOP';
Property "faststartfailovertarget" updated
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxPerformance
Databases:
mfinop - Primary database
mfinos - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinop - Primary database
mfinos - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> enable fast_start failover;
Enabled.
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinop - Primary database
mfinos - (*) Physical standby database
Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS
DGMGRL> show database verbose mfinop
Database - mfinop
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
mfinop
Properties:
DGConnectIdentifier = 'mfinop'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '4'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = ''
LogFileNameConvert = ''
FastStartFailoverTarget = 'mfinos'
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'pyro.group.com'
SidName = 'mfinop'
StaticConnectIdentifier = '(DESCRIPTION=(address=(host=172.22.25.162 )(port=1521)(protocol=tcp))(CONNECT_DATA=(SERVICE_NAME=mfinop_DGMGRL)(INSTANCE_ NAME=mfinop)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/u01/app/oracle/flash/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = 'log_%s_%t_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
DGMGRL> show database mfinos
Database - mfinos
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds
Apply Lag: 0 seconds
Real Time Query: ON
Instance(s):
mfinos
Database Status:
SUCCESS
DGMGRL> show database verbose mfinos
Database - mfinos
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds
Apply Lag: 0 seconds
Real Time Query: ON
Instance(s):
mfinos
Properties:
DGConnectIdentifier = 'mfinos'
ObserverConnectIdentifier = ''
LogXptMode = 'SYNC'
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '4'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '/MFINOP/, /MFINOS/'
LogFileNameConvert = '/MFINOP/, /MFINOS/'
FastStartFailoverTarget = 'mfinop'
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'inroamas1'
SidName = 'mfinos'
StaticConnectIdentifier = '(DESCRIPTION=(address=(host=172.22.0.74)( port=1521)(protocol=tcp))(CONNECT_DATA=(SERVICE_NAME=mfinos_DGMGRL)
(INSTANCE_NA ME=mfinos)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/u01/app/oracle/flash/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = 'log_%s_%t_%r.arc'
TopWaitEvents = '(monitor)'
Database Status:
SUCCESS
On Primary/Secondary Automate database startup and shutdown: Place the file into etc/init.d/.
1. Use the chmod command to set the privileges to 750.chmod 750 /etc/init.d/dbora
2. Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.
chkconfig --add dboraThe relevant instances should now startup/shutdown automatically at system startup/shutdown.
Summary For Broker Setup
Commands Description
dgmgrl sys/<passwd>@mfinop Connect to the broker command line utility dgmgrl
create configuration fsfodg as primary database is MFINOP connect identifier is MFINOP;
Create Dataguard configuration form dgmngrl
add database MFINOS as connect identifier is MFINOS maintained as physical;
Add database to the broker configuration
show configuration; show broker configuration and status
show database verbose MFINOS; Show broker database configuration
show instance verbose MFINOS; Show broker instance configuration
enable configuration; Enable broker configuration
enable database MFINOS; Enable database in broker Configuration
edit database MFINOP set property'logxptmode'='sync';
Set database property logxptmode to sync on broker, to enable FSFO
EDIT DATABASE MFINOS SET PROPERTY 'LogXptMode'='SYNC';
Set database property logxptmode to sync on broker, to enable FSFO
EDIT DATABASE MFINOP SET PROPERTY FastStartFailoverTarget='MFINOS';
Set FastStartFailover Target for DB
EDIT DATABASE MFINOS SET PROPERTY FastStartFailoverTarget='MFINOP';
Set FastStartFailover Target for DB
edit configuration set protection mode as maxavailability;
Change configuration protection mode to max availability, to enable FSFO
enable fast_start failover; Enable FSFO
select db_unique_name,database_role, open_mode,fs_failover_status, fs_failover_current_targetfrom v$database;
Check FSFO status on both Primary and Standby Databases
switchover to MFINOS; From within DGMGRL start switchover
------------------------------------
Its really necessary to have dataguard instances started upon reboot of machine but the problem is that how system will decide which one is primary and which one is standby.
Oracle does not have any solution for so far.
Here is the procedure to have DG instances started across reboot automatically.
First we need to enable the auto start for both instance like we do for standalone database.
Create script called /etc/init.d/dbora with following contents.
#! /bin/bash # # oracle Start/Stop the Databases…
# # chkconfig: 345 99 10 # description: DG auto start # # processname: oracle # config: /etc/oratab # pidfile: /var/run/oracle.pid
# Source function library. . /etc/init.d/functions
RETVAL=0 ORA_OWNER="oracle" ORA_HOME="/u01/app/oracle/product/10.2.0/db_1/"
# See how we were called.
prog="oracle"
start() { echo -n $"Starting $prog: " su – $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" su – $ORA_OWNER -c "$ORA_HOME/bin/dbstart" RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dbora
return $RETVAL }
stop() { echo -n $"Stopping $prog: " su – $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" su – $ORA_OWNER -c "$ORA_HOME/bin/dbshut"
}
restart() { stop start }
case "$1" in start) start ;; stop) stop ;; restart)
restart ;; *) echo $"Usage: $0 {start|stop|restart}" exit 1 esac
exit $?
chmod 755 /etc/init.d/dbora ( on both machine ) chkconfig –add dbora ( on both machine ) Modify /etc/oratab file for both instance to Y at the end.
For example :
chicago:/u01/app/oracle/product/10.2.0/db_1:Y ( Primary DB )
boston:/u01/app/oracle/product/10.2.0/db_1:Y ( Standby DB )
Login to Primary DB and make sure its in sync with Standby DB
Create trigger on primary DB which will be automatically propagated on standby database.
CREATE OR REPLACE TRIGGER SYS.DB_ROLE AFTER STARTUP ON DATABASE DECLARE CTL varchar(10); BEGIN SELECT CONTROLFILE_TYPE INTO CTL FROM V$DATABASE; IF CTL = ‘STANDBY’ THEN execute immediate ’shutdown immediate’; execute immediate ’startup mount’; execute immediate ‘alter database recover managed standby database using current logfile disconnect from session’; END IF ; END DB_ROLE;
Reboot both node and you will see that your standby db will started in Read Only mode first then it will bounced and restarted in Mount mode with Managed Recovery on.
------------------------------------------
Troubleshooting Dataguard
[oracle@OTRS ~]$ . .bash_profile1
[oracle@OTRS ~]$ env | grep ORA
ORACLE_HOSTNAME=OTRS
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_2
[oracle@OTRS ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.1.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@inraoms
Password:
Unable to connect to database
ORA-12154: TNS:could not resolve the connect identifier specified
Failed.
DGMGRL> exit
[oracle@OTRS ~]$ tnsping fsfo
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 22-JAN-2010 15:48 :43
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2.0/db_2/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 172.22.25.162)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 172.22.0 .74)(PORT = 1521)) (LOAD_BALANCE = yes)) (CONNECT_DATA= (SERVICE_NAME = fsfo)))
OK (0 msec)
[oracle@OTRS ~]$ dgmgrl
DGMGRL for Linux: Version 11.2.0.1.0 - Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys@fsfo
Password:
Connected.
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinos - Primary database
Warning: ORA-16817: unsynchronized fast-start failover configuration
mfinop - (*) Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
DGMGRL> stop observer
Error: ORA-16636: fast-start failover target standby in error state, cannot stop observer
Failed.
DGMGRL> show database mfinos
Database - mfinos
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
mfinos
Database Warning(s):
ORA-16817: unsynchronized fast-start failover configuration
Database Status:
WARNING
DGMGRL> show database mfinop
Database - mfinop
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: (unknown)
Apply Lag: (unknown)
Real Time Query: OFF
Instance(s):
mfinop
Database Status:
ORA-16661: the standby database needs to be reinstated
DGMGRL> show database mfinop
Database - mfinop
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: (unknown)
Apply Lag: (unknown)
Real Time Query: OFF
Instance(s):
mfinop
Database Status:
ORA-16661: the standby database needs to be reinstated
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinos - Primary database
Warning: ORA-16817: unsynchronized fast-start failover configuration
mfinop - (*) Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
DGMGRL> reinstate database mfinop
Reinstating database "mfinop", please wait...
Operation requires shutdown of instance "mfinop" on database "mfinop"
Shutting down instance "mfinop"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "mfinop" on database "mfinop"
Starting instance "mfinop"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "mfinop" ...
Reinstatement of database "mfinop" succeeded
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinos - Primary database
Warning: ORA-16817: unsynchronized fast-start failover configuration
mfinop - (*) Physical standby database
Warning: ORA-16817: unsynchronized fast-start failover configuration
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinos - Primary database
Warning: ORA-16817: unsynchronized fast-start failover configuration
mfinop - (*) Physical standby database
Warning: ORA-16817: unsynchronized fast-start failover configuration
Fast-Start Failover: ENABLED
Configuration Status:
WARNING
DGMGRL> show database mfinop
Database - mfinop
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: (unknown)
Apply Lag: 9 hours 37 minutes 37 seconds
Real Time Query: ON
Instance(s):
mfinop
Database Warning(s):
ORA-16817: unsynchronized fast-start failover configuration
Database Status:
WARNING
DGMGRL> show database mfinos
Database - mfinos
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
mfinos
Database Warning(s):
ORA-16817: unsynchronized fast-start failover configuration
Database Status:
WARNING
DGMGRL> show configuration
Configuration - fsfodg
Protection Mode: MaxAvailability
Databases:
mfinos - Primary database
mfinop - (*) Physical standby database
Fast-Start Failover: ENABLED
Configuration Status:
SUCCESS
DGMGRL> DGMGRL> [oracle@OTRS ~]$
----------------------------------------------------------------------
RMAN Implementation:
CREATE TABLESPACE rcat_111 DATAFILE '/u02/oradata/rcat/rcat_111.dbf' SIZE 32M REUSE AUTOEXTEND ON MAXSIZE 2024M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
[oracle@inroamas1 ~]$ sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Sat Jan 23 09:45:14 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> CREATE TABLESPACE rcat_111
DATAFILE '/u02/oradata/rcat/rcat_111.dbf'
SIZE 32M REUSE
AUTOEXTEND ON
MAXSIZE 2024M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
2 3 4 5 6 7
Tablespace created.
SQL> CREATE USER rcat
IDENTIFIED BY rcat
DEFAULT TABLESPACE rcat_111
QUOTA UNLIMITED ON rcat_111;
2 3 4
User created.
SQL> GRANT RECOVERY_CATALOG_OWNER TO rcat;
Grant succeeded.
SQL> GRANT RECOVERY_CATALOG_OWNER TO rcat;
Grant succeeded.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@inroamas1 ~]$ rman catalog rcat/rcat
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 23 09:47:49 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to recovery catalog database
RMAN> CREATE CATALOG;
recovery catalog created
[oracle@pyro ~]$ rman target / catalog rcat/rcat
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 23 09:47:38 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: MFINOP (DBID=736742729)
connected to recovery catalog database
[oracle@inroamas1 ~]$ rman target / catalog rcat/rcat
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 23 10:26:56 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: MFINOP (DBID=736742729)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
[oracle@inroamas1 ~]$ rman target / catalog rcat/rcat
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 23 10:31:23 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: MFINOP (DBID=736742729)
connected to recovery catalog database
RMAN> @/home/oracle/rmancat.rman
RMAN> RUN {
2> #####
3> # Set the database's point-in-time retention policy to 48 hours
4> #####
5> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
6> #####
7> # Enable deletion of archived redo logs only after they have been
8> # successfully applied to all standby databases
9> #####
10> CONFIGURE ARCHIVELOG DELETION POLICY
11> TO APPLIED ON ALL STANDBY;
12> #####
13> # Configure specific connection strings for both the primary and
14> # standby databases
15> #####
16> CONFIGURE DB_UNIQUE_NAME mfinop CONNECT IDENTIFIER 'mfinop';
17> CONFIGURE DB_UNIQUE_NAME mfinos CONNECT IDENTIFIER 'mfinos';
18> }
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'mfinop' CONNECT IDENTIFIER 'mfinop';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
new RMAN configuration parameters:
CONFIGURE DB_UNIQUE_NAME 'mfinos' CONNECT IDENTIFIER 'mfinos';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
RMAN>
RMAN> **end-of-file**
[oracle@pyro ~]$ rman target / catalog rcat/rcat
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 23 10:31:55 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: MFINOP (DBID=736742729)
connected to recovery catalog database
RMAN> @/home/oracle/rmancatp.rman
RMAN> RUN {
2> #####
3> # Activate automatic backup of the standby database's control file whenever a change
4> # to the database's structure is detected
5> #####
6> CONFIGURE CONTROLFILE AUTOBACKUP ON;
7> #####
8> # Activate backup optimization to prevent taking a backup of a datafile for which
9> # a backup is unnecessary (i.e. because nothing has changed in that datafile since
10> # the last backup was taken)
11> #####
12> CONFIGURE BACKUP OPTIMIZATION ON;
13> #####
14> # Specify the archived log file deletion policy to indicate when archived redo log files are deleted
15> #####
16> CONFIGURE ARCHIVELOG DELETION POLICY
17> TO BACKED UP 1 TIMES TO DEVICE TYPE DISK;
18> }
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters are successfully stored
RMAN>
RMAN> **end-of-file**
RMAN> exit
Recovery Manager complete.
Starting recover at 23-JAN-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=154 device type=DISK
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
no copy of datafile 5 found to recover
no copy of datafile 6 found to recover
Finished recover at 23-JAN-10
Starting backup at 23-JAN-10
using channel ORA_DISK_1
no parent backup or copy of datafile 1 found
no parent backup or copy of datafile 2 found
no parent backup or copy of datafile 5 found
no parent backup or copy of datafile 3 found
no parent backup or copy of datafile 6 found
no parent backup or copy of datafile 4 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/MFINOS/datafile/o1_mf_system_5nrkhyy6_.dbf
output file name=/u01/app/oracle/flash_recovery_area/MFINOS/datafile/o1_mf_system_5oo2nonv_.dbf tag=INCRUPD RECID=7 STAMP=709038352
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/MFINOS/datafile/o1_mf_sysaux_5nrkhz2b_.dbf
output file name=/u01/app/oracle/flash_recovery_area/MFINOS/datafile/o1_mf_sysaux_5oo2osv2_.dbf tag=INCRUPD RECID=8 STAMP=709038384
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/MFINOS/datafile/o1_mf_example_5nrknj9n_.dbf
output file name=/u01/app/oracle/flash_recovery_area/MFINOS/datafile/o1_mf_example_5oo2pwwk_.dbf tag=INCRUPD RECID=9 STAMP=709038393
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/MFINOS/datafile/o1_mf_undotbs1_5nrkhz37_.dbf
output file name=/u01/app/oracle/flash_recovery_area/MFINOS/datafile/o1_mf_undotbs1_5oo2q439_.dbf tag=INCRUPD RECID=10 STAMP=709038397
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u02/oradata/rcat/rcat_111.dbf
output file name=/u01/app/oracle/flash_recovery_area/MFINOS/datafile/o1_mf_rcat_111_5oo2q78d_.dbf tag=INCRUPD RECID=11 STAMP=709038400
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/MFINOS/datafile/o1_mf_users_5nrkhz4m_.dbf
output file name=/u01/app/oracle/flash_recovery_area/MFINOS/datafile/o1_mf_users_5oo2qbcs_.dbf tag=INCRUPD RECID=12 STAMP=709038402
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 23-JAN-10
channel ORA_DISK_1: finished piece 1 at 23-JAN-10
piece handle=/u01/app/oracle/flash_recovery_area/MFINOS/backupset/2010_01_23/o1_mf_ncsn1_INCRUPD_5oo2qdqk_.bkp tag=INCRUPD comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 23-JAN-10
Starting backup at 23-JAN-10
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=5 RECID=1 STAMP=708109024
input archived log thread=1 sequence=6 RECID=2 STAMP=708109024
input archived log thread=1 sequence=7 RECID=3 STAMP=708109089
input archived log thread=1 sequence=8 RECID=4 STAMP=708109094
input archived log thread=1 sequence=9 RECID=5 STAMP=708109238
input archived log thread=1 sequence=10 RECID=7 STAMP=708111108
input archived log thread=1 sequence=11 RECID=6 STAMP=708111107
input archived log thread=1 sequence=12 RECID=8 STAMP=708111108
input archived log thread=1 sequence=13 RECID=9 STAMP=708111123
input archived log thread=1 sequence=14 RECID=10 STAMP=708111595
input archived log thread=1 sequence=15 RECID=11 STAMP=708111616
input archived log thread=1 sequence=16 RECID=12 STAMP=708111620
input archived log thread=1 sequence=17 RECID=13 STAMP=708111630
input archived log thread=1 sequence=18 RECID=14 STAMP=708111632
input archived log thread=1 sequence=19 RECID=15 STAMP=708111640
input archived log thread=1 sequence=20 RECID=16 STAMP=708111673
input archived log thread=1 sequence=21 RECID=22 STAMP=708111959
input archived log thread=1 sequence=22 RECID=23 STAMP=708111967
input archived log thread=1 sequence=23 RECID=25 STAMP=708111974
input archived log thread=1 sequence=24 RECID=27 STAMP=708112004
input archived log thread=1 sequence=25 RECID=29 STAMP=708112005
input archived log thread=1 sequence=26 RECID=28 STAMP=708112004
input archived log thread=1 sequence=27 RECID=30 STAMP=708112007
input archived log thread=1 sequence=28 RECID=31 STAMP=708112029
input archived log thread=1 sequence=29 RECID=32 STAMP=708113759
input archived log thread=1 sequence=30 RECID=33 STAMP=708113842
input archived log thread=1 sequence=31 RECID=34 STAMP=708114128
input archived log thread=1 sequence=32 RECID=35 STAMP=708114171
input archived log thread=1 sequence=33 RECID=36 STAMP=708114173
input archived log thread=1 sequence=34 RECID=37 STAMP=708114396
input archived log thread=1 sequence=35 RECID=38 STAMP=708117480
channel ORA_DISK_1: starting piece 1 at 23-JAN-10
channel ORA_DISK_1: finished piece 1 at 23-JAN-10
piece handle=/u01/app/oracle/flash_recovery_area/MFINOS/backupset/2010_01_23/o1_mf_annnn_TAG20100123T110653_5oo2qq2w_.bkp tag=TAG20100123T110653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=39 STAMP=708127281
input archived log thread=1 sequence=2 RECID=40 STAMP=708151379
input archived log thread=1 sequence=3 RECID=41 STAMP=708170090
input archived log thread=1 sequence=4 RECID=42 STAMP=708170119
input archived log thread=1 sequence=5 RECID=45 STAMP=708170130
input archived log thread=1 sequence=6 RECID=50 STAMP=708184812
input archived log thread=1 sequence=7 RECID=52 STAMP=708185478
input archived log thread=1 sequence=8 RECID=54 STAMP=708188244
input archived log thread=1 sequence=9 RECID=57 STAMP=708192985
input archived log thread=1 sequence=10 RECID=59 STAMP=708197248
input archived log thread=1 sequence=11 RECID=60 STAMP=708215218
input archived log thread=1 sequence=12 RECID=63 STAMP=708231733
input archived log thread=1 sequence=13 RECID=65 STAMP=708265841
input archived log thread=1 sequence=14 RECID=67 STAMP=708300013
input archived log thread=1 sequence=15 RECID=69 STAMP=708320132
input archived log thread=1 sequence=16 RECID=71 STAMP=708342768
input archived log thread=1 sequence=17 RECID=72 STAMP=708343670
input archived log thread=1 sequence=18 RECID=74 STAMP=708346018
input archived log thread=1 sequence=19 RECID=77 STAMP=708367687
input archived log thread=1 sequence=20 RECID=79 STAMP=708386463
input archived log thread=1 sequence=21 RECID=81 STAMP=708406544
input archived log thread=1 sequence=22 RECID=83 STAMP=708423186
input archived log thread=1 sequence=23 RECID=85 STAMP=708444574
input archived log thread=1 sequence=24 RECID=87 STAMP=708467788
input archived log thread=1 sequence=25 RECID=89 STAMP=708491183
input archived log thread=1 sequence=26 RECID=91 STAMP=708507049
input archived log thread=1 sequence=27 RECID=93 STAMP=708531013
input archived log thread=1 sequence=28 RECID=95 STAMP=708550212
input archived log thread=1 sequence=29 RECID=97 STAMP=708573835
input archived log thread=1 sequence=30 RECID=98 STAMP=708607741
input archived log thread=1 sequence=31 RECID=99 STAMP=708640803
channel ORA_DISK_1: starting piece 1 at 23-JAN-10
channel ORA_DISK_1: finished piece 1 at 23-JAN-10
piece handle=/u01/app/oracle/flash_recovery_area/MFINOS/backupset/2010_01_23/o1_mf_annnn_TAG20100123T110653_5oo2qt96_.bkp tag=TAG20100123T110653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=32 RECID=100 STAMP=708650412
input archived log thread=1 sequence=33 RECID=101 STAMP=708683427
input archived log thread=1 sequence=34 RECID=102 STAMP=708697856
input archived log thread=1 sequence=35 RECID=109 STAMP=708712892
input archived log thread=1 sequence=36 RECID=110 STAMP=708712909
input archived log thread=1 sequence=37 RECID=112 STAMP=708712915
input archived log thread=1 sequence=38 RECID=115 STAMP=708712963
input archived log thread=1 sequence=39 RECID=116 STAMP=708712963
input archived log thread=1 sequence=40 RECID=114 STAMP=708712963
input archived log thread=1 sequence=41 RECID=117 STAMP=708712970
input archived log thread=1 sequence=42 RECID=118 STAMP=708712975
input archived log thread=1 sequence=43 RECID=119 STAMP=708732234
input archived log thread=1 sequence=44 RECID=120 STAMP=708750610
input archived log thread=1 sequence=45 RECID=121 STAMP=708783072
input archived log thread=1 sequence=46 RECID=122 STAMP=708815508
input archived log thread=1 sequence=47 RECID=123 STAMP=708822123
input archived log thread=1 sequence=48 RECID=124 STAMP=708849202
input archived log thread=1 sequence=49 RECID=125 STAMP=708867684
input archived log thread=1 sequence=50 RECID=126 STAMP=708867808
input archived log thread=1 sequence=51 RECID=127 STAMP=708871217
input archived log thread=1 sequence=52 RECID=128 STAMP=708871217
input archived log thread=1 sequence=53 RECID=129 STAMP=708871225
input archived log thread=1 sequence=54 RECID=130 STAMP=708871249
input archived log thread=1 sequence=55 RECID=131 STAMP=708871264
input archived log thread=1 sequence=56 RECID=134 STAMP=708871274
input archived log thread=1 sequence=57 RECID=137 STAMP=708871284
input archived log thread=1 sequence=58 RECID=139 STAMP=708871288
input archived log thread=1 sequence=59 RECID=141 STAMP=708872629
channel ORA_DISK_1: starting piece 1 at 23-JAN-10
channel ORA_DISK_1: finished piece 1 at 23-JAN-10
piece handle=/u01/app/oracle/flash_recovery_area/MFINOS/backupset/2010_01_23/o1_mf_annnn_TAG20100123T110653_5oo2skrd_.bkp tag=TAG20100123T110653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=142 STAMP=708872629
input archived log thread=1 sequence=2 RECID=140 STAMP=708872628
input archived log thread=1 sequence=3 RECID=143 STAMP=708872634
input archived log thread=1 sequence=4 RECID=144 STAMP=708872639
input archived log thread=1 sequence=5 RECID=145 STAMP=708905008
input archived log thread=1 sequence=6 RECID=146 STAMP=708905123
input archived log thread=1 sequence=7 RECID=147 STAMP=708932519
input archived log thread=1 sequence=8 RECID=148 STAMP=708939222
channel ORA_DISK_1: starting piece 1 at 23-JAN-10
channel ORA_DISK_1: finished piece 1 at 23-JAN-10
piece handle=/u01/app/oracle/flash_recovery_area/MFINOS/backupset/2010_01_23/o1_mf_annnn_TAG20100123T110653_5oo2tby9_.bkp tag=TAG20100123T110653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=1 RECID=149 STAMP=708973757
input archived log thread=1 sequence=2 RECID=150 STAMP=708973789
input archived log thread=1 sequence=3 RECID=153 STAMP=708973811
input archived log thread=1 sequence=4 RECID=157 STAMP=708973853
input archived log thread=1 sequence=5 RECID=159 STAMP=708991272
input archived log thread=1 sequence=6 RECID=161 STAMP=709014646
input archived log thread=1 sequence=7 RECID=163 STAMP=709020030
input archived log thread=1 sequence=8 RECID=164 STAMP=709029402
input archived log thread=1 sequence=9 RECID=166 STAMP=709029728
input archived log thread=1 sequence=10 RECID=169 STAMP=709029731
input archived log thread=1 sequence=11 RECID=171 STAMP=709034740
input archived log thread=1 sequence=12 RECID=172 STAMP=709037962
input archived log thread=1 sequence=13 RECID=174 STAMP=709037989
input archived log thread=1 sequence=14 RECID=177 STAMP=709037996
input archived log thread=1 sequence=15 RECID=179 STAMP=709038412
channel ORA_DISK_1: starting piece 1 at 23-JAN-10
channel ORA_DISK_1: finished piece 1 at 23-JAN-10
piece handle=/u01/app/oracle/flash_recovery_area/MFINOS/backupset/2010_01_23/o1_mf_annnn_TAG20100123T110653_5oo2tt7j_.bkp tag=TAG20100123T110653 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 23-JAN-10
The conversion from physical standby to snapshot standby database can be done through the command
Document Display https://support.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx...
ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;1) If not already configured , configure flash recovery area as given belowa) Set the size for recovery area.Alter system set db_recovery_file_dest_size=<size>b) Set Flash recovery area.Alter system set db_recovery_file_dest=<path>2) Bring the physical standby database to mount stage.3) Stop managed recovery if it is active.4) Convert physical standby database to snapshot standby database.ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;The database is dismounted during conversion and must be restarted.Once the database is restarted any transaction can be executed .SQL> select open_mode,database_role from v$database;OPEN_MODE DATABASE_ROLE---------- ----------------READ WRITE SNAPSHOT STANDBY
To convert back to physical standby database
1. Shutdown the snapshot standby database.2. Bring the database to the mount stage.3. Issue the commandALTER DATABASE CONVERT TO PHYSICAL STANDBY;4. Shutdown the database and mount it .SQL> select open_mode,database_role from v$database;OPEN_MODE DATABASE_ROLE---------- ----------------MOUNTED PHYSICAL STANDBY
6. Start the media recovery process.
=====================================================================
Creating statspack for primary and standby
SQL> @?/rdbms/admin/spcreate
Choose the PERFSTAT user's password
-----------------------------------
Not specifying a password will result in the installation FAILING
Enter value for perfstat_password: notallowed
notallowed
Choose the Default tablespace for the PERFSTAT user
---------------------------------------------------
Below is the list of online tablespaces in this database which can
store user data. Specifying the SYSTEM tablespace for the user's
default tablespace will result in the installation FAILING, as
using SYSTEM for performance data is not supported.
Choose the PERFSTAT users's default tablespace. This is the tablespace
in which the STATSPACK tables and indexes will be created.
TABLESPACE_NAME CONTENTS STATSPACK DEFAULT TABLESPACE
------------------------------ --------- ----------------------------
EXAMPLE PERMANENT
SYSAUX PERMANENT *
USERS PERMANENT
Pressing <return> will result in STATSPACK's recommended default
tablespace (identified by *) being used.
Enter value for default_tablespace:
Using tablespace SYSAUX as PERFSTAT default tablespace.
Choose the Temporary tablespace for the PERFSTAT user
-----------------------------------------------------
Below is the list of online tablespaces in this database which can
store temporary data (e.g. for sort workareas). Specifying the SYSTEM
tablespace for the user's temporary tablespace will result in the
installation FAILING, as using SYSTEM for workareas is not supported.
Choose the PERFSTAT user's Temporary tablespace.
TABLESPACE_NAME CONTENTS DB DEFAULT TEMP TABLESPACE
------------------------------ --------- --------------------------
TEMP TEMPORARY *
Choose the PERFSTAT user's Temporary tablespace.
TABLESPACE_NAME CONTENTS DB DEFAULT TEMP TABLESPACE
------------------------------ --------- --------------------------
TEMP TEMPORARY *
Pressing <return> will result in the database's default Temporary
tablespace (identified by *) being used.
Enter value for temporary_tablespace:
Using tablespace TEMP as PERFSTAT temporary tablespace.
... Creating PERFSTAT user
... Installing required packages
... Creating views
... Granting privileges
NOTE:
SPCUSR complete. Please check spcusr.lis for any errors.
SQL>
SQL> --
SQL> -- Build the tables and synonyms
SQL> connect perfstat/&&perfstat_password
Connected.
SQL> @@spctab
SQL> Rem
SQL> Rem $Header: rdbms/admin/spctab.sql /st_rdbms_11.2.0/1 2010/08/13 10:06:01 kchou Exp $
SQL> Rem
SQL> Rem spctab.sql
SQL> Rem
SQL> Rem Copyright (c) 1999, 2010, Oracle and/or its affiliates.
SQL> Rem All rights reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem spctab.sql
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem SQL*PLUS command file to create tables to hold
SQL> Rem start and end "snapshot" statistical information
SQL> Rem
SQL> Rem NOTES
SQL> Rem Should be run as STATSPACK user, PERFSTAT
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem kchou 08/11/10 - Bug#9800868 - Add Missing Idle Events for
SQL> Rem 11.2.0.2for Statspack & Standby Statspack
SQL> Rem kchou 08/11/10 - Bug#9800868 - Add missing idle events to 11.2.0.2
SQL> Rem cgervasi 05/13/09 - add idle event: cell worker idle
SQL> Rem cgervasi 04/02/09 - bug8395154: missing idle events
SQL> Rem rhlee 02/22/08 -
> Rem cdgreen 03/14/07 - 11 F2
SQL> Rem shsong 06/14/07 - Add idle events
SQL> Rem cdgreen 02/28/07 - 5908354
SQL> Rem cdgreen 04/26/06 - 11 F1
SQL> Rem cdgreen 06/26/06 - Increase column length
SQL> Rem cdgreen 05/10/06 - 5215982
SQL> Rem cdgreen 05/24/05 - 4246955
SQL> Rem cdgreen 04/18/05 - 4228432
SQL> Rem cdgreen 03/08/05 - 10gR2 misc
SQL> Rem vbarrier 02/18/05 - 4081984
SQL> Rem cdgreen 10/29/04 - 10gR2_sqlstats
SQL> Rem cdgreen 07/16/04 - 10gR2
SQL> Rem cdialeri 03/25/04 - 3516921
SQL> Rem vbarrier 02/12/04 - 3412853
SQL> Rem cdialeri 12/04/03 - 3290482
SQL> Rem cdialeri 11/05/03 - 3202706
SQL> Rem cdialeri 10/14/03 - 10g - streams - rvenkate
SQL> Rem cdialeri 08/05/03 - 10g F3
SQL> Rem cdialeri 02/27/03 - 10g F2: baseline, purge
SQL> Rem vbarrier 02/25/03 - 10g RAC
SQL> Rem cdialeri 11/15/02 - 10g F1
SQL> Rem cdialeri 09/27/02 - sleep4
SQL> Rem vbarrier 03/20/02 - 2143634
SQL> Rem vbarrier 03/05/02 - Segment Statistics
SQL> Rem cdialeri 02/07/02 - 2218573
SQL> Rem cdialeri 01/30/02 - 2184717
SQL> Rem cdialeri 01/11/02 - 9.2 - features 2
SQL> Rem cdialeri 11/30/01 - 9.2 - features 1
SQL> Rem cdialeri 04/22/01 - Undostat changes
SQL> Rem cdialeri 03/02/01 - 9.0
SQL> Rem cdialeri 09/12/00 - sp_1404195
SQL> Rem cdialeri 04/07/00 - 1261813
SQL> Rem cdialeri 03/20/00 - Support for purge
SQL> Rem cdialeri 02/16/00 - 1191805
SQL> Rem cdialeri 01/26/00 - 1169401
SQL> Rem cdialeri 11/01/99 - Enhance, 1059172
SQL> Rem cmlim 07/17/97 - Added STATS$SQLAREA to store top sql stmts
SQL> Rem gwood 10/16/95 - Version to run as sys without using many views
SQL> Rem cellis.uk 11/15/89 - Created
SQL> Rem
SQL>
SQL> set showmode off echo off;
If this script is automatically called from spcreate (which is
the supported method), all STATSPACK segments will be created in
the PERFSTAT user's default tablespace.
Using SYSAUX tablespace to store Statspack objects
... Creating STATS$SNAPSHOT_ID Sequence
Sequence created.
Synonym created.
... Creating STATS$... tables
Table created.
Synonym created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Index created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Synonym created.
View created.
Synonym created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.
Synonym created.
Synonym created.
NOTE:
SPCTAB complete. Please check spctab.lis for any errors.
SQL> -- Create the statistics Package
SQL> @@spcpkg
SQL> Rem
SQL> Rem $Header: spcpkg.sql 28-jan-2008.21:06:26 arogers Exp $
SQL> Rem
SQL> Rem spcpkg.sql
SQL> Rem
SQL> Rem Copyright (c) 1999, 2008, Oracle. All rights reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem spcpkg.sql
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem SQL*PLUS command file to create statistics package
SQL> Rem
SQL> Rem NOTES
SQL> Rem Must be run as the STATSPACK owner, PERFSTAT
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem arogers 01/23/08 - 6523482 - change VM_IN/OUT_BYTES id numbers
SQL> Rem cdgreen 03/14/07 - 11 F2
SQL> Rem shsong 06/14/07 - Fix BUFFER_GETS
SQL> Rem cdgreen 04/05/07 - 5691086
SQL> Rem cdgreen 03/02/07 - use _FG for v$system_event
SQL> Rem cdgreen 03/02/07 - 5913378
SQL> Rem cdgreen 05/16/06 - 11 F1
SQL> Rem cdgreen 05/10/06 - 5215982
SQL> Rem cdgreen 05/24/05 - 4246955
SQL> Rem cdgreen 04/18/05 - 4228432
SQL> Rem cdgreen 02/28/05 - 10gR2 misc
SQL> Rem vbarrier 02/18/05 - 4081984
SQL> Rem cdgreen 01/25/05 - 4143812
SQL> Rem cdgreen 10/29/04 - 10gR2_sqlstats
SQL> Rem cdgreen 10/25/04 - 3970898
SQL> Rem cdgreen 07/16/04 - 10g R2
SQL> Rem vbarrier 03/18/04 - 3517841
SQL> Rem vbarrier 02/12/04 - 3412853
SQL> Rem cdialeri 12/04/03 - 3290482
SQL> Rem cdialeri 11/05/03 - 3202706
SQL> Rem cdialeri 10/14/03 - 10g - streams - rvenkate
SQL> Rem cdialeri 08/05/03 - 10g F3
SQL> Rem cdialeri 07/31/03 - 2804307
SQL> Rem vbarrier 02/25/03 - 10g RAC
SQL> Rem cdialeri 01/28/03 - 10g F2: baseline, purge
SQL> Rem cdialeri 11/15/02 - 10g F1
SQL> Rem cdialeri 10/29/02 - 2648471
SQL> Rem cdialeri 09/11/02 - 1995145
SQL> Rem vbarrier 04/18/02 - 2271895
SQL> Rem vbarrier 03/20/02 - 2184504
SQL> Rem spommere 03/19/02 - 2274095
SQL> Rem vbarrier 03/05/02 - Segment Statistics
SQL> Rem spommere 02/14/02 - cleanup RAC stats that are no longer needed
SQL> Rem spommere 02/08/02 - 2212357
SQL> Rem cdialeri 02/07/02 - 2218573
SQL> Rem cdialeri 01/30/02 - 2184717
SQL> Rem cdialeri 01/09/02 - 9.2 - features 2
SQL> Rem cdialeri 11/30/01 - 9.2 - features 1
SQL> Rem hbergh 08/23/01 - 1940915: use substrb on sql_text
SQL> Rem cdialeri 04/26/01 - 9.0
SQL> Rem cdialeri 09/12/00 - sp_1404195
SQL> Rem cdialeri 04/07/00 - 1261813
SQL> Rem cdialeri 03/28/00 - sp_purge
SQL> Rem cdialeri 02/16/00 - 1191805
SQL> Rem cdialeri 11/01/99 - Enhance, 1059172
SQL> Rem cgervasi 06/16/98 - Remove references to wrqs
SQL> Rem cmlim 07/30/97 - Modified system events
SQL> Rem gwood.uk 02/30/94 - Modified
SQL> Rem densor.uk 03/31/93 - Modified
SQL> Rem cellis.uk 11/15/89 - Created
SQL> Rem
SQL>
SQL> set echo off;
Creating Package STATSPACK...
Package created.
No errors.
Creating Package Body STATSPACK...
Package body created.
No errors.
NOTE:
SPCPKG complete. Please check spcpkg.lis for any errors.
-------------------------------------------------------------------------------------------------------------
[oracle@prod ~]$ sqlplus
SQL*Plus: Release 11.2.0.3.0 Production on Sun May 5 22:52:36 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> @?/rdbms/admin/sbcreate
Choose the STDBYPERF user's password
-----------------------------------
Not specifying a password will result in the installation FAILING
Enter value for stdbyuser_password: notallowed
notallowed
Choose the Default tablespace for the STDBYPERF user
---------------------------------------------------
Below is the list of online tablespaces in this database which can
store user data. Specifying the SYSTEM tablespace for the user's
default tablespace will result in the installation FAILING, as
using SYSTEM for performance data is not supported.
Choose the STDBYPERF users's default tablespace. This is the tablespace
in which the STATSPACK tables and indexes will be created.
TABLESPACE_NAME CONTENTS STATSPACK DEFAULT TABLESPACE
------------------------------ --------- ----------------------------
EXAMPLE PERMANENT
SYSAUX PERMANENT *
USERS PERMANENT
Pressing <return> will result in STATSPACK's recommended default
tablespace (identified by *) being used.
Enter value for default_tablespace:
Using tablespace SYSAUX as STDBYPERF default tablespace.
Choose the Temporary tablespace for the STDBYPERF user
-----------------------------------------------------
Below is the list of online tablespaces in this database which can
store temporary data (e.g. for sort workareas). Specifying the SYSTEM
tablespace for the user's temporary tablespace will result in the
installation FAILING, as using SYSTEM for workareas is not supported.
Choose the STDBYPERF user's Temporary tablespace.
TABLESPACE_NAME CONTENTS DB DEFAULT TEMP TABLESPACE
------------------------------ --------- --------------------------
TEMP TEMPORARY *
Pressing <return> will result in the database's default Temporary
tablespace (identified by *) being used.
Enter value for temporary_tablespace:
Using tablespace TEMP as STDBYPERF temporary tablespace.
... Creating STDBYPERF user
... Installing required packages
... Granting privileges
NOTE:
SBCUSR complete. Please check sbcusr.lis for any errors.
SQL>
SQL> connect stdbyperf/&&stdbyuser_password
Connected.
SQL>
SQL> --
SQL> -- Build the tables
SQL> @@sbctab
SQL> Rem
SQL> Rem sbctab.sql
SQL> Rem
SQL> Rem Copyright (c) 1999, 2010, Oracle and/or its affiliates.
SQL> Rem All rights reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem sbctab.sql
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem SQL*PLUS command file to create tables to hold standby database
SQL> Rem start and end "snapshot" statistical information
SQL> Rem
SQL> Rem NOTES
SQL> Rem Should be run as Standby Statspack user, stdbyperf
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem kchou 08/11/10 - Bug#9800868 - Add Missing Idle Events for
SQL> Rem 11.2.0.2for Statspack & Standby Statspack
SQL> Rem kchou 08/11/10 - Bug#9800868 - Add missing idle events to 11.2.0.2
SQL> Rem shsong 01/28/10 - add stats$lock_type
SQL> Rem shsong 08/18/09 - Add db_unique_name
SQL> Rem shsong 02/02/09 - remove stats$kccfn etc
SQL> Rem shsong 07/10/08 - add stats$kccfn etc
SQL> Rem shsong 02/28/07 - Fix bug
SQL> Rem wlohwass 12/04/06 - Created, based on spctab.sql
SQL> Rem
SQL>
SQL> set showmode off echo off;
If this script is automatically called from sbcreate (which is
the supported method), all STATSPACK segments will be created in
the STDBYPERF user default tablespace.
Using SYSAUX tablespace to store Statspack objects
... Creating STATS$SNAPSHOT_ID Sequence
Sequence created.
... Creating STATS$... tables
Table created.
Table created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Index created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Synonym created.
Table created.
Synonym created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Commit complete.
View created.
NOTE:
SBCTAB complete. Please check sbctab.lis for any errors.
SQL>
SQL>
SQL> --
SQL> -- Add a standby database instance to the configuration
SQL> @@sbaddins
SQL> Rem
SQL> Rem sbaddins.sql
SQL> Rem
SQL> Rem Copyright (c) 2006, 2010, Oracle and/or its affiliates.
SQL> Rem All rights reserved.
SQL> Rem
SQL> Rem NAME
SQL> Rem sbaddins.sql - Standby Database Statistics Collection Add Instance
SQL> Rem
SQL> Rem DESCRIPTION
SQL> Rem SQL*PLUS command file which adds a standby database instance
SQL> Rem for performance data collection
SQL> Rem
SQL> Rem NOTES
SQL> Rem Must be run from standby perfstat owner, STDBYPERF
SQL> Rem
SQL> Rem MODIFIED (MM/DD/YY)
SQL> Rem shsong 01/28/10 - remove v$lock_type
SQL> Rem shsong 08/18/09 - add db_unique_name to stats$standby_config
SQL> Rem shsong 03/04/07 - fix bug
SQL> Rem wlohwass 12/04/06 - Created
SQL> Rem
SQL>
SQL> set echo off;
The following standby instances (TNS_NAME alias) have been configured
for data collection
=== END OF LIST ===
THE INSTANCE YOU ARE GOING TO ADD MUST BE ACCESSIBLE AND OPEN READ ONLY
Do you want to continue (y/n) ?
Enter value for key: y
You entered: y
Enter the TNS ALIAS that connects to the standby database instance
-----------------------------------------------------------------
Make sure the alias connects to only one instance (without load balancing).
Enter value for tns_alias: fardr
You entered: fardr
Enter the PERFSTAT user's password of the standby database
---------------------------------------------------------
Performance data will be fetched from the standby database via
database link. We will connect to user PERFSTAT.
Enter value for perfstat_password: notallowed
You entered: notallowed
... Creating database link
... Selecting database unique name
Database
------------------------------
FARDR
... Selecting instance name
Instance
------------
FARDR
... Creating package
Creating Package STATSPACK_FARDR_FARDR..
No errors.
Creating Package Body STATSPACK_FARDR_FARDR..
No errors.
NOTE:
SBCPKG complete. Please check sbcpkg.lis for any errors.
SQL>
SQL> undefine key tns_alias inst_name perfstat_password pkg_name db_unique_name
SQL> set echo off;
The following standby instances (TNS_NAME alias) have been configured
for data collection
DATABASE INSTANCE DB LINK
------------------------------ ------------ ------------------------------
PACKAGE
----------------------------------------------
FARDR FARDR STDBY_LINK_fardr
STATSPACK_FARDR_FARDR
[oracle@prod ~]$ sqlplus
SQL*Plus: Release 11.2.0.3.0 Production on Sun May 5 22:59:27 2013
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter user-name: sys as sysdba
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> connect stdbyperf/notallowed
Connected.
SQL> connect stdbyperf/notallowed@fardr
Connected.
SQL> connect stdbyperf/notallowed@prod
Connected.
SQL>
SQL> show db_name
SP2-0158: unknown SHOW option "db_name"
SQL> show parameter db_name
ORA-00942: table or view does not exist
SQL> show user
USER is "STDBYPERF"
SQL> exec STATSPACK_FARDR_FARDR.snap
PL/SQL procedure successfully completed.
-----------------------------------------------------------------------------------------------------------------
[oracle@fardr ~]$ env | grep ORA
ORACLE_UNQNAME=FARDR
ORACLE_SID=FARDR
ORACLE_HOSTNAME=fardr
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_1
[oracle@fardr ~]$ expdp system/notallowed@PROD directory=dmpdir dumpfile=hr.dmp network_link=adg_sby schemas=hr
Export: Release 11.2.0.3.0 - Production on Sun May 5 23:22:38 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01": system/********@PROD directory=dmpdir dumpfile=hr.dmp network_link=adg_sby schemas=hr
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 448 KB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "HR"."COUNTRIES" 6.273 KB 25 rows
. . exported "HR"."DEPARTMENTS" 7.007 KB 27 rows
. . exported "HR"."EMPLOYEES" 16.80 KB 107 rows
. . exported "HR"."JOBS" 6.992 KB 19 rows
. . exported "HR"."JOB_HISTORY" 7.054 KB 10 rows
. . exported "HR"."LOCATIONS" 8.273 KB 23 rows
. . exported "HR"."REGIONS" 5.476 KB 4 rows
. . exported "HR"."BAL" 0 KB 0 rows
. . exported "HR"."T1" 0 KB 0 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
/tmp/hr.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 23:24:00