0% found this document useful (0 votes)
102 views

Standby Practical Notes

The document shows the steps to configure a physical standby database in Oracle. It includes configuring the standby control file and redo logs, copying primary database files to the standby, editing the standby initialization parameter file, mounting and opening the standby database, and switching logfiles on the primary to begin standby redo log application.

Uploaded by

Mohan Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views

Standby Practical Notes

The document shows the steps to configure a physical standby database in Oracle. It includes configuring the standby control file and redo logs, copying primary database files to the standby, editing the standby initialization parameter file, mounting and opening the standby database, and switching logfiles on the primary to begin standby redo log application.

Uploaded by

Mohan Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 15

To open primary database

SQL> archive log list;


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle9i/admin/shiv/arch
Oldest online log sequence 64
Next log sequence to archive 65
Current log sequence 65
SQL> create spfile from pfile;

File created.

SQL> shutdown immediate;


Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 286332064 bytes


Fixed Size 451744 bytes
Variable Size 167772160 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> archive log file;
SP2-0718: illegal ARCHIVE LOG option
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle9i/admin/shiv/arch
Oldest online log sequence 64
Next log sequence to archive 65
Current log sequence 65
SQL> alter system set log_archive_start=false;
alter system set log_archive_start=false
*
ERROR at line 1:
ORA-02095: specified initialization parameter cannot be modified

SQL> alter system set log_archive_start=false scope=spfile;

System altered.

SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 286332064 bytes
Fixed Size 451744 bytes
Variable Size 167772160 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Disabled
Archive destination /home/oracle9i/admin/shiv/arch
Oldest online log sequence 64
Next log sequence to archive 65
Current log sequence 65
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 286332064 bytes


Fixed Size 451744 bytes
Variable Size 167772160 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Disabled
Archive destination /home/oracle9i/admin/shiv/arch
Oldest online log sequence 64
Next log sequence to archive 65
Current log sequence 65
SQL> alter system set log_achive_start=true scope=spfile;
alter system set log_achive_start=true scope=spfile
*
ERROR at line 1:
ORA-02065: illegal option for ALTER SYSTEM

SQL> alter system set log_archive_start=true scope=spfile;

System altered.

SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 286332064 bytes


Fixed Size 451744 bytes
Variable Size 167772160 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle9i/admin/shiv/arch
Oldest online log sequence 64
Next log sequence to archive 65
Current log sequence 65
SQL> select force_logging from v$database;

FOR
---
NO

Default mode:- no logging

to change logging mode

SQL> alter database force logging;

Database altered.

SQL> select force_logging from v$database;

FOR
---
YES

SQL> select name from v$datafile


2 ;

NAME
-------------------------------------------------------------------------
-------
/home/oracle9i/admin/shiv/data/system01.dbf
/home/oracle9i/admin/shiv/data/undotbs01.dbf
/
home/oracle9i/admin/shiv/data/shiv01.dbf/home/oracle9i/admin/shiv/data/mo
han01.dbf
/home/oracle9i/admin/shiv/data/sud01.dbf
/
home/oracle9i/admin/shiv/data/data00.dbf/home/oracle9i/admin/shiv/data/sh
am01.dbf/home/oracle9i/admin/shiv/data/ar1.dbf
/home/oracle9i/admin/shiv/data/gg.dbf
/
home/oracle9i/admin/shiv/data/data01.dbf/home/oracle9i/admin/shiv/data/bb
b.dbf

11 rows selected.
SQL> shutdown;
Database closed.
Database dismounted.
ORACLE instance shut down.

To create stadby directory


[oracle9i@intellic ~]$ mkdir standby
[oracle9i@intellic ~]$ cd standby
[oracle9i@intellic standby]$ mkdir -p datafile controlfile archive
redolog dump/udump dump/bdump

oracle9i@intellic standby]$ ls
archive controlfile datafile dump redolog

Goto primary database and copy all datafiles into standby database
datafile folder

[oracle9i@intellic data]$ cp system01.dbf undotbs01.dbf shiv01.dbf


mohan01.dbf sud01.dbf data00.dbf sham01.dbf ar1.dbf gg.dbf data01.dbf
bbb.dbf /home/oracle9i/standby/datafile

primary database
SQL> startup
ORACLE instance started.

Total System Global Area 286332064 bytes


Fixed Size 451744 bytes
Variable Size 167772160 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> show parameter spfile;

NAME TYPE VALUE


------------------------------------ -----------
------------------------------
spfile string ?/dbs/spfile@.ora

Create control file for standby database

Step 1: create control file for standby database in primary database


SQL> alter database create standby controlfile as
'/home/oracle9i/standby/controlfile/cntrl.ctl';

Database altered.

Create pfile for standby database

SQL> create pfile='/home/oracle9i/dbs/initstandby.ora' from spfile;


edit standby parameter file

cd/dbs/
vi initstandby.ora

*.background_dump_dest='/home/oracle9i/admin/shiv/bdump'
*.compatible='9.2.0'
*.control_files='/home/oracle9i/admin/shiv/control/control01.ctl'
*.core_dump_dest='/home/oracle9i/admin/shiv/cdump'
*.db_block_size=4096
*.db_cache_size=100m
*.db_name='shiv'
*.log_archive_dest_1='location=/home/oracle9i/admin/shiv/arch'
*.log_archive_dest_state_1='enable'
*.log_archive_start=TRUE
*.query_rewrite_enabled='TRUE'
*.query_rewrite_integrity='TRUSTED'
*.shared_pool_size=100m
*.undo_management='auto'
*.undo_tablespace='undotbs'
*.user_dump_dest='/home/oracle9i/admin/shiv/udump'

To change admin to standby

:%s/shiv/standby/g

*.background_dump_dest='/home/oracle9i/standby/shiv/bdump'
*.compatible='9.2.0'
*.control_files='/home/oracle9i/standby/shiv/control/control01.ctl'
*.core_dump_dest='/home/oracle9i/standby/shiv/cdump'
*.db_block_size=4096
*.db_cache_size=100m
*.db_name='shiv'
*.log_archive_dest_1='location=/home/oracle9i/standby/shiv/arch'
*.log_archive_dest_state_1='enable'
*.log_archive_start=TRUE
*.query_rewrite_enabled='TRUE'
*.query_rewrite_integrity='TRUSTED'
*.shared_pool_size=100m
*.undo_management='auto'
*.undo_tablespace='undotbs'
*.user_dump_dest='/home/oracle9i/standby/shiv/udump'

To set some parameter settings in standby databse pfile

*.background_dump_dest='/home/oracle9i/standby/dump/bdump'
*.compatible='9.2.0'
*.control_files='/home/oracle9i/standby/controlfile/cntr.ctl'
*.db_block_size=4096
*.db_cache_size=100m
*.db_name='shiv'
*.log_archive_dest_1='location=/home/oracle9i/standby/arch'
*.log_archive_dest_state_1='enable'
*.log_archive_start=TRUE
*.query_rewrite_enabled='TRUE'
*.query_rewrite_integrity='TRUSTED'
*.shared_pool_size=100m
*.undo_management='auto'
*.undo_tablespace='undotbs'
*.user_dump_dest='/home/oracle9i/standby/dump/udump'
db_file_name_convert='/home/oracle9i/admin/shiv/data','/home/oracle9i/sta
ndby/datafile'
log_file_name_convert='/home/oracle9i/admin/shiv/redo','/home/oracle9i/st
andby/redolog'
standby_file_management=auto
remote_archive_enable=true
instance_name=standby
lock_name_space=standby
standby_archive_dest='/home/oracle9i/standby/arch'

Save and exit

To create listeners

#netmgr

To start listeners

To check listeners are working r not

[oracle9i@intellic ~]$ tnsping primary

TNS Ping Utility for Linux: Version 9.2.0.4.0 - Production on 29-JUL-2010


14:33:29

Copyright (c) 1997 Oracle Corporation. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias


Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL
= TCP)(HOST = 192.168.1.16)(PORT = 1525))) (CONNECT_DATA = (SERVER =
DEDICATED) (SERVICE_NAME = primary)))
OK (10 msec)
[oracle9i@intellic ~]$ tnsping standby

TNS Ping Utility for Linux: Version 9.2.0.4.0 - Production on 29-JUL-2010


14:33:36

Copyright (c) 1997 Oracle Corporation. All rights reserved.

Used parameter files:

Used TNSNAMES adapter to resolve the alias


Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL
= TCP)(HOST = 192.168.1.16)(PORT = 1526))) (CONNECT_DATA = (SERVER =
DEDICATED) (SERVICE_NAME = standby)))
OK (0 msec)

To goto standby database

[oracle9i@intellic ~]$ export ORACLE_SID=standby

[oracle9i@intellic ~]$ sqlplus '/as sysdba'

SQL> alter database mount standby database;

Database altered.

goto primary database

SQL> alter system set log_archive_dest_2='service=standby' scope=both;

System altered.

go to standby database

SQL> alter database mount standby database;

Database altered.

SQL> alter database recover managed standby database disconnect from


session;

Database altered.

SQL> recover managed standby database cancel;


Media recovery complete.
SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-16004: backup database requires recovery
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/home/oracle9i/standby/datafile/system01.dbf'

Primary database

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /
System altered.

standby database

SQL> alter database recover managed standby database disconnect from


session;

Database altered.

SQL> recover managed standby database cancel;


Media recovery complete.
SQL> alter database open read only;

Database altered.

SQL> select sequence#,first_time,next_time,applied from v$archived_log;

SEQUENCE# FIRST_TIM NEXT_TIME APP


---------- --------- --------- ---
65 29-JUL-10 29-JUL-10 YES
66 29-JUL-10 29-JUL-10 YES
67 29-JUL-10 29-JUL-10 YES

Primary database

SQL> select * from scott.emp;

---------- ---------- --------- ---------- -------- - ----------


----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-8 1 3000
20

7934 MILLER CLERK 7782 23-JAN-8 2 1300


1000
10

14 rows selected.

SQL> update scott.emp


2 set comm=450
3 where empno=7902;

1 row updated.

SQL> commit;

Commit complete.
To check update

SQL> alter database recover managed standby database disconnect from


session;

Database altered.

SQL> recover managed standby database cancel;


Media recovery complete.
SQL> alter database open read only;

Database altered.

SQL> select sequence#,first_time,next_time,applied from v$archived_log;

SEQUENCE# FIRST_TIM NEXT_TIME APP


---------- --------- --------- ---
65 29-JUL-10 29-JUL-10 YES
66 29-JUL-10 29-JUL-10 YES
67 29-JUL-10 29-JUL-10 YES

SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600


300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250


500
30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250


1400
30
7698 BLAKE MANAGER 7839 01-MAY-81 2850
30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000


20

7839 KING PRESIDENT 17-NOV-81 5000


10

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500
0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100


20

7900 JAMES CLERK 7698 03-DEC-81 950


30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300


1000
10

14 rows selected.
SQL> alter database recover managed standby database disconnect from
session;

Database altered.

SQL> recover managed standby database cancel;


Media recovery complete.
SQL> alter database open read only;

Database altered.

SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600


300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250


500
30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250


1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850


30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000


20

7839 KING PRESIDENT 17-NOV-81 5000


10

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500
0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100


20

7900 JAMES CLERK 7698 03-DEC-81 950


30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
20

7934 MILLER CLERK 7782 23-JAN-82 1300


1000
10

14 rows selected.

SQL> alter database recover managed standby database disconnect from


session;

Database altered.

SQL> recover managed standby database cancel;


Media recovery complete.
SQL> alter database open read only;

Database altered.
SQL> select * from scott.emp;

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20

7499 ALLEN SALESMAN 7698 20-FEB-81 1600


300
30

7521 WARD SALESMAN 7698 22-FEB-81 1250


500
30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20

7654 MARTIN SALESMAN 7698 28-SEP-81 1250


1400
30

7698 BLAKE MANAGER 7839 01-MAY-81 2850


30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7782 CLARK MANAGER 7839 09-JUN-81 2450
10

7788 SCOTT ANALYST 7566 19-APR-87 3000


20

7839 KING PRESIDENT 17-NOV-81 5000


10
EMPNO ENAME JOB MGR HIREDATE SAL
COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500
0
30

7876 ADAMS CLERK 7788 23-MAY-87 1100


20

7900 JAMES CLERK 7698 03-DEC-81 950


30

EMPNO ENAME JOB MGR HIREDATE SAL


COMM
---------- ---------- --------- ---------- --------- ----------
----------
DEPTNO
----------
7902 FORD ANALYST 7566 03-DEC-81 3000
450
20

7934 MILLER CLERK 7782 23-JAN-82 1300


1000
10

14 rows selected.

SQL> show parameter standby;

NAME TYPE VALUE


------------------------------------ -----------
------------------------------
standby_archive_dest string
/home/oracle9i/standby/arch
standby_file_management string auto

to change manual to auto parameter


SQL> show parameter standby;

NAME TYPE VALUE


------------------------------------ -----------
------------------------------
standby_archive_dest string ?/dbs/arch
standby_file_management string MANUAL
SQL> alter system switch logfile;
System altered.

SQL> shut
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 286332064 bytes


Fixed Size 451744 bytes
Variable Size 167772160 bytes
Database Buffers 117440512 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> show parameter standby;

NAME TYPE VALUE


------------------------------------ -----------
------------------------------
standby_archive_dest string ?/dbs/arch
standby_file_management string AUTO

to delete standby pfile first in /home/oracle9i/dbs (file


name=initstandby.ora)

and delete standby database also

to create remote configuration for standby

[oracle9i@intellic standby]$ scp -r controlfile oracle9i@192.168.1.17:


oracle9i@192.168.1.17's password:
cntrl.ctl 100% 1908KB 1.9MB/s
00:00

to change only tnsname

primary database:- standby name viceversa

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy