Você está na página 1de 5

CONTROL file management :

=========================
SQL> SELECT NAME FROM V$CONTROLFILE;
NAME
-------------------------------------------------------------------------------/u02/disk/prd/oradata/PROD/control01.ctl
/u02/disk/prd/flash_recovery_area/PROD/control02.ctl
Adding Control file :
======================
[prd@anush PROD]$ pwd
/u02/disk/prd/oradata/PROD
[prd@anush PROD]$ cp control01.ctl control03.ctl
[prd@anush PROD]$ ls
total 1513932
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba
-rw-r----- 1 prd dba

-ltr
20979712
5251072
52429312
52429312
104865792
52436992
713039872
492838912
52429312
9748480
9748480

Apr
Apr
Apr
Apr
Apr
Apr
Apr
Apr
Apr
Apr
Apr

4
4
4
4
4
4
4
4
4
4
4

22:01
22:12
22:12
22:12
22:12
22:17
22:17
22:17
22:20
22:20
22:20

temp01.dbf
users01.dbf
redo03.log
redo02.log
example01.dbf
undotbs01.dbf
system01.dbf
sysaux01.dbf
redo01.log
control03.ctl
control01.ctl

update the location information of newly created Controlfile in pfile.


[prd@anush dbs]$ pwd
/u02/disk/prd/11.2.0/dbs
[prd@anush dbs]$ ls
hc_PROD.dat initPROD.ora orapwPROD
spfilePROD.ora
init.ora
lkPROD
peshm_PROD_0
[prd@anush dbs]$ vi initPROD.ora
*.control_files='/u02/disk/prd/oradata/PROD/control01.ctl',
'/u02/disk/prd/flash_recovery_area/PROD/control02.ctl',
'/u02/disk/prd/oradata/PROD/control03.ctl'
CREATE A SPFILE FROM PFILE .
SQL> CREATE SPFILE FROM PFILE;
File created.

SQL> SHOW PARAMETER CONTROL_FILE;

SQL> SELECT NAME FROM V$Controlfile;


NAME
-------------------------------------------------------------------------------/u02/disk/prd/oradata/PROD/control01.ctl
/u02/disk/prd/flash_recovery_area/PROD/control02.ctl
/u02/disk/prd/oradata/PROD/control03.ctl
==================================== ===========================================
================================
DELETing the CONTROL FILE :
open the pfile and delete the path of the control file ;
[prd@anush dbs]$ ls
hc_PROD.dat initPROD.ora orapwPROD
spfilePROD.ora
init.ora
lkPROD
peshm_PROD_0
[prd@anush dbs]$ vi initPROD.ora

SQL> CREATE spfile from pfile;


File created.
SQL> startup;
SQL> SELECT NAME FROM V$controlfile;
NAME
-------------------------------------------------------------------------------/u02/disk/prd/oradata/PROD/control01.ctl
/u02/disk/prd/flash_recovery_area/PROD/control02.ctl

================================================================================
===================
Taking the Backup of the Control file
Steps :
Instance should be in runninng
SQL> SELECT STATUS FROM V$instance;
STATUS
-----------OPEN
SQL> alter database backup controlfile to trace as '/u02/disk/prd/control.sql';

Database altered.
[prd@anush ~]$ ls
11.2.0 cfgtoollogs control.sql flash_recovery_area oradiag_prd
admin checkpoints diag
oradata
oraInventory
When all the control files are lost we generate them with the help of backuped
controlfiles taken .
STEPS:
i. check weather any existing Control file are there by running the Sql qurey
SQL> SELECT NAME FROM V$controlfile;
ii. open the backup of Control File Copy the ANY one set of Script into a new f
ile and save it
[prd@anush ~]$ vi backup.sql
CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u02/disk/prd/oradata/PROD/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u02/disk/prd/oradata/PROD/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u02/disk/prd/oradata/PROD/redo03.log' SIZE 50M BLOCKSIZE 512
DATAFILE
'/u02/disk/prd/oradata/PROD/system01.dbf',
'/u02/disk/prd/oradata/PROD/sysaux01.dbf',
'/u02/disk/prd/oradata/PROD/undotbs01.dbf',
'/u02/disk/prd/oradata/PROD/users01.dbf',
'/u02/disk/prd/oradata/PROD/example01.dbf'
CHARACTER SET WE8MSWIN1252
;
iii. start the database in nomount stage;
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 644468736 bytes
Fixed Size
1338448 bytes
Variable Size
398459824 bytes
Database Buffers
239075328 bytes
Redo Buffers
5595136 bytes
iv. Run the script file
SQL> @backup.sql
Control file created.

SQL> SELECT STATUS FROM V$instance ;


STATUS
-----------MOUNTED
SQL> alter database open;
Database altered.
SQL> SELECT NAME FROM V$controlfile;
NAME
-------------------------------------------------------------------------------/u02/disk/prd/oradata/PROD/control01.ctl
/u02/disk/prd/flash_recovery_area/PROD/control02.ctl

Controlfile is a very critical file that is essentially needed for proper databa
se operation. Here are some interesting interview questions that an oracle dba c
an definitely expect during an interview
1) What are all the information that is stored in control file?
Oracle controlfile is a binary file. Make sure you don t attempt to edit it while
database is up and running. If so, this will cause an issue. Now, coming to the
information stored in controlfile, here are the details that a controlfile does
contain:
Database structure This starts with name of database, name of datafiles with ful
l path details, name of online redolog files with their location details
Controlfile is live and dynamic in the sense it stores details on online redo lo
g sequence number
Checkpoint information is stored in controlfile
Backup details RMAN does make use of controlfile to store information about back
ups. If the recovery catalog is not configured by default controlfile does store
RMAN backup details. This makes controlfile extremely important for restore, re
covery of RMAN backups
2) Can I open controlfile directly to read the details?
No. Controlfile is a small binary file. If you want to read details about the co
ntrolfile, run the following command from SQL prompt
alter database backup controlfile to trace;
This command will create controlfile as a trace file. Edit and read this file to
know current details. Instead opening controlfile directly will lead to corrupt
ion
3) What types of information is stored in controlfile?
Many different information is stored in controlfile including filename, tablespa
ce, rman configuration, backup corruption, proxy copy, flashback log, removable
recovery files, auxillary datafile copy, datafile. The information can be obtain
ed as follows:
select distinct type from v$controlfile_record_section;
4) What happens when shutdown command is issued?
When a shutdown command is issued
database is closed, controlfile is unmouneted,
oracle instance is stopped
5) In current production we have spfile.ora. We need to add a controlfile. Does
this demand instance restart?
Yes. When an environment does make use of spfile, still addition of controlfile
demands instance restart
show parameter control_files

Issue alter system set control_files= values scope=spfile;


shutdown immediate;
Copy the existing controlfile to new file. This duplicates controlfiles
startup; # this does bring back the instance

Você também pode gostar