Connecting to a Database Other Key Physical Structures Parameter file Password file 1-9 Database Archived log files Copyright © Oracle Corporation, 1998 All rights reserved Apart from the database files, an Oracle server also uses other files Some of these are: • Parameter file: used to define the characteristics of an Oracle instance • Password file: used to authenticate privileged database users • Archived redo log files: offline copies of the redo log files that may be necessary to recover from media failures The following sections of this lesson explain how a server process uses some of the components of the Oracle instance and the database to service requests made by a user process Oracle8: Database Administration 1-13 Lesson 1: Oracle Architectural Components Running a Query Processing a Query Statement SELECT * FROM emp Handle ORDER BY ename; Handle User process Server process Results OK OK Parse 1-10 Execute Fetch Copyright © Oracle Corporation, 1998 All rights reserved The following are the main stages in the processing of a query: Parse: In this stage, the user process sends the query to the server process with a request to parse or compile the query The server process checks the validity of the command and uses the area in the SGA known as the shared pool to compile the statement At the end of this phase, the server process returns the status—that is, success or failure of the parse phase—to the user process Execute: During this phase in the processing of a query, the server process prepares to retrieve the data Fetch: The rows that are retrieved by the query are returned by the server to the user during this phase Depending on the amount of memory used for the transfer, one or more fetches are required to transfer the results of a query to the user Instructor Note This slide has a build There are three stages 1-14 Oracle8: Database Administration Running a Query The Shared Pool Shared pool Library cache Data dictionary cache • Size defined by SHARED_POOL_SIZE • Library cache contains statement text, parsed code, and an execution plan • Data dictionary cache contains table and column definitions and privileges 1-11 Copyright © Oracle Corporation, 1998 All rights reserved The shared pool is a part of the SGA that is used during the parse phase The size of the shared pool is specified by the initialization parameter, SHARED_POOL_SIZE in the parameter file The components of the shared pool described below are used to parse an SQL statement Library Cache The library cache stores the following information about the most recently used SQL statements: • Text of the statement • Parse tree, which is the compiled version of the statement • Execution plan, which defines the steps to be followed in running the statement as determined by the optimizer Since the library cache stores this information, if a query is reexecuted before its execution plan is aged out by other statements, the server process does not need to parse the statement Thus the library cache helps improve the performance of applications Oracle8: Database Administration 1-15 Lesson 1: Oracle Architectural Components Data Dictionary Cache The data dictionary cache, also known as the dictionary cache or row cache, is a part of the shared pool that stores the most recently used data dictionary information, such as table and column definitions, usernames, passwords, and privileges During the parse phase, the server process looks for the information in the dictionary cache to resolve the object names specified in the SQL statement and to validate the access privileges If necessary, the server process initiates the loading of this information from the data files 1-16 Oracle8: Database Administration Running a Query Database Buffer Cache • Number of buffers defined by DB_BLOCK_BUFFERS • Size of a buffer based on DB_BLOCK_SIZE • Stores the most recently used blocks 1-12 Copyright © Oracle Corporation 1998 All rights reserved When a query is processed, the server process looks for the blocks needed in the database buffer cache If the block is not found in the database buffer cache, the server process reads the block from the data file and places a copy in the buffer cache Subsequent requests for the same block are likely to find the block in memory, and may not require physical reads Function of the Database Buffer Cache The database buffer cache, or simply the buffer cache, is an area in the SGA that is used to store the most recently used data blocks The size of each buffer in the buffer cache is equal to the size of a data block, and it is specified by the DB_BLOCK_SIZE parameter The number of buffers is equal to the value of the DB_BLOCK_BUFFERS parameter The Oracle server uses a least recently used (LRU) algorithm to age out buffers that have not been accessed recently to make way for new blocks to be accommodated in the buffer cache Oracle8: Database Administration 1-17 Lesson 1: Oracle Architectural Components Program Global Area (PGA) Server process PGA • Not shared and not writable • Contains – Sort area – Session information – Cursor state – Stack space 1-13 Copyright © Oracle Corporation, 1998 All rights reserved The Program Global Area (PGA) is a memory region that contains data and controls information for a single server process or a single background process In contrast to the SGA, which is shared and written to by several processes, the PGA, which is also called the process global area, is an area that is used by only one process When using the dedicated server configuration, the PGA contains: • Sort area: which is used for any sort that may be necessary before rows are processed or returned to the user • Session information: such as user privileges for the session • Cursor state: which indicates the stage in the processing of various cursors that are currently used by the session • Stack space: containing the session variables The PGA is allocated when a process is created and deallocated when the process is terminated Note Some of these structures are stored in the SGA when using an MTS configuration 1-18 Oracle8: Database Administration Running a DML Statement Running a DML Statement Processing a DML Statement UPDATE emp Instance SET sal=sal*1.1 WHERE empno=7369 Server process SGA Shared pool Library cache Database buffer cache Redo log buffer Data dictionary cache 1-14 Data files Control files Database Redo log files Copyright © Oracle Corporation, 1998 All rights reserved A data manipulation language (DML) statement requires two phases of processing: • Parse, which is similar to the parse phase used for processing a query • Execute Execute Phase Consider an example in which a user executes an update command of the following form: UPDATE emp SET sal=sal*1.1 WHERE empno=7369; What follows are the steps used in executing the update statement: The server process reads the data and rollback blocks from the data files, if they are not already in the buffer cache Copies of the blocks that are read are placed in the buffer cache The server process places locks on the data Oracle8: Database Administration 1-19 Lesson 1: Oracle Architectural Components The server process records the changes to be made to the rollback (before-image) and to the data (new value) in the redo log buffer The server process records the before-image to the rollback block and updates the data block, both in the database buffer cache Both the changed blocks in the buffer cache are marked as dirty buffers—that is, buffers that are not the same as the corresponding blocks on the disk Note The processing of a DELETE or INSERT command uses similar steps The before-image for a delete contains the column values in the deleted row, while inserts just require the row location information to be stored in the rollback Instructor Note • The slide explaining the processing of a DML command has builds There are five stages • You may want to ask the students what the DML commands are In the current context we are referring to only the INSERT, UPDATE, and DELETE commands 1-20 Oracle8: Database Administration Running a DML Statement Rollback Segment Old image New image Table Rollback segment DML statement 1-15 Copyright © Oracle Corporation, 1998 All rights reserved Before making a change, the server process saves the old value into a rollback segment This image is used to: • Undo the changes if the transaction is rolled back • Ensure that other transactions not see uncommitted changes made by the DML statement (read consistency) • Recover the database to a consistent state in case of failures Rollback segments, like tables and indexes, exist in data files and parts of them are brought into the database buffer cache when required Oracle8: Database Administration 1-21 Lesson 1: Oracle Architectural Components Redo Log Buffer • Size defined by LOG_BUFFER • Records changes made through the instance • Used sequentially • Circular buffer 1-16 Copyright © Oracle Corporation, 1998 All rights reserved The server process records changes made by an instance in the redo log buffer, which is a part of the SGA The redo log buffer has the following characteristics: • Its size in bytes is defined by the LOG_BUFFER parameter • It stores redo records, which record changes—that is, the block that is changed, the location of the change, and the new value A redo entry registers a change, but it makes no distinction between the type of block that is changed So it cannot distinguish, for example, a change to a data block from a change to an index or a rollback block • The redo log buffer is used sequentially, and changes made by one transaction may be interleaved with changes made by other transactions • It is a circular buffer that is reused after it is filled up, but only after all the old redo entries are recorded in the redo log files Note The redo log files are covered in more detail in the lesson “Maintaining Redo Log Files.” 1-22 Oracle8: Database Administration Lesson 2: Using Administration Tools Intelligent Agent The intelligent agent is a process that runs on remote nodes in a network It executes jobs and events sent by the console and communicates results back to the console using Net8 The agent provides autonomy from the console For example, in the event that a network connection becomes severed or the console is down, the intelligent agent continues to operate remotely, reporting status back to the console once normal communications are restored OEM Repository The OEM Repository (the repository), a set of database tables that holds information used by OEM, gives the administrator location flexibility A separate repository exists for each OEM user When a user logs on using OEM, a connection to that user’s repository is established Since each repository is associated with an owner (as opposed to a specific client machine), a user can log on using OEM from any client machine Thus, an off-site administrator can actually log on using OEM from a connected console in a remote city if desired 2-10 Oracle8: Database Administration OEM Components OEM Components Enterprise Manager Console 2-8 Copyright © Oracle Corporation, 1998 All rights reserved The OEM Console provides a global view of the system It includes both a hierarchical tree and a graphical representation of the objects in the system It has the following features: A menu that can be used to initiate other administrative applications and perform various tasks A launch pallette to invoke other applications to perform administrative tasks (It provides an alternative to using the menu.) A navigator or object explorer view which provides a hierarchical view of Oracle services on the network (The navigator permits administrators to browse the different Oracle services such as databases, listeners, nodes, and name-servers, and modify the characteristics of objects; for example, users, and tables that they contain.) A map or topographical view which permits Oracle services to be grouped based on spatial relationships, function, or both (The map view enables the user to focus on managed objects directly within their purview or interest.) Oracle8: Database Administration 2-11 Lesson 2: Using Administration Tools A job system that permits remote execution of tasks related to listeners, databases, or the host itself (The job system is based on the procedural Tool Control Language (TCL) engine.) An event system that monitors and reports on system status (The event system in conjunction with the job system will take corrective action based on predefined criteria and can advise the administrator by pager or electronic mail that a particular event has occurred.) 2-12 Oracle8: Database Administration OEM Components OEM Common Services • Repository • Service Discovery • Security 2-9 Copyright © Oracle Corporation, 1998 All rights reserved OEM Services There are three services commonly provided through the OEM console: • Repository • Service Discovery • Security Repository The OEM Repository is a set of tables in any database accessible to the console which is automatically created or upgraded when you start the console Each administrator uses a specific repository The repository provides: • A centralized location for storing information about the state of the environment managed by OEM from the perspective of each console user • Information on jobs and events • The preferred credentials for the user • Other information associated with each OEM Console login Oracle8: Database Administration 2-13 Lesson 2: Using Administration Tools Note If the repository does not exist, it is automatically created and a dialog box informs you of the operation If the repository exists, the version must be compatible with the console If the existing Enterprise Manager Repository version is older than the Oracle Enterprise Manager Console version, the existing repository will be upgraded automatically and a dialog box informs you of the upgrade Service Discovery The Service Discovery feature provides wizards for identifying network services and populating the Navigator tree These services, such as databases and listeners, can be administered with OEM components Note • Use the Discover New Services and Refresh Services wizards for nodes that have the Intelligent Agent release 7.3.3 or higher running If you add services to these nodes, you must restart the agent on the nodes before discovering the new services with the Discovery wizard option • If a node is successfully discovered, it is set to automatic refresh mode in the Refresh Nodes page of the Refresh Services wizard All nodes that are not successfully discovered are automatically retried unless they are removed from the Retry Nodes page Security Access to Oracle Services on the network is controlled by a set of user defined preferred credentials for each of the managed services This feature enables you to set up specific usernames, passwords, and roles for different services in your network These preferences are used when you access a database, listener, or node in the navigator or map This information is also passed to a DBA tool when a tool is executed on a selected database OEM caches the user authentication information in an encrypted form in the OEM Repository and provides it as part of the connection request from the OEM Console or applications launched from the console Note If the references have not been set up for a database, listener, or node, the login information that you entered to access the console is used when accessing that service If that information is not valid for a selected service, you have to enter new login information each time you access the object 2-14 Oracle8: Database Administration OEM Components OEM Database Administration Tools Components needing console 2-10 Copyright © Oracle Corporation, 1998 All rights reserved The standard applications that are supplied with OEM include the following: • Instance Manager: used to control database availability and define initialization parameters to specify the characteristics of the instance • Schema Manager: used to create and maintain objects such as tables, indexes, and views • Security Manager: used to manage users and privileges • Storage Manager: used to organize the database files and manage rollback segments • SQL Worksheet: a command line interface that can be used to run SQL commands, PL/SQL code, and Server Manager commands • Backup Manager: used to backup, restore, and recover databases, and to manage redo log files • Data Manager: used to load and reorganize data in databases Oracle8: Database Administration 2-15 Lesson 2: Using Administration Tools Note • All applications except Backup Manager and Data Manager can be invoked either from the console or directly from the operating system • This lesson discusses the application interface and the use of SQL Worksheet The use of these applications to perform specific tasks is covered in respective lessons throughout the course • The use of Backup Manager to backup, restore, and recover databases is discussed in the course Oracle8: Backup and Recovery 2-16 Oracle8: Database Administration OEM Components OEM Performance Pack 2-11 Copyright © Oracle Corporation, 1998 All rights reserved A brief description of the components in the OEM Performance Pack are presented in this section Performance Manager • Provides a graphical view of database and system performance • Charts real time performance data • Records performance data for later analysis • Contains a predefined set of performance charts • Enables you to design your own custom charts Top-Session Monitor • Lists sessions in descending order of system resource use • Displays detailed information for each session, such as session and system statistics, locks held and requested, open cursors, and execution plans • Enables you to kill sessions Oracle8: Database Administration 2-17 Lesson 2: Using Administration Tools Lock Manager • Provides a graphical view of the locking activity • Includes information about locks held and requested • Enables you to kill sessions Advanced Events These are a set of space management, resource use, and performance event definitions that extend the OEM Event Management system Tablespace Manager • Includes a segment map that graphically displays database space usage • Enables you to easily match an object with its extents and a particular extent with its object • Defragments tables by automatically exporting and importing them • Enables you to manually coalesce adjacent free space Trace • Collects performance data for the database, Net8, and applications • Provides a graphical interface for managing Trace collection data Expert • Can tune an existing system • Enables you to evaluate a planned configuration before it is implemented • Enables you to experiment with changes to your existing system • Provides you with detailed information about its tuning recommendations and generates reports for reference and documentation Note The terms tablepace, segment, extent, and free space will be discussed in subsequent lessons 2-18 Oracle8: Database Administration Using Oracle Enterprise Manager Using Oracle Enterprise Manager Starting and Using OEM • Create repository automatically by invoking OEM • Define services – Auto discovery – Manual • Set up security using preferred credentials • Use the navigator and launch palette to invoke applications 2-12 Copyright © Oracle Corporation, 1998 All rights reserved Creating the Repository Before you can use the OEM Console, you need to connect to the database that contains the repository The database can reside on any node that is accessible to the console The user account that contains the repository should have DBA privileges The repository gets created automatically when you connect to an account on an Oracle database for the first time To start the console, use the following steps: Choose Start—>Programs menu Select Enterprise Manager You can also start the console (voc.exe) from the MS-DOS prompt: voc.exe user=system password=manager service=U15 Oracle8: Database Administration 2-19 Lesson 2: Using Administration Tools Define Services After the console is running, the user needs to populate the navigator tree with the nodes and services This can be performed automatically if the machine running a service has the intelligent agent running Alternatively the service can be defined manually All discovered services can be viewed through the navigator tree Note Service discovery is discussed in detail in the course Oracle Enterprise Manager Set Up Security The usernames and passwords to access various services in a network can be stored in the repository by setting up preferred credentials To set up preferred credentials, use the following steps: Choose File—>Preferences In the User Preferences property sheet, enter the username, password and role for accessing a database, node, or listener Click OK Invoke Applications To start an application and connect to a database using preferred credentials, perform the following steps: • In the navigator, expand the Databases folder • Select the appropriate database • Click the application icon in the launch palette, or Select Tools—>Applications and the name of the application from the menu If the connection is successful the application window displays If a database connection cannot be made, the connect dialog box displays Instructor Note Invoke OEM Console, and demonstrate the following: • Use Navigator—>Service Discovery and show one of the following: - Auto discovery - Refreshing of a service - Manual definition of a service Auto discovery and Refreshing are possible only if the agent is running on the node • Set up preferred credentials for the database discovered or defined in the previous step • Use the launch palette or menu to invoke Schema Manager 2-20 Oracle8: Database Administration Using Oracle Enterprise Manager Using Application Interface 2-13 Copyright © Oracle Corporation, 1998 All rights reserved When a successful connection to a database is established using one of the applications, the navigator displays the objects managed through the application Most applications use a standard toolbar containing icons to set options and perform specific actions Some of the most commonly used objects in the user interface are discussed below: Property Sheet: displays in the pane on the right hand side of the window (The properties displayed depend on the object selected in the navigator For example, if a table is selected in the navigator of the Schema Manager, the column details and other information are displayed in the property sheet.) Page: Property sheets are organized into pages, and each page displays a set of related properties For example, the property sheet for a table consists of separate pages for general information (that includes column details) and constraints Buttons: enable operations such as Create, Create Like, and Delete to be performed Oracle8: Database Administration 2-21 Lesson 2: Using Administration Tools Note An Advanced Mode button (see in the screenshot) is a toggle that controls the number of pages displayed Only the General page is displayed in most cases if the Advanced Mode is not activated Instructor Note Demonstrate the following using the Schema Manager: • Use Object—>Create in the menu to create a new table Point to the Create icon, and inform the students that the same action can be performed using the toolbar • Select the table just created and demonstrate the use of Create Like using the toolbar • Demonstrate the use of the Advanced Mode button by selecting the table created in the preceding step • Use the Constraints page to show the creation of a Primary Key constraint Click on the Show SQL button to display the SQL statement that is generated 2-22 Oracle8: Database Administration Using Oracle Enterprise Manager Using SQL Worksheet 2-14 Copyright © Oracle Corporation, 1998 All rights reserved SQL Worksheet enables administrators to dynamically enter SQL statements, PL/SQL code, and Server Manager commands Some of the components of SQL Worksheet, and their uses are outlined below: Output pane: appears at the top of the window and is used to display the results and messages in response to commands Input pane: at the bottom of the window is used by the user to enter commands or PL/SQL code Execute icon: after a command is entered, click this icon to run the command Command history icon: is used to display a list of the most recently executed commands from the buffer, and retrieve, edit, and execute one or more of them SQL Worksheet also has menu options to save commands to scripts, to retrieve, and to run scripts Oracle8: Database Administration 2-23 Lesson 2: Using Administration Tools Summary Summary • Using Server Manager in Line Mode • Using Oracle Enterprise Manager components 2-15 Copyright © Oracle Corporation, 1998 All rights reserved Quick Reference Context Initialization parameters Dynamic performance views Data dictionary views Commands Reference None None None svrmgrl svrmgr30.exe SERVER MANAGER line mode commands Packaged procedures and functions voc.exe None Instructor Note (Refer to previous page.) Demonstrate the following using SQL Worksheet: • Invoke SQL Worksheet from the Windows Start menu • Retrieve the script scott.sql from the LABS subdirectory, and execute it • Notice that this script sets echo to Off Show how to set echo to On • Use SELECT * FROM scott.emp and show the results • Run a query to retrieve all rows from SCOTT.DEPT Show the use of Command History Retrieve and execute the query on SCOTT.EMP 2-24 Oracle8: Database Administration ... 2 -14 Oracle8 : Database Administration OEM Components OEM Database Administration Tools Components needing console 2 -10 Copyright © Oracle Corporation, 19 98 All rights... generated 2- 22 Oracle8 : Database Administration Using Oracle Enterprise Manager Using SQL Worksheet 2 -14 Copyright © Oracle Corporation, 19 98 All rights reserved... recover databases is discussed in the course Oracle8 : Backup and Recovery 2 -16 Oracle8 : Database Administration OEM Components OEM Performance Pack 2 -11 Copyright