Database Administration Tasks
- Plane and create database
- Manage database availability
- Manage physical and logical structures
- Manage storage based on design
- Manage security
- Network administration
- Backup and Recovery
- Database tuning
Oracle Server = + Oracle Instance + Oracle database
Oracle Instance = Memory structures + Background process
Oracle Database = data files, control files, redo log files
SGA – (System Global Area), SGA_MAX_SIZE
- Shared pool, SHARED_POOL_SIZE
1. Library cache
- Execution plan
- Parse Tree
- Parsed and compiled program units and procedures
2. Data Dictionary cache
- Information about user account data, data file names, segment names, extent locations, table description and user privileges
- Database buffer cache,
- DB_CACHE_SIZE, DB_KEEP_CACHE_SIZE, DB_RECYCLE_CACHE_SIZE
- DB_CACHE_ADVICE values ON,OFF,READY, for predicting different cache
size behavior, information is stored in v$db_cache_advice
- Redo log buffer, LOG_BUFFER
- Primary purpose is recovery
- records all changes made to the database block
- change records within are called redo entries
- Larger pool (optional), LARGE_POOL_SIZE
- Java pool (optional), JAVE_POOL_SIZE
PGA – (Program Global Area)
- is a memory region that contains data and control information for single server process or a background process
- PGA includes following info
1. Sort area –
2. Session information – includes user privileges and performance statistics
for the session
3. Cursor state –
4. Stack space – contains other session variables
DBWn writes when following events occurs:
1. Checkpoint
2. Dirty buffer threshold reached
3. No free buffer
4. Timeout
5. RAC ping request
6. Tablespace offline
7. Tablespace read only
8. Tablespace BEGIN BACKUP
9. Table DROP or TRUNCATE
LGWR writes under following situations
1. At commit
2. When one-third full
3. When there 1 MB of redo
4. Every 3 seconds
5. Before DBWn writes
SMON: Responsibilities
1. Instance recovery
- Rolls forward changes in the redo logs
- Open database for user access
- Rollback uncommitted transactions
2. Coalescess free space every 3 seconds in the data files
3. Deallocates temporary segments
PMON: Cleans up after failed process by
1. Rolling back the user’s current transaction
2. Releasing the locks
3. Release other resources
4. Restarts dead dispatchers
CKPT : Checkpoint occurs in the following situations
1. At every log switch
2. shut down normal, transactional, or immediate
3. when forced by setting the parameter FAST_START_MTTR_TARGET
4. when manually requested by the DBA
5. ALTER TABLESPACE [OFFLINE NORMAL |READ ONLY|BEGIN BACKUP] cause checkpoint on specific data files
Check points are implemented for the following reason:
1. it ensures that data blocks in memory that changes frequently are written to data files regularly
2. all changes up to the checkpoints have been recorded in the data files, redo log entries before the checkpoints no longer need to be applied to the data files if instance recovery is required
At checkpoint following information is written:
1. checkpoint number into datafile headers
2. checkpoint number, log sequence number, archived log names, and system change numbers into the control file
If LOG_CHECKPOINTS_TO_ALERT parameter is set to TRUE checkpoint information is recorded in the altert_SID.log file
Oracle Managed Files:
DB_CREATE_FILE_DEST – default location for data files
DB_CREATE_ONLINE_LOG_DEST_N – default location for online redo logs and control files, up to max 5 locations
Startup nomount
- only during database creation or control file re-creation
Starting an instance includes following tasks
1. Reading initialization file in the following order
- spfileSID.ora. if not found then
- spfile.ora
- initSID.ora
2. SGA is allocated
3. Background processes are started
4. alert_SID.log and trace files opened
mounting the database
Database in mount during the following tasks
- renaming data files
- enabling or disabling archiving
- performing full database recovery
Mounting a database includes following tasks
1. Associate a database with a previously started instance
2. Locating and opening the control files specified in the parameter file
3. Reads the control file to obtain the names and status or datafiles and online redo log files
Opening the database
Opening the database includes the following tasks
1. opening the online data files
2. opening the redo log files
3. If necessary SMON initiates instance recovery
Shutdown normal
- no new connection can be made
- waits for all users to disconnect
- data and redo buffers are written to disk
- background processes are terminated
- SGA is removed from the memory
- closes and dismounts the database
- next startup does not require a instance recovery
Shutdown Transactional
1. No new connection
2. waits until all the transaction ends
3. a shutdown immediate occurs
shutdown immediate
- does not wait for users to disconnect
- rolls back all active transactions and disconnects all transactions
- closes and dismounts the database, next startup instance reconvery not required
shutdown abort
- all active sessions are terminated
- database and redo buffers are not written to disk
- uncommitted transactions are not rolled back
- instance is terminated without closing the files
- database is not closed or dismounted
- next startup requires instance recovery
Alert log keeps a record of following information
- when the database was started and shutdown
- a list of all non default initialization parameters
- the start up of the background processes
- the thread being used by the instance
- the log sequence number LGWR is writing to
- Information about the log switch
- Creation of tablespaces and undo segments
- alter statements that have been used
- information regarding the error messages such as ora-600 etc
Base tables are create during database creation, sql.bsq
Data Dictionary views are created using catalog.sql
Dynamic performance views: information is accessed from
- memory
- control file
Control files
- can be multiplexed up to 8 times
- size is influenced by the following keywords in create database or create ontolfile
commands
- MAXLOGFILES
- MAXLOGMEMBERS
- MAXLOGHISTORY
- MAXDATAFILES
- MAXINSTANCES
- Control file contains the following entries
- Database name and identifier
- Time stamp of the database creation
- tablespace names
- Names and locations of the data files and red log files
- Current redo log file sequence number
- Checkpoint information
- Begin and end of undo segments
- Redo log archive information
- Backup information
- The control file consists of two types of section
- Reusable – stores rman backup information, used in a circular manner.
- Not reusable
Multiplexing control file using spfile
1. Alter spfile
Sql> alter system set control_file=’/oradata1/control/control1.ctl’, ’/oradata2/control/control2.ctl’ scope=spfile;
2. shutdown normal
Sql> shutdown
3. create addition control file
$ cp /oradata1/control/control1.ctl’, ’/oradata2/control/control2.ctl’
4. start the databse
Sql> startup
Multiplexing control file using pfile
1. shutdown normal
Sql> shutdown
2. create addition control file
$ cp /oradata1/control/control1.ctl’, ‘/oradata2/control/control2.ctl’
3. Add new control file name to init.ora
control_file=’/oradata1/control/control1.ctl’, ’/oradata2/control/control2.ctl’
4. start the databse
Sql> startup
Backup control file
Sql> alter database backup controlfile to ‘/backup/controlfile.bkp’;
Sql> alter database backup controlfile to trace;
Add redo group
Alter database add logfile group 3 (‘/oradata/redolog/redo3a.log’, ‘/oradata/redolog/redo3b.log’) size 1m;
Alter database add logfile member
‘/oradata/redolog/redo1c.log’, to group 1,
‘/oradata/redolog/redo2c.log’ to group 2,
‘/oradata/redolog/redo3c.log’ to group 2;
Drop log file group
Alter database drop logfile group 3;
– the os files are not deleted
Drop log file member
Alter database drop logfile member ‘/oradata/redolog/redo3c.log’ ;
– the os files are not deleted
Status of the redo file
1. unused – log group never been used. When log file was just added
2. current – implies online redo group is active
3. active – indicates log group is active but not the current. It is needed for crash recovery
4. inactive – log group is no longer needed for instance recovery. It may or may not be archived.
Forcing Log switch
ALTER SYSTEM SWITH LOGFILE;
Clearing Log file
ALTER DATABASE CLEAR LOGFILE GROUP 5;
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 5