Você está na página 1de 22

How to add or extend datafiles in sap system based on oracle database ?

This article answers the below queries :

What is the database administration tool supported by SAP for oracle


database?
What is BRTOOLS ?
How to access BRTOOLS ?
How to add or extend datafiles in sap system based on oracle database
-----------------------------------------------------------------------------

What is BRTOOLS?

BRTOOLS is the database administration tool supported by SAP for oracle


database.

How to access BRTOOLS ?

BRTOOLS can be accessed by logging into database host as ora<sid> user and
calling brtools at the command prompt.

How to add or extend datafiles in sap system based on oracle database?

Once brtools is called at command prompt, following menu will be displayed

BR*Tools main menu

1 = Instance management
2 - Space management
3 - Segment management
4 - Backup and database copy
5 - Restore and recovery
6 - Check and verification
7 - Database statistics
8 - Additional functions
9 - Exit program
Standard keys: c - cont, b - back, s - stop, r - refr, h - help
======================================
Select option 2 - Space management from the above query and press c to
continue.

It displays another screen as below :

Database space management


1 = Extend tablespace
2 - Create tablespace
3 - Drop tablespace
4 - Alter tablespace
5 - Alter data file
6 - Move data file
7 - Additional space functions
8 - Reset program status

Standard keys: c - cont, b - back, s - stop, r - refr, h - help


=============================================
Select Option 1- Extend tablespace and press continue.

In the next screen, you will be prompted to enter tablespace name, size/location
of new datafile to be added, initial filesize, maximum filesize, autoextend
(yes/no). Please provide all the relevant details and you can see an SQL query is
being built based on the inputs given by you.

Once all the inputs are provided, press continue to execute the command and the
datafile will be added.

How to view database parameters at SAP level ?


This article answers the following queries:

How to view database active parameters at SAP level ?


How to view SPFILE parameters at SAP level ?
How to view database Parameters history at SAP level ?
How to export the database parameters to an excel sheet ?

How to view database active parameters at SAP level ?

Goto transaction DB02 and navigate to Additional Functions -> Database


parameters as shown below :

Click on Active parameters tab to view active database parameters


How to view SPFILE parameters at SAP level ?

Click on SPFILE tab to view SPFILE parameters

How to view database Parameters history at SAP level ?

Click on parameters history tab to view the parameters that are changed in the
recent past.
In the above screen click on Show parameters history. It displays window as
below

Provide the date from which you would like to view the database parameter
changes.

And then click on tick mark to view the database parameter changes from the
selected date.

How to export the database parameters to an excel sheet ?

Click on export button (highlighted below) and select table as the output as
shown in below screen and the parameters can be exported to an excel or word
as per the selection by you.

How to check database, tablespace sizes in SAP ?

This article answers the following queries :


How to check the database size ?
How to check in SAP, the number of tables and indexes in database and
their sizes ?
How to check the users that are present in database at SAP level ?
How to check various tablespaces in SAP and their sizes ?

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

How to check the database size ?

Goto transaction DB02 and navigate to Space -> Space overview to view

Database name
Database system
Size
Free size
Used percentage
Number of database users
Number of tablespaces
Number of tables and size
Number of indexes and size

In DB02, navigate to Space -> Space overview to find all the above mentioned
details

How to check the users that are present in database at SAP level ?

In DB02, navigate to Space -> Users -> Overview as below


How to check various tablespaces in SAP and their sizes ?

In DB02, navigate to Space -> Table spaces -> Overview to view


tablespaces details as below.

Oracle Background Processes

This article answers the following queries :

What are the different background processes of oracle database ?


What are the functionalities of different background processes of oracle?
What is dirty buffer ?
What is cold buffer?
What is write-ahead-logging ?
How to list or view the different background processes of oracle ?

Background processes are created from the oracle binary when an instance is
started. As the name suggests background processes run in background and
they are meant to perform certain specific activities or to deal with abnormal
scenarios that arise during the runtime of an instance.

From SAP perspective, the following are the 6 most important background
processes of oracle database.

Database Writer (DBWR) :

The database writer writes dirty blocks from the database buffer to the datafiles.

Dirty blocks need to be flushed out to disk to make room for new blocks in the
cache. When a buffer in the database buffer cache is modified it is marked as
dirty buffer. A cold buffer is a buffer that has not been recently used according
to the least recently used (LRU) algorithm. The database writer writes cold, dirty
buffers to disk so that new blocks can be read into the cache.

The initialization parameter DB_WRITER_PROCESSES specifies the number of


database writer processes. The maximum number of database writer processes is
20.

The database writer writes the dirty buffers to disk under the following
conditions :

1. When a checkpoint occurs


2. Every 3 seconds
3. When a server process couldnt find a clean reusable buffer after scanning a
threshold number of buffers

Log Writer (LGWR) :

The log writer process writes data from the redolog buffers to the redolog files on
disk.

The redolog buffer is a circular buffer. When LGWR writes redo entries from the
redolog buffer to the redolog file, server processes can overwrite the entries that
are already copied with new entries in redolog buffer. LGWR writes at a faster
pace so that space is always available in the buffer for new entries.

The log writer gets activated under the following conditions :

1. When a transaction is commited


2. Every 3 seconds
3. When the redo-log buffer is 0ne third full
4. When a database writer writes modified buffers to disk, if necessary
Note : Before database writer can write dirty blocks to disk it should make sure
that all redo entries are written from the redolog buffer to the disk. This is also
known as write-ahead logging. If database writer finds that some redo-records
are not written, it signals LGWR to write to disk and waits for LGWR to complete
writing the redolog buffer before it can write out the databuffers.

Checkpoint (CKPT) :

Checkpoint signals the synchronization of all database files with the check point
information. It ensures data consistency and faster database recovery in case of a
crash.

The checkpoint process regularly initiates a checkpoint. Whenever a check point


occurs following things are carried out :

1. Updating the file headers of the data files with information about the last
checkpoint performed
2. Update control files about the last checkpoint
3. Initiates LGWR to flush the redolog buffer entries to redolog files.
4. Writes the checkpoint record to the redolog file
5. Initiates DBWR to write all dirty blocks to disk and thus synchronizes
database

Archiver Process(ARCH) :

The archiver process copies online redolog files to the designation archive log
location after the occurrence of a log switch. It is an optional process. Archiver is
present only when database is running in archive log mode and automatic
archiving is enabled.

You can specify multiple archiver processes with initialization parameter


LOG_ARCHIVE_MAX_PROCESSES. ALTER SYSTEM command can be used to
increase or decrease the number of archiver processes.

However it is not recommended for us to change this value, as Log writer starts a
new archiver process automatically when the current archive processes are
insufficient to handle the workload

Process Monitor (PMON) :

The process monitor performs process recovery when a user process fails. PMON
is responsible for cleaning up the database buffer cache and freeing resources
that the user process was using like releasing locks, removing process ids from
active processes list etc.

PMON checks the running status of dispatcher and server processes periodically
and restarts in case any have stopped. Please note that this wont start processes
that are intentionally stopped by Oracle.

PMON also registers information about the instance and dispatcher processes with
the network listener.

PMON wakes up every 3 seconds to perform house keeping activities and should
be running always for an instance.

System Monitor (SMON) :

The system monitor performs instance recovery, if necessary, at instance startup.


SMON is also responsible for cleaning up temporary segments that are no longer
in use and for coalescing contiguous free extents within dictionary managed
tablespaces.

SMON can be called by other processes in cases of need. SMON wakes up every 5
seconds to perform house keeping activities. SMON must always be running for
an instance.

Query to view background processes of Oracle :

Goto SQL prompt of oracle database system and provide following command to
view background processes.

SQL>

Select * from v$session where type = BACKGROUND;


Difference between PFILE and SPFILE in Oracle

This article answers the following queries :

What is PFILE in Oracle?

What is SPFILE in Oracle?

What is the use of PFILE or SPFILE in Oracle ?

What is the difference between PFILE and SPFILE in Oracle ?

What are the advantages of SPFILE compared to PFILE in Oracle ?

How to check whether database is running with PFILE or SPFILE ?

Use of PFILE or SPFILE

When an Oracle instance is started, its characteristics are set by reading some
initialization parameters. These parameters are specified either through PFILE or
SPFILE. (0r)

When an oracle instance is being started, it reads either PFILE or SPFILE to set its
characteristics.

What is PFILE ?

A PFILE is a static, client side text file. This file normally resides on the server.
However in case you would like to start oracle from a remote machine, you will
need a local copy of the PFILE in that machine.

This file can be edited with a standard text editor like notepad or vi editor. This
file will be commonly referred as INIT.ORA file.
What is SPFILE ?

SPFILE (Server parameter file) is a persistent server side binary file. SPFILE
should only be modified through ALTER SYSTEM SET command . Editing an
SPFILE directly will corrupt the file and the start up of the database or instance
will not be possible.

As SPFILe is a server side binary file, local copy of the PFILE is not required to
start oracle from a remote machine.

Advantages of SPFILE compared to PFILE

A SPFILE doesnot need a local copy of the pfile to start oracle from a
remote machine. Thus eliminates configuration problems.

SPFILE is a binary file and modications to that can only be done through
ALTER SYSTEM SET command.

As SPFILE is maintained by the server, human errors can be eliminated as


the parameters are checked before modification in SPFILE

It is easy to locate SPFILE as it is stored in a central location

Changes to the parameters in SPFILE will take immediate effect without


restart of the instance i.e Dynamic change of parameters is possible

SPFILE can be backed up by RMAN

Difference between PFILE and SPFILE in Oracle :

SNO PFILE SPFILE


Persistent server side binary
1 Static, client side text file file
Local copy of pfile required to start
2 database from a remote machine local copy is not required
3 Can be edited through notepad or vi Editing directly will corrupt the
editor file. It should be modified only
through ALTER SYSTEM SET
command
Is available in earlier versions of Oracle Available from Oracle 9i and
4 9i above
Eliminates human errors as
parameters are checked
5 Prone to human errors while modification before modification
6 Cannot be backed up by RMAN Can be backed up by RMAN
Parameters in pfile cannot be changed Dynamic change of some
dynamically and system needs to be parameters is possible. Need
bounced for the new changes to take not restart server for the
7 effect changes to take effect

Query to findout, if database is running with PFILE or SPFILE

Goto SQL prompt and execute the following command to figure out if database is
started with a PFILE or SPFILE.

SQL > SELECT DECODE(value, NULL, PFILE, SPFILE) Init File FROM
sys.v_$parameter WHERE name = spfile;

Enabling or Disabling archivelog mode in Oracle

This article answers the following queries :

How to findout whether current archive mode in Oracle ?


How to connect to SQL in oracle?
How to findout whether archive mode is on or off in oracle ?
How to enable archive log mode in Oracle ?
How to disable archive log mode in Oracle ?
What are the steps to be followed in Oracle to change archive log mode?
How to shut down the oracle database ?
How to startup the oracle database in mount mode?

How to findout current archive mode in Oracle ?


Goto SQL prompt of oracle and provide the following command to find out the
archive mode in Oracle.

SQL > select log_mode from v$database;

It ouptus similar to as shown below if the database is in no archive mode.

LOG_MODE

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

NO ARCHIVE LOG

Steps to be followed in Oracle to Change the archive log mode

1) Connect to SQL plus

How to connect to SQL ?

First login to the database server using orasid user

Then connect to sqlplus as follows

sqlplus /nolog

conn /as sysdba

Then you will be connected to database and SQL prompt appears as below:

SQL >

2) Find out the current archive log mode by providing below command as
explained earlier:

SQL > select log_mode from v$database;

3) If current archive log is NO ARCHIVE LOG mode and if you would like to
set to ARCHIVE LOG mode, first of all shut down the oracle database.

How to shutdown oracle database?


Proceed as follows to shutdown the database

SQL > shutdown immediate;

Please wait for a while and system brings down the oracle database and
SQL prompt

appears.

4) Please note database should be in mount mode while changing the archive
log mode in Oracle.

How to start the oracle database in Mount mode?

Start the database in mount mode as shown below :

SQL> startup mount

An output similar to below will appear:

ORACLE Instance started

Total System Area xxxxxxxx bytes

Fixed size xxxxxx bytes

Variable size xxxxxxx bytes

Database buffers xxxxx bytes

Redo buffers xxxx bytes

Database mounted

5) Now since database is mounted provide the following command at SQL


prompt

SQL > alter database archivelog;

Once this command is given System prompts you with a message


Database altered

DISABLING ARCHIVE LOG MODE

Please note : For example, if you would like to set the database in NO
ARCHIVE LOG mode ( or disable archive log mode ) then command should
be
SQL > alter database noarchivelog;

6) Now open the database using the following command

SQL > alter database open ;

After this system prompts you with a message Database altered


confirming that the data base opened

7) Now cross check the current archive mode using the command below

SQL > select log_mode from v$database;

If you have enabled archive log mode then system prompts with a message
like

LOG_MODE

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

ARCHIVE LOG

Please note changing archive log mode can also be done through brtools
utility also. Will explain that process for the same in another article

Control file and its functions in Oracle

This article answers the following queries :

What is the control file in oracle?


What are the functions of control file in oracle ?
What are the control file contents ?
Can database function properly without control file?
Can we edit control file ?
Who can modify control file ?
At what time control file will be created?
What is control file in Oracle and what are its functions ?

Control file is a small binary file which is necessary for the database to start and
operate successfully.

What are the functions of control file ?

Each control file is associated with only one database. Oracle continuosly updates
control file during database use so this file must be available for writing whenever
the database is in the open state. Control file will be created at the same time of
database creation.

Whenever a datafile or a redolog file is added to , dropped or renamed in the


database, the control file is updated to reflect the physical structural change.

These changes are recorded in control file which facilitates :

Oracle to identify the files that are required or available in case database
recovery is needed

Oracle to identify the datafiles and redolog files to open during database
startup.

Can database function properly without control file?

No. Database cannot function properly if the control file is not available.

Can we edit control file ? Who can modify control file ?

Please note control file cannot be edited by database administrator or by any


user. Control file information can only be modified by Oracle.

Contents of control files :

Control file contains information such as

Database name

Timestamp of database creation


Tablespace information

The log history

Archive log information

Current log sequence number

Checkpoint information

Names and locations of associated datafiles and redolog files

Datafile copy information

Datafile offline ranges

Backup set and backup related information

Backup datafile and redolog information

Steps to be followed to rename or move control files location


This article answers the following queries :

How to find out the current location of control files?


Can we rename or move control file location? What is the parameter for
that ?
What is the process to be followed to rename or move control file
location?

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

Query to find current location of control files :

SQL > select name from v$controlfile;

After executing the above query, System outputs the location of all control files
in the system

Usually there will be 3 control files in oracle database( for SAP applications).

Can we rename or move control files location? If so, what is that


parameter?
Yes. If required, control files location can changed with the control_files instance
parameter.

Please execute the below query to display the current value of control_files
parameter

SQL > show parameter control_files

The above command outputs the current value. This value can be changed with
the ALTER SYSTEM command. In other words the current location of the control
files can be changed using ALTER SYSTEM command.

Steps to be followed to rename or move control files location

1) Alter the control_files parameter using the ALTER SYSTEM command

Syntax:

SQL> ALTER SYSTEM SET control_files=<New controlfile1 path or


newcontrol file name>, <New controlfile2 path or newcontrol file name>,
<New controlfile13 path or newcontrol name> SCOPE=SPFILE;

Eg: In the below command set the paths or names for various control files
as per your requirement

SQL> ALTER SYSTEM SET


control_files=D:\ORACLE\..\..\..\Newname1.CTL,

D:\ORACLE\..\..\..\Newname2.CTL, D:\ORACLE\..\..\..\Newname3.CTL

SCOPE=SPFILE;

2) Shutdown the database

SQL > shutdown immediate;

3) Rename the physical file in the OS

SQL > HOST MOVE <old controlfile with path> <new controlfile with path
>

Eg:
SQL > HOST MOVE D:\ORACLE\ORADATA\CONTROL01.CTL
D:\ORACLE\ORADATA\NEW_CONTROL01.CTL

4) Start the database

SQL > startup

How to recover an SAP instance when a control file got corrupted?

This article answers the following queries:

What are the scenarios in which contol file should be backed up in oracle?
How to backup control file in oracle?
How to recover an instance when one of the control files got corrupted ?
How multiple control files are managed in Oracle ?

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

Scenarios in which control file to be backed up in Oracle

It is very important to backup control file whenever there is a change in the


physical structure of the database. Some of the examples of structural changes
are

Adding or dropping or renaming of datafiles

Adding or dropping a tablespace

Altering the read/write state of the tablespace

Adding or dropping redolog files or groups

Control file backup procedure in Oracle

ALTER DATABASE BACKUP CONTROLFILE statement is used to backup control


files in Oracle.

There are 2 options to backup control files.

a. Backup the control file to a binary file (duplicate of existing control file)
using the below statement:

ALTER DATABASE BACKPUP CONTROLFILE TO


/oracle/backup/control.bkp;

b. Produce SQL statements that can later be used to re-create control file.

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

Above command writes a SQL script to the database trace file where it can
be captured and edited to regenerate the control file.

Recovering an instance when one of the control files got corrupted

Oracle recommends to have atleast 2 control files each stored on a different disk.

(Please note, for SAP applications , 3 control files are generally maintained in an
oracle database at different locations)

If a control file got corrupted due to a disk failure the respective instance should
be shut down. Once the disk drive is repaired, the corrupted control file can be
restored using the copy of control file from other disk and the instance can be
brought up. In these cases, media recovery is not required.

How multiple control files are managed in Oracle?

All the control files that are listed in the CONTROL_FILES parameter are
updated by the database.

The database reads only the first file listed in the CONTROL_FILES
parameter during database operation

If any of the control files got corrupted or become unavailable during


database operation, the instance wont function and it should be shutdown
and recovered as mentioned earlier

How to check table size in SAP?


This article answers the following queries

How to check table size in SAP?


How to check view size in SAP?
How to find out number of rows in a table in SAP?
How to view indexes on a table in SAP?
How to view index statistics of a table in SAP?
How to find out on what columns indexes are built on a SAP table?
How to find out on which date index statistics are last run for a SAP
table?

---------------------------------------------------------------------------------------
Please login to SAP system and goto transaction DB02 or DBACOCKPIT

Você também pode gostar