Database Administrator an Introduction

Embed Size (px)

Citation preview

  • 7/28/2019 Database Administrator an Introduction

    1/32

    Database Administrator

    An Introduction

    UNCLASSIFIED

  • 7/28/2019 Database Administrator an Introduction

    2/32

    DBA Introdu

    1 Preface

    The information contained herein focuses on what would be considered an introduction to being an Oracle DataBAdministrator (DBA). It is not in any way a replacement for hands-on-training at an education center like LearnTree International or Oracle Education. It is however to be used as a starting point of reference for people startinareer as an Oracle DBA. This manual is a hodgepodge of information gathered from manuals, books, internet arti

    and personal experience, nothing is intentionally plagiarized.

    1.1 Terminology

    Table 1-1. Abbreviations

    Abbreviation Description

    RMANOracles Recovery Manager product used to backuprestore databases.

    PRIM The primary instance database

    SECD The failover instance database

    CATA The RMAN catalog instance database

    1.2 Typographic ConventionsThe following table provides the typographic conventions used in this guide:

    Table 1-2. Typographic Conventions

    Convention Description

    CourierCourier type indicates UNIX commands, directory names, usernames,pathnames, and filenames

    Italics Italic type indicates a variable, including variable portions of filenames

    UPPERCASEUppercase letters indicate Structured Query Language (SQL) reservedwords, initialization parameters, and environment variables

    This string indicates a newline character

    ArialArial type indicates response to commands by operating system (OS) orcurrent program in use

    1.3 Command Syntax

    Command prompts will vary depending on the shell or program you are current using.

    All command syntax appears in courierfont.

    $ character at the beginning of UNIX command examples is the default UNIX command prompt. Do

    enter it as part of the command. The UNIX command assumes the use of the POSIX shell.

    SQL> indicates a command example given at the default SQLPLUS command prompt. Do not enter it as par

    the command.

    Table 1-3. Command Syntax Conventions

    Convention Description

    backslash \ A backslash indicates a command that was too long to fit on a single line

    braces {} Braces indicated required items: export DISPLAY={YOUR_TERMINAL}

    brackets [] Brackets indicate optional items: stop_mon.sh {db} [service]

    ItalicsItalic type indicates a variable. Substitute a value for the variable:database_name

  • 7/28/2019 Database Administrator an Introduction

    3/32

    DBA Introdu

    1.4 Standards

    .4.1 File Locations and Descriptions

    Every system has sets of standards that to which they adhere. This document uses the following standards to forocations. It is not to be taken as a recommendation of standards, only as an example.

    Table 1-4. General File Locations

    Type of File Location Short Name Description

    RMANscripts

    /opt/oracle/workspace/bin$RMAN_DIR POSIX shell scripts (.sh) calling rman comman

    to backup and restore the database. These arlocated on the segment controller server.

    RMAN logs /opt/oracle/workspace/logs/rman$RMAN_LOGS Log files created by the RMAN scripts and

    located on the segment controller server.

    SQL scripts/home/oracle/sql and/opt/oracle/workspace/sql

    $SQL_DIR General sql scripts used in monitoring thedatabase.

    Shell Scripts /opt/oracle/workspace/bin$ORA_BIN General shell scripts the help in the over

    administration and monitoring of the database

    nitializationfiles

    $ORACLE_HOME/dbs/spfiledbname.o

    raNA Initialization parameter file for starting up

    database.

    Passwordfiles

    $ORACLE_HOME/dbs/orapwdbname NA Password file for accessing database asSYSDBA

    Oratab files /etc/oratabNA Listing of current databases on machine with t

    current home directory and if they should startwhen server is rebooted.

  • 7/28/2019 Database Administrator an Introduction

    4/32

    DBA Introdu

    2 Role of a Database Administrator

    2.1 Oracle DBA Responsibilities

    Install and upgrade Oracle products

    Creates and maintains all databases required for development, testing, education and production.

    Works in conjunction with System Administrators (SAs) to plan and allocate disk storage for each system. process can often depend on the type of disk storage system and how it is integrated into the over sysarchitecture.

    Work with software developers, network administrators and system administrators to monitor and perfo

    tuning of the database. The DBA works closely with the software developers because the highest yieldadjustments are often in the sql code used within the application. The DBA works closely with the sysadministrators because they often have applications or tools to use in monitoring system usage and can helppoint system bottle necks.

    Works in concurrence with Security System Administrators (SSA) to implement and maintain database secu

    including monitoring of auditing logs and database usage by users.

    Performs use maintenance

    Plan and implements backup and recovery strategy of Oracle databases.

    Controls migration of programs, database changes, and reference data changes through the development

    cycle.

    Modify database structures as required by system/problem change requests (PCR).

    Acts as the principal Oracle support contact. This includes using oracle metalink to research questions and o

    trouble tickets at http://metalink.oracle.com

    Works with Change Management Team (CM) and Software Developers (SDs) to develop and main

    standards in application design and code. They also work with CM and SD to ensure that system / standards are being adhered to.

    Evaluates and works with SA, SD, and CM to plan and integrate new releases of Oracle and its tools as wel

    any other third party products that have been integrated into the database administration or usage.

    Creates, enforces and maintains oracle database constraints to ensure integrity of the database.

    Works closely with software developers to provide technical support for database related issues as wel

    feedback on possible impact changes to the database objects may cause. It is the database administrators perform all administration tasks related to database objects, including tables, clusters, indexes, viesequences, packages and procedures.

    The DBA should work closely with system engineers and software developers to create and implement

    physical database design.

    2.2 The DBA in an Organization

    The database administrator is more than just an Operations and Maintenance role. They must communicatework with practically all groups that participate in the life cycle of a project/system. This would incmanagement, system architects, software development, vendors, system administrators, security sysadministrators, network administrators, service providers, users, test teams, and system configuramanagement teams. They work proactively with all teams to plan and improve the system. They wreactively to system and database problems with the O&M team.

    http://metalink.oracle.com/http://metalink.oracle.com/
  • 7/28/2019 Database Administrator an Introduction

    5/32

    DBA Introdu

    Figure 1: DBA Relation to Organization

    2.3 The Skills of a DBAThe roles outlined above show that the DBA is more than just a monitor/creator of the database instances. a role that works closely with many other groups to ensure that the best system is built and maintained. DBA must have many skills and areas of knowledge to make certain the database is integrated into the syswith maximum efficiency. A DBA should always be looking at their skill sets and striving to improve thThe DBA should have:

    Knowledge of operating system their databases reside on including areas of job scheduling, sys

    commands and shell scripting.

    Knowledge of physical database design including STAR schema, clustering, oracle recommended

    structures, and the normal forms (particularly 3

    rd

    normal form). Knowledge of Oracle and system performance tools for monitoring the system.

    A growing knowledge of Oracle features and the future vision of oracle to be able to provide input

    future system architecture.

    An understanding and practice in Oracle backup and recovery scenarios within the environment wh

    they maintain.

    At least a generally knowledge of the applications that access the database and specific knowledg

    they interact with the database.

    A good understanding of the business rules that govern the system and how they relate to

    information within the database.

    An understanding of the system life cycle that is implemented within the organization to which t

    belong.

    A growing knowledge and practice in tools and methods to perform database and program c

    performance tuning.

    Sound communication skills.

    DBA

    Requirements Engineers

    SystemArchitects

    Management System

    Administrators

    (SA, SSA,NA)

    Developers

    Test Team

    Users

    Configuration

    Management

    Orac

    le

    Vendor

    s

    Service

    Provider

    s

  • 7/28/2019 Database Administrator an Introduction

    6/32

    DBA Introdu

    2.4 DBA Example Checklist

    Each system differs on what types of checks that need to be performed. The following lists are not to beused as definitive checks, but rather a spring board for you to create your own task lists.

    2.4.1 Daily Procedures

    Many of these procedures can be automated using shell scripts and a scheduler like cron or even using tools suchOracle Enterprise Manager (OEM). The Lazy DBA is the concept that you are working smarter using tools to dogrunt work and then you checking the results.

    2.4.1.1 Verify all instances are up.

    Make sure that all databases under your supervision are available. Log into each instance and run daily reports orcripts.

    2.4.1.2 Look for any new alert log entries

    Each Oracle Instance has a background dump destination, usually in $ORACLE_BASE/ORACLE_SID/bdump. alert log file (alert_ORACLE_SID.log) is in this location and should be checked for errors each day.

    2.4.1.3 Verify success of database backup

    Keep a schedule of database backups and review logs to assure backups occurred successfully. In manyenvironments it is beneficial to keep track of backup times and sizes for capacity planning.

    2.4.1.4 Verify enough resources for acceptable performance

    Keep a record of acceptable minimum amount / percentage free in tablespaces and compare it daily to reports. Infappropriate parties if there is a discrepancy.

    2.4.1.5 Verify enough resources for acceptable performance

    Look for segments in the database that are running out of resources (e.g. extents) or growing at an excessive rate. torage parameters for these segments may need to be adjusted. You should as well gather sizing information as w

    and compare it to past trends. It is also important to check to make sure that the next_extent for each table is smahan the largest extent that the tablespace can offer, if not the space may need to be coalesced or a datafile added.

    2.4.1.6 Review contention for CPU, memory, network or disk resources

    Work with system administrators to develop methods to review contention for these resources.

    2.4.1.7 Check status of standby database if applicable.

    Check to determine if latest archive logs have been applied to the database by looking at the alert log filethe standby database.

    2.4.1.8 Read DBA manuals/reference materials for one hour

    t is extremely important to continue to read DBA manuals, trade journals, newgroups and/or mailing lists. newsgroups like, http://dba-village.com/village/dvp_base.main, allow you see real world questions being answeredother experienced DBAs, it also gives you a chance to ask questions and verify answers. The DBA manuals and trournals help you stay abreast of new trends and technologies. Often it is best to find a topic you are interesteearning more about and do research on the web about the topic.

  • 7/28/2019 Database Administrator an Introduction

    7/32

    DBA Introdu

    2.4.2 Procedures for Reviewing New Builds

    2.4.2.1 Review object creation scripts

    Each system should be adhering to object-creation policies (naming conventions, storage parameters, etc.). You shoreate scripts that check these policies out to assure they are being enforced.

    2.4.2.2 Look for security policy violations

    Every system has security policies. One of the best practices is that of Least Needed Privileges. The concept is tha

    object should be created with the least amount of individual access right to allow software to work. Access rihould be by group, not individuals, and never by public.

    2.4.2.3 Look in SQL*Net logs for errors or issues

    Although unlikely, it is possible that system changes occur in the manner which an application connects to the systThe SQL*Net logs should be reviewed to catch any such errors.

    2.4.2.4 Review Tuning Opportunities

    Review common Oracle tuning points.

    Cache hit ratio

    Latch contention

    Disk i/o contention

    Data Fragmentation

    Compare with past reports to identify impact of recent changes to system.

    Project Performance into the Future by comparing with past reports for both Oracle and the OS.

    2.5 DBA Resources

    Like with any other technical field the functionality and options that you can implement with Oracle continue to grt is impossible to be an expert on every single area of Oracle but there are resources that can definitely help

    nurture your knowledge. Training is very helpful, but I suggest that you take the hands-on approach. Using Courses are all well and good, but you need to sit down with Oracle and play with it; create a few tables, a few usearn basic SQL, shutdown/startup, backup and restore. You may want to take a class at a university in basic datab

    administration. The following links were current as off February 7, 2007. They are not exhaustive but are only mo be used as a spring board for you to find your own sources of knowledge.

    http://docs.oracle.com/home_content.html - All the original documents from Oracle and a great referelibrary.

    http://metalink.oracle.com The knowledge base and trouble ticket submission utility for Oracle. You m

    have an account which is based on your Customer Support Identifier (CSI).

    http://www.oracle.com/technology/index.html-Oracle - The Oracle Technology Network where you download software, review documentation, participate in forums, read articles, see sample codes and tutorial

    http://www.oracle-base.com Another good source from DBA Scripts, Version specific articles, foruexaminiation guides, and industry news.

    http://www.dba-oracle.com/oracle_links.htm - Site sponsored by Burleson Consulting with links to other sof interest.

    http://www.toadsoft.com/index.htm - Site for Toadsoft by Quest Software. This is a good tool for databdevelopers and DBAs.

    http://docs.oracle.com/home_content.htmlhttp://metalink.oracle.com/http://www.oracle.com/technology/index.html-Oraclehttp://www.oracle.com/technology/index.html-Oraclehttp://www.oracle-base.com/http://www.dba-oracle.com/oracle_links.htmhttp://www.toadsoft.com/index.htmhttp://docs.oracle.com/home_content.htmlhttp://metalink.oracle.com/http://www.oracle.com/technology/index.html-Oraclehttp://www.oracle-base.com/http://www.dba-oracle.com/oracle_links.htmhttp://www.toadsoft.com/index.htm
  • 7/28/2019 Database Administrator an Introduction

    8/32

    DBA Introdu

    http://blogs.oracle.com Oracle blogging community where you can read blogs from Oracle executiemployees and non-employees that exchange views about requirements and best practices for Oracle.

    http://www.dba-village.com/village/dvp_base.main - A good source of information for tips, scripts, papforums and links.

    http://blogs.oracle.com/http://www.dba-village.com/village/dvp_base.mainhttp://blogs.oracle.com/http://www.dba-village.com/village/dvp_base.main
  • 7/28/2019 Database Administrator an Introduction

    9/32

    DBA Introdu

    3 Oracle Architecture

    The following section outlines the Oracle Architecture. In general, an Oracle Instance refers to the backgroprocesses and memory structures; where as the Oracle Database refers to the actual physical storage structures.

    3.1 Oracle Server

    An Oracle Server is a relational database management system (RDBMS). It provides an open comprehens

    ntegrated approach to information management. It consists of an Oracle Instance and an Oracle database (see Fi2).

    Figure 2 : Oracle Instance and Oracle Database

    3.1.1 Oracle Instance

    An Oracle Instance is the means to access an Oracle database. It is always connected to one and only database. There however may be more than one instance that connects to a database (DB_NAME) (th

    either a parallel configuration or a Real Application Cluster (RAC) configuration (see Figure 3). An OrInstance consists of Memory structures and background processes (see Figure 2). It is uniquely defineORACLE_SID.

    System

    Global

    Area

    Databasebuffer cache

    RedoLog

    Buffer

    Shared PoolJava Pool

    DedicatedServer Process

    DatabaseWriter

    System

    Monitor

    Process

    Monitor

    Log

    Writer

    Archiver CKPT

    Oracle Instance Memory

    Database

    UndoTablespace(Rollbacksegments)

    DataSegments

    Redo log file 2

    Redo log file 3

    Redo log file n

    ControlFiles

    Oracle Database - Physical

    Redo log file 1

  • 7/28/2019 Database Administrator an Introduction

    10/32

    DBA Introdu

    Figure 3 : Parallel / RAC Configuration

    3.1.2 System Global Area (SGA)

    The SGA consists of the memory structures that perform the database management. This is a dynamic memarea where size is controlled by the initialization parameter SGA_MAX_SIZE. The following list is onfew of the memory structures within an instance.

    Shared Pool Includes areas such as Library Cache and Data Dictionary Cache.

    Library Cache The Library Cache includes the most recently executed SQL statements. Enables the sharingcommonly used statements across sessions. Is managed by a least recently used (LRU)algorithm and has two areas (SQL, PL/SQL)

    Data Dictionary

    Cache

    The Data Dictionary Cache includes the most recently used data definitions. Including

    information about database files, tables, indexes, columns, users, privileges and other databasobjects. Caching improves response time on queries and DML.

    Database BufferCache

    Stores copies of data blocks that have been retrieved from the datafiles. Enables greatperformance when you obtain and then update data. Is managed by a LRU algorithm.

    ava Pool Required only if installing and using Java because it services parsing requirements for Javacommands. Oracle 10g does require it for normal working.

    Redo Log Buffer Records all changes made to the database data blocks. Primary purpose is recovery. Changerecorded within are called redo entries. Redo entries contain information to reconstruct or redchanges.

    Larger Pool Optional area of memory in the SGA used to relieve the burden placed on the shared pool bysession memory, I/O server processes, backup and restore operations by RMAN and parallel

    execution message buffers.

    3.1.3 Program Global Area

    This is memory reserved for each server process connecting to an Oracle database. It is allocated when a seprocess is created and deallocated when the server process is terminated. It can only be used by one server process.

    3.1.4 Oracle Processes

    In a Unix/Linux environment the Oracle Instance has processes run as individual processes; in Windows trun as threads. The processes that are running will differ depending on the features that have been enabledan Oracle Instance. The processes are owned by the Oracle user and can generally be seen by using

    following command.$ps ef | grep oracle

    The following list is not exhaustive but is to give a general overview of some of the processes that may berunning in the background for an Oracle instance. Most of them will be covered in detail later.

    Archiver (ARCn) Copies online redo log files to disk/tape after each log switch for databases in ARCHIVELOmode.

    Checkpoint (CKPT) Updates the headers of all datafiles when a checkpoint occurs.

    Database WriterDBW0 or DBWn)

    In most systems on database writer is adequate by for systems that modifies data heavily mthan one may be needed. It writes out data from the buffer cache in the SGA to the databas

    Dispatcher (Dnnn) When the Oracle Instance is setup with the Multi-Threaded-server the dispatcher routes clie

    ORACLE_SID=

    PROD1

    DB_NAME=

    OE_PROD

    ORACLE_SID=

    PROD2

    ORACLE_SID=

    PROD3

  • 7/28/2019 Database Administrator an Introduction

    11/32

    DBA Introdu

    requests to the next available shared server process.

    Log Writer (LGWR) The log writer process (LGWR) writes the redo log buffer to a redo log file on disk.

    Process MonitorPMON)

    This is basically a cleanup system for processes that fail. It will clean up the database buffecache, and free resources that the users process was using.

    Recoverer (RECO) With a distributed database configuration this process automatically resolves failures for thdistributed transactions.

    System MonitorSMON)

    Performs system wide housekeeping tasks such as crash recover, if necessary, at instancestartup, cleaning up temporary segments, coalescing contiguous free extents.

    3.2 Oracle Database

    An Oracle Database is just basically a set of files treated as a unit. It provides the actual physical storage ofdatabase data and is mounted by one or more instances. All data is contained within Tablespaces and accessible when the database is OPEN. There are three basic file types that make up the Oracle Database.

    File Type Description

    Datafiles A tablespace in an Oracle database consists of one or more physical datafiles. A datafilebe associated with only one tablespace and only one database. Oracle creates a datafile ftablespace by allocating the specified amount of disk space plus the overhead required for

    file header. When a datafile is created, the operating system under which Oracle runresponsible for clearing old information and authorizations from a file before allocating Oracle.

    Control Files The database control file is a small binary file necessary for the database to start and opesuccessfully. A control file is updated continuously by Oracle during database use, so it mbe available for writing whenever the database is open. If for some reason the control file isaccessible, then the database cannot function properly. Each control file is associated wonly one Oracle database. It is advisable to have multiple copies of the control file being uby the database.

    Redo Log files A set of files that protect altered database data in memory that has not been written to thedatafiles. The redo log can consist of two parts: the online redo log and the archived redo lo

    There are three additional types of files that should be part of any backup policy of an Oracle database.

    File Type Description Minimum Backup Policy

    Parameter Files

    initORACLE_SID.ora,pfileORACLE_SID.ora)

    Controls aspects of the database instance and isreferenced at startup time.

    Monthly and before each change

    Password File Password files are located in directoryORACLE_BASE\ORACLE_HOME\DATABASE and are

    named PWDsid.ORA, where SIDidentifies the Oracle

    database instance. Password files can be used forlocal or remote connections to an Oracle9i database.

    Monthly and before each change

    Archived Log Files Optionally, filled online redo files can be archivedbefore being reused, creating an archived redo log.Archived (offline) redo log files constitute thearchived redo log.

    Depends on the volume but at ldaily.

  • 7/28/2019 Database Administrator an Introduction

    12/32

    DBA Introdu

    4 Establishing a Connection and Creating a Session

    There are primarily two ways to connect to an Oracle Instance. If your user/application resides on the same machinhe Oracle Instance you can do a local connection which can either be through an OS authenticated account or

    Oracle account which requires a username and password. A local connection does not pass through the Oracle formerly SQL*Net), which is a part of the Oracle Net Services. This concept is similar to the differences betwee

    Oracle Instance and an Oracle Database. If the user/application (client) resides on a different machine then it emote connection and uses the Oracle Net to access the system. For database security OS authenticated accohould never be allowed for remote connections. It should be noted here that even when the user/application residehe same machine as the Oracle Instance, you can still use Oracle Net to access the system, and in fact many of

    Oracles applications and third party software applications do.

    Figure 4 : Establishing Database Connection

    There are several files that control the connection from the client to the database.

    nsnames.ora The transparent network substrate names configuration file, should reside on any machine that wanmake a client connection to the database. This maps Net service names to connection descriptors.

    qlnet.ora This configuration file resides on both the client and server. It contains parameter for domain, nammethods, log/trace, route, security and access control.

    Listener.ora This configuration file resides on the server and contains the listener name, protocol addresses on whthe listener accepts connection requests, database services, and control parameters. Although FigurEstablishing Database Connection, shows the listener on a separate server as the database instance toften reside on the same hardware.

    The tnsnames.ora file contains all the connection descriptors for the databases to which you want to connection fhe machine on which it resides. It contains information about the destination service and network route informat

    Oracle Server

    Listener Process

    Oracle Client

    tnsnames.ora

    sqlnet.ora

    tnsnames.ora

    sqlnet.ora

    listener.ora

    Network

    Connection RequestEstablished Connection

  • 7/28/2019 Database Administrator an Introduction

    13/32

    DBA Introdu

    The following is an example of the connect descriptor format:

    Net_service_name=

    (DESCRIPTION=

    (ADDRESS=(protocol_address_information))

    (CONNECT_DATA=

    (SERVICE_NAME=service_name)))

    The listener listens for client connections. Once it receives a session request and establishes the link between the cland the server, it then establishes a new process (or picks from a pool and allocates processes). The client anderver then communicate independently of the listener. Shutting down or restarting the listener while a c

    application is running generally will have no effect on the existing application session, but it is not a recommenpractice.

    The Listener Control Utility (lsnrctl) is used to the control or view the listener configuration. It can be usetart/stop or even dynamically change some parameters. The lsnrctl status command will display a list of listen

    which will include descriptions and services and their individual status (READY, BLOCK or UNKNOWN).

    $ lsnrctl status [listener name]

    Results:

    If the listener is up, results should be something like:

    LSNRCTL for Solaris: Version 9.2.0.7.0 - Production on 04-JAN-2007 08:46:42

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

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)($=EXTPROC)))

    STATUS of the LISTENER

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

    Alias LISTENERVersion TNSLSNR for Solaris: Version 9.2.0.7.0 - Production

    Start Date 04-JAN-2007 17:31:04

    Uptime 12 days 15 hr. 15 min. 39 sec

    Trace Level off

    Security OFF

    SNMP OFF

    Listener Parameter File /opt/oracle/product/9.2.0/network/admin/listener.ora

    Listener Log File /opt/oracle/product/9.2.0/network/log/listener.log

    The command completed successfully

    If the listener is down

    Results: (example)

    LSNRCTL for Solaris: Version 9.2.0.7.0 - Production on 04-JAN-2007 09:00:03

    Copyright (c) 2003 Oracle Corporation. All rights reserved. Connecting (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)($=EXTPROC)))

    TNS-12541: TNS:no listener

  • 7/28/2019 Database Administrator an Introduction

    14/32

    DBA Introdu

    TNS-12560: TNS:protocol adapter error

    TNS-00511: No listener

    Solaris Error: 2: No such file or directory

    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=1521)))

    TNS-12541: TNS:no listener

    TNS-12560: TNS:protocol adapter error

    TNS-00511: No listener

    Solaris Error: 146: Connection refused

    4.1 Oracle Net

    Most connections issues can be traced to how the Oracle Net Services and its related components are configured. Oracle Manual says that Oracle Net Services is a suite of networking components that provide enterprise-wonnectivity solutions in distributed, heterogeneous computing environments. Seemingly benign changes to

    network configuration at this layer can bring systems to a halt and debugging at that point is extremely difficult. Thare many components to Oracle Net Services including Oracle Net, listener, Oracle Connection Manager, Oracle Configuration Assistant, and Oracle Net Manager. Depending on the application and the location of the application

    he system not all these components are used.

    Oracle Net is the communication software that enables a network session from a client application to connect toOracle database server. In other words, Oracle Net is a relay layer that sits on top of network protocols and resideboth the client and server ends. Its function is to perform the following critical network tasks:

    Relay calls from the client to the Oracle server and back

    Perform character translations between the client character set and the database character set.

    When you are done reading this section you should have a good understanding of the role and importance of Oracleand some base knowledge of its common configuration.

    n general communication through the network follows the following steps (Figure 5 : Client Server Architecture).

    1. Application communicates with Oracle Net on the client

    2. Oracle Net on the client communicates with the network

    3. The network carries the communication to the server

    4. The network communicates with Oracle Net on the server

    5. Oracle Net on the server communicates with the Server Process

  • 7/28/2019 Database Administrator an Introduction

    15/32

    DBA Introdu

    Figure 5 : Client Server Architecture

    4.2 Oracle Net on the ClientMost database programming interfaces (JDBC, ADO, ODBC, etc.) and application such as Perl-DBI and Pommunicate with Oracle Net through the OCI (see Figure 6). However, Pro*C/C++ and other pre-comp

    applications communicate through a layer parallel to OCI called SQLLIB. Both of these layers interact with OrNet through the UPI (user Program Interface) layer, which is the lowest layer of the client stack. The preference is lient programs should interact with Oracle at the OCI level (SQLLIB). There are thin clients that contain lim

    networking capabilities for talking to the Oracle Net Layer and these non-OCI JDBC drivers bypass the OCI laSome see the benefits of this being you dont have to install the Oracle client, however since the throughput for thdrivers is less than that of OCI-based JDBC driver the cost is performance.

    Figure 6 : Oracle Net on Client

    4.3 Oracle Net on the Server

    On the server, Oracle Net Services introduces the Oracle Net Listener layer between the network and the OraProtocol Support. The Oracle Net Listener basically works as a negotiator between the server and the client requt receives a request for a connection from the client and passes off the connection to a server. Once this connectiostablish it does not participate in the communication between client and server (see Figure 7). Depending on the

    Client Application

    Oracle Net on Client

    Oracle Net on Server

    Server Process

    Networ

    k

    Client Application

    ODBC ADO JDBC OCCI Pro*C, etc

    Oracle Call Interface (OCI) SQLLIB

    User Program Interface (UPI)

    Oracle Net Foundation Layer

    Oracle Protocol Support

    Network Protocol

  • 7/28/2019 Database Administrator an Introduction

    16/32

    DBA Introdu

    of connection your application maintains, it is entirely possible that the listener goes off-line with out affectingapplication. Many systems have applications that only connect once and then maintain their connection untilystem is shutdown. Therefore, after the system starts up the listener can fail without bringing the entire system dnot recommended), but this does prevent new connections over the network (local connections are still possible).

    Figure 7 : Role of the Listener

    4.4 Oracle Net Topologies

    There are many different topologies that you could encounter with Oracle Net. Most likely the ones that you ncounter will be of the following:

    Client/server architectures

    Server application architectures

    Database Links (including replication)

    External Procedures

    4.4.1 Client / Server Architecture

    The client/server architecture is illustrated above (see Figure 5) in which the client application accesses the databacross the network. The Oracle Net resides on both the client and server side of the network. Every user / applicaprocess connects to a server process on the server side. If the configuration is a dedicated server configuration, erver process is spawned by the listener per client connection. If the configuration is of shared server type, the

    many-to-one relationship exists between client and server connections.

    4.4.2 Server Application Architecture

    The topology in which the server application accesses the database on the same machine is a very minor varianFigure 5 , except that this scenario likely will reduce issues of network latency. If you use an OS authenticated accowithout specifying the instance in the connection string you by pass the listener when connecting to the server.

    Clie

    nt

    Network

    Listener

    Server Process

    Client

    Network

    Listener

    Server Process

    Initial Request for Connection

    Communication Hand-Off

  • 7/28/2019 Database Administrator an Introduction

    17/32

    DBA Introdu

    Figure 8 : Server Application Architecture

    4.4.3 Database Links / Replication

    A database link is like a referenced object that exists in database A, while operations actually take place over the on database B (see Figure 9). The databases can reside on the same or different machines but requires all the pro

    Oracle Net Services configurations to be done properly. The basis of replication is a database link and therefore cadepicted in the same manner.

    Figure 9 : Database Links

    Note in this figure that the database and server processes are shown two separate servers but they could just as easilon the same server.

    4.4.4 External Procedures

    External procedures are procedures defined externally but declared in the database. When they are called fromdatabase an individual process space is created from which they are executed. In this manner more OS interactionbe obtained by the means of the shared libraries or DLL. It also provides a means to use abilities available in o

    Client Application

    Oracle Net on Server

    Oracle Net on Server

    Server Process

    Server YServer X

    Client Application

    Oracle Net on Client

    Oracle Net on Server

    Server Process

    Network

    Database ADatabase B

    Database Link to DB B

    Oracle Net on Server

    Server Process

  • 7/28/2019 Database Administrator an Introduction

    18/32

    DBA Introdu

    anguages like C, ADA or JAVA that are not a part of or as well suited for the database PL/SQL. Speaking froecurity stand point, the external procedures (extproc) should have their own listener. The listener spawns the extp

    process in a manner similar to the server processes (represented by the dotted line in Figure 10) and communicahen happens via IPC.

    Figure 10: External Procedures

    There are other types of connections that are not mentioned here like the Heterogeneous connection, which allo

    ommunication between an Oracle database and other types of databases: the Web-Browser connection, whicbasically an application connection via a web-browswer. However, it is more likely you will encounter on of the abmentioned connections. If you would like more information then do a google search on Oracle Net Configurations.

    5 Quick Checks

    Often there is a need to verify whether an Oracle database is working. Sometimes a process running on one serverxtracts data from a database on another server. Tests may need to be performed locally as well as from the remoteerver.

    5.1 Test for Local Processes on Database Server

    The output will vary depending on the options in use. This output shows that the Oracle processes are runnncluding tnslsnr, often referred to as "the listener" and critical for connections to be made to the local databa

    $ ps -ef | grep oracle

    oracle 308 1 0 Oct 11 ? 3:35 ora_dbw0_ORCLoracle 338 1 0 Oct 11 ? 0:00 /opt/oracle/product/9.2.0/bin

    /tnslsnr LISTENER -inheritoracle 306 1 0 Oct 11 ? 0:03 ora_pmon_ORCLoracle 310 1 0 Oct 11 ? 1:12 ora_lgwr_ORCL

    oracle 312 1 0 Oct 11 ? 6:31 ora_ckpt_ORCLoracle 314 1 0 Oct 11 ? 0:21 ora_smon_ORCLoracle 316 1 0 Oct 11 ? 0:01 ora_reco_ORCLoracle 318 1 0 Oct 11 ? 0:14 ora_snp0_ORCLoracle 320 1 0 Oct 11 ? 0:14 ora_snp1_ORCLoracle 322 1 0 Oct 11 ? 0:15 ora_snp2_ORCLoracle 324 1 0 Oct 11 ? 0:15 ora_snp3_ORCLoracle 7388 1 0 Oct 21 ? 0:00 oracleORCL (DESCRIPTION=(LOCAL=no)

    (ADDRESS=(PROTOCOL=BEQ)))oracle 908 1 0 Oct 11 ? 0:11 oracleORCL (DESCRIPTION=(LOCAL=no)

    (ADDRESS=(PROTOCOL=BEQ)))oracle 7414 1 0 Dec 21 ? 0:23 oracleORCL (DESCRIPTION=(LOCAL=no)

    Client Application

    Oracle Net on Server

    Oracle Net on Server

    Server Process

    External Process (extproc)

    Shared Library/DLL

  • 7/28/2019 Database Administrator an Introduction

    19/32

    DBA Introdu

    (ADDRESS=(PROTOCOL=BEQ)))

    5.2 TEST Port

    f access to netstat is enabled check to assure a listener exists on the port that Oracle uses (by default 1521).

    $ netstat -a | grep 1521*.1521 *.* 0 0 0 0 LISTEN

    Oe_prod.32806 oe_prod.1521 32768 0 32768 0 ESTABLISHEDoe_prod.1521 oe_prod.32806 32768 0 32768 0 ESTABLISHEDlocalhost.32841 localhost.1521 32768 0 32768 0 ESTABLISHEDlocalhost.1521 localhost.32841 32768 0 32768 0 ESTABLISHEDoe_prod.1521 10.9.1.13.32854 24820 0 8760 0 ESTABLISHEDoe_prod.1521 10.9.1.13.32861 24820 0 8760 0 ESTABLISHED

    5.3 Connectivity Test

    5.3.1 tnsping

    This test can usually be done from both the remote and local server. This test uses the information in Oransnames.ora file to test connectivity. The command "tnsping ORCL", for example, will look for a database wi

    ervice name of ORCL and will issue a ping-like request to the configured port and report on the responseuccessful response from tnsping will look something like this:

    $ tnsping ORCL

    TNS Ping Utility for Unix: Version 9.2.0.0.0 - Production on 29-DEC-2005

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

    Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=oe_prod)(PORT=1521))OK (11 msec)

    The OK indicates that the network is working correctly and the response to 11 milliseconds. If Oracle is listening port other than 1521, the tnsping command will still work, assuming that the tnsnames.ora file contains the cornformation. A tnsnames.ora entry for a single database will could something like this:

    ORCL =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = oe_prod)(PORT = 1521))

    )(CONNECT_DATA =(SERVICE_NAME = ORCL)

    ))

    Notice how the service name (ORCL) that used in the example tnsping command and the port on which Oracle listener is responding (1521) are both configured in this database descriptor.

    5.3.2 SQLPLUS

    Sqlplus can be used to verify that Oracle is responding and some sqlplus commands can be used to verify the tables or the content of tables match what is expected.

    The sqlplus command takes this form to connect to an Oracle database:

    $sqlplus username/password[@service_name]

  • 7/28/2019 Database Administrator an Introduction

    20/32

    DBA Introdu

    This command specifies the username, password and SERVICE_NAME/SID in a singlecommand. Once connected, various scripts can be run to verify state of thedatabase.

    5.4 Check Log Directory and Files for Errors or Messages

    ~/bdump/alertORA_SID.log

    qlnet.log

    istener.log

    ~/bdump

    ~/cdump

    Rman backup logs

    5.5 Creating a Script

    Depending on the information you want to gather and the tests you want to run could make it quicker and more assuby writing scripts and display results or create log files. Often people like to create excel spreadsheets to display res

    and so you may want to create files that are comma delineated. You might want to make several individual scripts a local connection "connect2local" and a similar script for connecting to a database on a remote server "connect2rand then a wrapping script to execute them both. Understand that when ran from CRON shell scripts only takeminimal shell settings. You should store the environment variables to be used in a profile that is called withincripts as needed:

    # Oracle Settingsstty erase ^Hexport ORACLE_BASE=/opt/oracleexport ORACLE_HOME=$ORACLE_BASE/product/9.2.0export ORACLE_TERM=vt100export PATH=$ORACLE_HOME/bin:/usr/ccs/bin:/bin:/usr/bin:/usr/local/bin:/usr/u

    export ORACLE_SID=OE_PROD

    #!/bin/bash

    # connect2local: connect to local db using sqlplus

    ~/oracle_profile

    # check connectivity to databasetnsping $ORACLE_SID

    sqlplus username/password@$ORACLE_SID

    This is a very simple script that displays the results of the tnsping and should leave you at an SQL prompt. The nogical step is to either log these results or use the exit code from the commands to display succinct results.

    5.6 Script Creation

    You can write scripts which contain SQL*PLUS, SQL and PL/SQL commands which you can retrieve, edit and rThis is especially useful for storing complex commands or frequently used reports. Probably one of the easmethods of script creation is to have an OS editor open in one window and the SQL*Plus program open in anothYou can edit the script and save it then you @, @@ or START commands to execute the scripts. You can also useoperating system text editor without leaving SQL*Plus commands-line by enter the EDIT command at the S

  • 7/28/2019 Database Administrator an Introduction

    21/32

    DBA Introdu

    prompt.

    SQL>edit

    You can also choose a particular OS text editor by setting the SQL*Plus variable _EDITOR. For example, to dehe editor used by EDIT to be nedit, enter the following command:

    DEFINE _EDITOR = nedit

    To create script with a text editor, enter EDIT followed by the name of the file to edit or create, for example:

    SQL>EDIT SALESEDIT adds the filename extension .SQL to the name unless you specify the file extension.

    f you just type EDIT without a filename the last command stored in the buffer will appear for editing.

    SQL>select sysdate from dual;

    SQL>EDIT

    elect sysdate from dual

    You can use a number of SQL*Plus commands to edit the SQL command or PL/SQL block currently stored in

    buffer. Lists the SQL*Plus commands that all you to examine or change the command in the buffer without re-entehe command.

    Table 5: SQL*Plus Editing CommandsCommand Abbreviati

    onPurpose

    APPEND text A text Adds textat the end of the current line

    CHANGE /old/new C/old/new Changes old to new in the current lineCHANGE /text C/text Deletes text from the current lineCLEAR BUFFER CL BUFF Deletes all linesDEL Deletes the current lineDEL n Deletes line nDEL n * Deletes line n through *

    DEL LAST Deletes the last lineDEL m n Deletes a range of lines (m to n)DEL * n Deletes the current line through line nINPUT I Adds one or more linesINPUT text I text Adds a line consisting of textLIST ; or L Lists all lines in the SQL bufferLIST n L n or n Lists line nLIST * L * Lists the current lineLIST n * Ln * Lists the n through the current lineLIST LAST L LAST Lists the last line

    LIST m n L m n Lists a range of line m to n

    5.6.1 Saving Buffer

    When editing the buffer from the SQL*Plus command line you may want to save the buffer to a file for use laUsing the SAVE command will save what is in the buffer to the filename of your choice. The SAVE commaautomatically adds .SQL to the file name unless you specify a file extension.

    SQL>SAVE /tmp/mysqlscript

    This command saves a file to the /tmp directory named mysqlscript.sql.

    5.6.2 Placing Comments

    You can enter comments in a script in three ways:

    Using the SQL*Plus REMARK command for or - - for single line comments

  • 7/28/2019 Database Administrator an Introduction

    22/32

    DBA Introdu

    Using the SQL comment delimiters /**/ for single or multi line comments

    5.6.3 Suppressing Listing

    f you do not want the text of the script to be displayed on the screen when you run the file, then your script needontain SET ECHO OFF command.

    5.6.4 Running Scripts

    The START command retrieves a script and runs the commands it contains.

    SQL> START file_name

    SQL*Plus assumes the file has an .SQL extension by default.

    You can also use the @ and @@ commands run the commands in the specified script in the same manner.

    SQL>@file_name

    SQL>@@file_name

    5.6.5 Running a Script as You Start SQL*Plus

    To run a script as you start SQL*Plus, use one of the following options

    Follow the SQLPLUS command with your username, a slash, your password, a space, @, and the name offile:

    $SQLPLUS user_name/password @file_name

    If the /password is eliminated you will be prompted for the password.

    5.7 SQL Tuning

    SQL is declarative, so there are many ways to formulate a query, each with identical results but with far diffexecution times. Oracle SQL tuning is a very complex subject with entire books written about it. This section prov

    general ideas where to start researching for performance gains.

    5.7.1 Optimizing Oracle SQL Execution

    Reanalyze statistics only when necessary. It is a common mistake to frequently re-analyze the schema.

    However, the only purpose to analyzing the schema is to change the execution plan of the SQL. If there are complaints on the execution times, then dont fix it.

    Pre-tune the SQL before deploying Developers should be given an environment the properly reflects the

    Operational Environment. This may entail exporting the production CBO statistics into the test/developmendatabases. This will allow the developers to see how their SQL will execute when it is placed in the productsystem.

    AUTOTRACE and TKPROF Utilities should be used to interpret SQL execution results.

    Tune the overall system first Changes to critical CBO parameters (optimizer_mode,

    optimizer_index_cost_adj, and optimizer_index_caching) can affect thousands of SQL statements so should done with great care.

    5.7.2 General Guidelines for SQL tuning:

    Replace unnecessary large-table full-table scans with index scans.

    If your sql statement displays less than 40 percent of a table then it should not be performing full table scaChange the sql to use an index, check to statistics to assure CBO is optimal or if needed add an index.

    Cache small-table full tables scans

    If a small table is being hit often then it should be placed into memory. Logical reads (consistent gets) are o

  • 7/28/2019 Database Administrator an Introduction

    23/32

    DBA Introdu

    100x faster than a disk read and therefore small often accessed objects should be cached in the KEEP pCandidates to be placed in the KEEP pool can be found by analyzing dba_hist_sqlstat.

    Verify optimal index usage

    The developer should examine both indexes and ensure the Oracle is using the best index.

    Verify optimal JOIN techniques

    Some queries perform faster with NESTED LOOP joins and some with HASH joins.

    Tuning by Simplifying SQL Syntaxo Rewrite query into a more efficient form

    o Use the WITH clause

    o Use Global Temporary Tables

    o Use Materialized Views

    o Tune complex subqueries to remove redundant access

    All though these see simple enough, they comprise 90 percent of SQL tuning.

  • 7/28/2019 Database Administrator an Introduction

    24/32

    DBA Introdu

    6 Various Tips

    A quick reference sheet is very helpful especially when you are in a time crunch and need to have the information rihere in front of you. It is easier to keep the quick reference sheet up than try to remember the information in a cru

    Some of the information is generic but a lot of it is based upon the system. Keep it as a spreadsheet or just in w

    format, but keep it handy. It is also very useful to be able to pass onto people new to the group.

    6.1 Tip Sheet

    Metalink webaddress : www.metalink.oracle.com

    Metalink username :

    Oracle Customer Service Identifier (CSI):

    -------------------------Individual System

    System Name:

    System Description:

    Contacts:

    Role (SA, SSA, DBA,..) Name Contact

    Server Name Description Login Application User

    mportant Environmental Variables

    Server Name Variable Value

    Directory/File Locations (tnsnames.ora, listener.ora,bdump, cdump, backup logs, udump, sqlnet.ora)

    Server Name Location\File Name Description

    http://www.metalink.oracle.com/http://www.metalink.oracle.com/
  • 7/28/2019 Database Administrator an Introduction

    25/32

    DBA Introdu

    Backup Times:

    Server Date/Time (example Mon-Fri/04:00)

    Notes:

    6.2 Odds and Ends

    6.2.1 CRON and ENVIRONMENT

    When running an script from CRON or similar scheduling tool, it only uses the basic shell variables therefore you n

    o set any variables like ORACLE_HOME within the script itself.

    6.2.2 SQL Login Profile

    f you want to set your own defaults for when you log into SQL you can set things like linesizes, pagesizes, feedband even the format of fields such as dates within the login.sql in the SQLPATH.

    6.2.3 SQL DESC command

    f you need to know what fields a table contains use the DESC tablename to view the table structure.

    Example

    SQL>DESC ALL_TAB_COMMENTS

    OLUMN DATATYPE NULL DESCRIPTION

    WNER VARCHAR2(30) NOT NULL Owner of the objectABLE_NAME VARCHAR2(30) NOT NULL Name of the objectABLE_TYPE VARCHAR2(11) Type of the objectOMMENTS VARCHAR2(4000) Comment on the object

    6.2.4 ALL_%, DBA_%,USER_%Tables

    There are many system tables which can be used to determine user/system information. Data dictionarytables are not directly accessible, but you can access information in them through data dictionary views. list the data dictionary views available to you, query the view DICTIONARY.

    SQL>select * from DICTIONARY

    Many data dictionary tables have three corresponding views:

    An ALL_ view displays all the information accessible to the current user, including information from the curuser's schema as well as information from objects in other schemas, if the current user has access to those objectsway of grants of privileges or roles.

    A DBA_ view displays all relevant information in the entire database. DBA_ views are intended onlyadministrators. They can be accessed only by users with the SELECT ANY TABLE privilege. This privilegassigned to the DBA role when the system is initially installed.

  • 7/28/2019 Database Administrator an Introduction

    26/32

    DBA Introdu

    A USER_ view displays all the information from the schema of the current user. No special privileges required to query these views.

    Examples:

    f you have the proper privileges you can see all the tables within a database by querying the DBA_TABLES view.

    SQL>SELECT OWNER,TABLE_NAME FROM DBA_TABLES;

    f you want to see all the tables the current user has access to view use the following SQL statement.

    SQL>SELECT OWNER, TABLE_NAME FROM ALL_TABLES;f you only want to see the tables the current user owner use the next SQL statement.

    SQL>SELECT TABLE_NAME FROM USER_TABLES;

    I will list a few of the essential ones below and you can do a DESC on them to see the available columns

    Table Name Use

    *_ALL_TABLES

    Determine Table Information

    *_CONS_COLUMNS

    Determine the type of constraints on columns.

    *_CONSTRAINTS

    Determine all constraints

    *_ERRORS *_ERRORS describes current errors on stored objects (views, procedures,functions, packages, and package bodies) in the database.

    DBA_LOCK,DBA_LOCKS

    DBA_LOCK lists all locks or latches held in the database, and all outstandrequests for a lock or latch.

    6.3 Dynamic Performance V$ views

    This part describes the dynamic performance views, which are often referred to as V$views. These views can hel

    determining the performance of the database during testing or production. I will list a few of the more interestinguserful ones.

    Table Name Description

    V$DATABASE Displays information about the database from the control file.

    V$PROCESS This view contains information about the currently active processes. While the LATCHWcolumn indicates what latch a process is waiting for, the LATCHSPIN column indicates what latprocess is spinning on. On multi-processor machines, Oracle processes will spin on a latch bewaiting on it.

    V$INSTANCE This displays the current state of the instance;

  • 7/28/2019 Database Administrator an Introduction

    27/32

    DBA Introdu

    7 Database Administration Accounts

    Oracle databases are created with two accounts (SYS,SYSTEM) that have DBA privileges. The database administraccounts have a lot of power and should only be used when necessary to perform maintenance on they system. best approach is to have individual accounts to do general trouble shooting, data manipulation and monitoring ofystem. When doing tasks such as database backups and restores or trouble shooting it is easiest using a session onerver that contains the actual instance you want to backup or restore. If you are just performing adhoc queries or

    manipulation then remote access is fine.

    Each database administrator should have an individual OS account with the dba group privileges and then a databaccount with the privileges needed to perform daily tasks.

    7.1 SYS

    SYS is the owner of the database and the owner of the data dictionary. Never ever create objects in the SYS scheThe objects belonging to SYS cannot be exported. SYS has the SYSDBA privilege which SYSTEM doesn't. Tmakes it possible for SYS to become a very powerful user. This is the case when connections are made as

    sys/password as SYSDBA or/ as sysdbaThe as sysdba phrase is a request to acquire the privileges associated with the single SYSDBA system privileges.

    The difference becomes clear if you try to shutdown the database as ordinary SYS: you get insufficient privilegeesult. However, if connected as SYSDBA, it's possible.

    Anytime, someone connects as SYSDBA, it turns out it's being SYS. That is, if SYSDBA is granted to JOHN and Jonnects as SYSDBA and select user from dual, it reveals he's actually SYS.

    Ensure that your ORACLE_SID is set to the correct instance name.

    $echo $ORACLE_SID

    If it is not set correctly then

    $export ORACLE_SID=ORACLE_SID

    If accessing from local UNIX account with the proper privileges.

    $sqlplus / as sysdba

    If accessing remotely

    $sqlplus username/password as sysdba

    This makes a sys connection AS SYSDBA. When using this connection you will need to use a special intepassword if appropriate operating-system privileges are not held. This special password is held encrypted password file PWD.ora. This file is created by running the utility provided by Oracle ca

    ORAPWD. The use of this file can be limited to one instance, it can be a shared password file between instances an limit connections to only secure networks. The usage of the password file is controlled by an initializa

    parameter REMOTE_LOGIN_PASSWORDFILE and is used to define the mode of the password file.

    EXCLUSIVE

    o The password file can be used with only one database

    o Users other than sys may be given SYSDBA privileges

    SHARED

    o For use with multiple databases

    http://www.adp-gmbh.ch/ora/admin/objects.htmlhttp://www.adp-gmbh.ch/ora/admin/objects.htmlhttp://www.adp-gmbh.ch/ora/admin/objects.htmlhttp://www.adp-gmbh.ch/ora/admin/imp_exp.htmlhttp://www.adp-gmbh.ch/ora/sqlplus/connect.htmlhttp://www.adp-gmbh.ch/ora/admin/objects.htmlhttp://www.adp-gmbh.ch/ora/admin/objects.htmlhttp://www.adp-gmbh.ch/ora/admin/imp_exp.htmlhttp://www.adp-gmbh.ch/ora/sqlplus/connect.html
  • 7/28/2019 Database Administrator an Introduction

    28/32

    DBA Introdu

    o Only logins by sys are recognized by a shared password file

    NONE

    o No privileged connections over non-secure networks

    o Allows remote connections from accounts that are able to active OSDBA roles (this is

    authentication)

    7.2 SYSTEM

    SYSTEM is a privileged administration user, and typically owns Oracle provided tables other than the dictionary. Dreate your own objects under SYSTEM.

  • 7/28/2019 Database Administrator an Introduction

    29/32

    DBA Introdu

    8 Database States

    Remember that there are, in essence, two different entities: the Oracle Instance and the database. The instance is uo access and manipulate the database data and storage structures.

    An instance can be STARTed up which builds the SGA in memory and starts the background processes. The instanan also be SHUT DOWN which closes the database, stops the instance and removes the memory structures.

    database itself may be open, closed or mounted.

    NOTE

    Sometimes systems have 3rd party clustering software like HP ServiceGuard in place which controls the shutdown tartup of the Oracle Database. If you however a need arises that the DBA must startup/shutdown the instance thereteps that need to take place before issuing these commands to prevent ServiceGuard moving the database package

    different node. Check with your administrators on each system before trying to perform these commands to knowother steps to take.

    8.1 Database Startup

    Figure 11: Database Stages

    t can be observed in Figure 11 that the database can be altered in the upward direction (up the stairs) but not bdown them. In addition to the states there are three additional options that can be combined with the states whpurpose are in the following list.

    NOMOUNT Starts up the instance without mounting the database. Activities are limited to things like creating a database. database is inaccessible with no dictionary available for password checking.

    MOUNT Starts up the instance and mounts the database. It allows restricted use of the database for DBA tasks such asmanagement and database structuring. There is no normal user access possible

    OPEN It starts the instance, mounts and then opens the database. Other file management activities available sucManipulating log files, taking datafiles offline, backing up control files. Normal users processing is allowed.

    FORCE Shuts down an instance before starting it up in the specified mode and is the same as performing SHUTDOWN AB

    followed by a start-up.

    RECOVER This is an OPEN option which forces automatic recovery procedures on start-up.

    Shutting Dow

    (closing)

    Altering the

    database

    Instance

    started

    STARTUP NOMOUNT

    Reads init.ora

    Creates and starts instance

    STARTUP MOUNT

    Links the instance to a database

    Reads control file

    Checks the datafiles and redo log files

    STARTUP OPEN

    Opens datafiles and redo logs

    Acquires roolback segments

    Calls SMON if needed

    Makes data dictionary available

    SHUTDOWN SHUTDOWN

  • 7/28/2019 Database Administrator an Introduction

    30/32

    DBA Introdu

    RESTRICT This is an OPEN option which limits access to the database to users who have been granted both CREATE SESSION A

    RESTRICTED SESSION system privileges. It is useful for doing tasks like database exports while there is no activit

    the database.

    SQL>STARTUP OPEN RESTRICT

    Can be removed while open by doing the following command:

    SQL>ALTER SYSTEM DISABLE RESTRICTED SESSION;

    The above options can be combined at the SQL prompt to create the state you wish the database to start.

    SQL>STARTUP [FORCE] [NOMOUNT | MOUNT | OPEN [open_options]] [oracle_sid_name][PFILE=paramfile];

    Examples:

    SQL>STARTUP MOUNT prod;

    SQL>STARTUP OPEN RECOVER;

    The database can be moved upward on the state stair step by performing alter commands.

    SQL>ALTER DATABASE MOUINT;SQL>ALTER DATABASE OPEN;

    8.2 Database Shutdown

    You can not go back down the stair step depicted in Figure 11, you have to SHUTDOWN the database completely hen you can open it to the state you need. The SHUTDOWN command closes the database, dismounts the datab

    and then shuts down the instance. There are several SHUTDOWN options that can be employed.

    SQL>SHUTDOWN NORMAL

    o The database will only SHUTDOWN when all users have logged off and all work is committed

    rolled back).o No new connections are allowed.

    o This option is difficult to use in man environments since the users are applications and all

    applications have to be shutdown before the database would shutdown.

    SQL>SHUTDOWN IMMEDIATE

    o Disconnects all users and performs rollback on all uncommitted data by using PMON

    o Terminates all current SQL statements

    SQL>SHUTDOWN ABORT

    o Shuts down without tidying up; akin to system failure and requires system recovery on start-up

    o No rollback of uncommitted transactions

  • 7/28/2019 Database Administrator an Introduction

    31/32

    DBA Introdu

    9 Database Backup

    The planning of the backup and recovery strategies of the database has to be integrated into the bacand recovery strategies of a system and business in general. Some sample items to consider:

    1. Backup retention policies This may vary depending on how often you are able to perform a fullbackup. Business rules may dictate policies. State or government laws may place restrictions onretention times.

    2. Tape retention policies This probably goes hand-in-hand with backup retention policies. Theremay be cases however that you keep one backup on-line and an older one offsite. Where is youroffsite tape storage location?

    3. Detailed capacity planning The backup plan you put into place today, maybe outdated next yearthe system grows immensely. You should know what changes are expected within the business aforecast what effects it will have on the size of your database and your backups.

    4. Location of backups Where will you store your backups. Will your backups go directly to tape owill you write them to disk first and then have the system write them to tape?

    5. If you write backups to disk then when will they get written to a tape? How do you know that theyhave been written to tape so you can reuse the space for a new backup?

    Overall Oracle Database Backup and Recovery Strategy

    Backup Strategy

    There are several database considerations when planning an Oracle backup.

    1. Operate in Archive Log Mode Operate the production Oracle database in automatic archivelogmode. In addition you need to regularly monitor the archive log location to ensure that there isadequate disk space to store archived redo log files.

    2. Perform Regular Hot Backups Your overall system backup policy should include regular backupsThis policy will be dictated by several factors including:

    a. System Workloadb. Amount of Database Updatesc. Size of Databased. Time it Takes to Perform Backups

    3. Archived Log File Backups Depending on the amount of database updates, archived log filesshould be archived several times between the full database backups.

    4. Retain Archived Redo Log Online As a rule of thumb, keep the archived redo log files on disk forlong as possible, ideally until the next full backup. This allows for faster recovery in case a media(disk) failure occurs, since the logs do not have to be restored from a slower tape failure.

    5. Backup the Control File You should always include the control file as part of the backup, but toensure recovery you should also perform a binary and text copy backup with every major backup.This is especially important after database structural changes.

    6. Backup the Parameter and Passwords files The oracle parameter init.ora or spfile.ora file, are nosupported by Recovery Manager. The parameter and password files should however be backed uregularly by the OS backup or included in backup scripts.

    7. Use Automatic Scheduling and Notification The backup scripts should run automatically via ascheduling tool like cron in UNIX.

  • 7/28/2019 Database Administrator an Introduction

    32/32

    DBA Introdu

    Recovery Strategy

    Different types of failures within an Oracle database require their own recovery. This document will document mof types of database failures but all scripts and steps need to be modified for your system and then tested.

    1. Instance Failure Instance failure can usually automatically addressed by Oracle if the server has not failed awell. If the server has failed and can be restarted successfully, the Oracle server can automatically recover itfrom the redo logs upon startup.

    2. Media Failure Media failures require media recovery, which is the process of restoring database files to themost recent point-in-time image prior to the media failure. Media recovery can be supported by using acombination of backup files and archived redo log files.

    3. Server (Node) Failure This can be dressed by failing over to another node if you are in Fail Safeconfiguration. A secondary node can share the same disk drives and datafiles as the primary node and can bbrought up upon node failure. This is not to be confused with RAC, GRID or an Oracle standby database. Ithere is only one sever then problems with that server will need to be addressed before the database recoverycan be performed.

    t can not be emphasized enough that for quick recovery you dont want to be sitting at a terminal trying to remem

    ommands or not understanding how to do the steps properly. All scripts and steps should be well documented ested multiple times to assure they work properly.