iiiContents 1 Introduction Objectives 1-2 Course Objectives 1-3 Suggested Schedule 1-4 Oracle Database Innovation 1-5 Enterprise Cloud Computing 1-6 Course Examples: HR Sample Schema 1-7 Summary 1-8 2 Exploring Oracle Database Architecture Objectives 2-2 Oracle Database Server Architecture: Overview 2-3 Oracle Database Instance Configurations 2-4 Connecting to the Database Instance 2-5 Oracle Database Memory Structures 2-6 Shared Pool 2-8 Database Buffer Cache 2-10 Redo Log Buffer 2-11 Large Pool 2-12 Java Pool 2-13 Streams Pool 2-14 Program Global Area (PGA) 2-15 Quiz 2-16 Process Architecture 2-18 Process Structures 2-20 Database Writer Process (DBWn) 2-22 Log Writer Process (LGWR) 2-24 Checkpoint Process (CKPT) 2-26 System Monitor Process (SMON) 2-27 Process Monitor Process (PMON) 2-28 Recoverer Process (RECO) 2-29 Listener Registration Process (LREG) 2-30 Archiver Processes (ARCn) 2-31 Database Storage Architecture 2-32 Logical and Physical Database Structures 2-34
ivSegments, Extents, and Blocks 2-36 Tablespaces and Data Files 2-37 SYSTEM and SYSAUX Tablespaces 2-38 Oracle Container Database: Introduction 2-39 Multitenant Architecture 2-40 Automatic Storage Management 2-41 ASM Storage Components 2-42 Interacting with an Oracle Database: Memory, Processes, and Storage 2-43 Quiz 2-45 Summary 2-47 Practice Overview 2-48 3 Oracle Database Management Tools Objectives 3-2 Oracle Database Management Tools: Introduction 3-3 Using SQL*Plus 3-4 Calling SQL*Plus from a Shell Script 3-5 Calling a SQL Script from SQL*Plus 3-6 Oracle SQL Developer: Connections 3-7 Oracle SQL Developer: DBA Actions 3-8 Oracle Enterprise Manager Database Express Architecture 3-9 Configuring Enterprise Manager Database Express 3-10 Logging In to Oracle Enterprise Manager Database Express 3-11 Using the Database Home Page 3-12 Using Enterprise Manager Database Express Menus 3-13 Oracle Enterprise Manager Cloud Control Components 3-14 Controlling the Enterprise Manager Cloud Control Framework 3-15 Starting the Enterprise Manager Cloud Control Framework 3-16 Stopping the Enterprise Manager Cloud Control Framework 3-17 Types of Enterprise Manager Cloud Control Targets 3-18 Enterprise Manager Cloud Control 3-19 Using Enterprise Manager Cloud Control 3-20 Quiz 3-21 Summary 3-22 Practice Overview 3-23 4 Managing the Database Instance Objectives 4-2 Initialization Parameter Files 4-3 Types of Initialization Parameters 4-5 Initialization Parameters: Examples 4-6
v Using SQL*Plus to View Parameters 4-10 Changing Initialization Parameter Values 4-13 Changing Parameter Values: Examples 4-15 Quiz 4-16 Starting Up an Oracle Database Instance: NOMOUNT 4-17 Starting Up an Oracle Database Instance: MOUNT 4-18 Starting Up an Oracle Database Instance: OPEN 4-19 Startup Options: Examples 4-20 Shutdown Modes 4-21 Shutdown Options 4-22 Shutdown Options: Examples 4-25 Viewing the Alert Log 4-26 Using Trace Files 4-28 Administering the DDL Log File 4-30 Understanding the Debug Log File 4-31 Using Dynamic Performance Views 4-32 Dynamic Performance Views: Usage Examples 4-33 Dynamic Performance Views: Considerations 4-34 Data Dictionary: Overview 4-35 Data Dictionary Views 4-36 Data Dictionary: Usage Examples 4-39 Quiz 4-40 Summary 4-41 Practice Overview 4-42 5 Configuring the Oracle Network Environment Objectives 5-2 Oracle Net Services: Overview 5-3 Oracle Net Listener: Overview 5-4 Establishing Oracle Network Connections 5-5 Connecting to an Oracle Database 5-6 Name Resolution 5-7 Establishing a Connection 5-8 User Sessions 5-9 Naming Methods 5-11 Easy Connect 5-12 Local Naming 5-13 Directory Naming 5-14 External Naming Method 5-15 Tools for Configuring and Managing Oracle Net Services 5-16 Defining Oracle Net Services Components 5-17
viUsing Enterprise Manager Cloud Control 5-18 Using Oracle Net Manager 5-19 Using Oracle Net Configuration Assistant 5-20 Using the Listener Control Utility 5-21 Listener Control Utility Syntax 5-22 Advanced Connection Options 5-24 Testing Oracle Net Connectivity 5-26 Comparing Dedicated Server and Shared Server Configurations 5-27 User Sessions: Dedicated Server Process 5-28 User Sessions: Shared Server Processes 5-29 SGA and PGA Usage 5-30 Shared Server Configuration Considerations 5-31 Configuring Communication Between Databases 5-32 Connecting to Another Database 5-33 Quiz 5-34 Summary 5-36 Practice Overview 5-37 6 Administering User Security Objectives 6-2 Database User Accounts 6-3 Predefined Administrative Accounts 6-5 Administrative Privileges 6-6 Protecting Privileged Accounts 6-7 Authenticating Users 6-8 Administrator Authentication 6-10 OS Authentication and OS Groups 6-11 Managing Users 6-13 Creating a User 6-14 Unlocking a User Account and Resetting the Password 6-15 Privileges 6-16 System Privileges 6-17 Revoking System Privileges with ADMIN OPTION 6-19 Granting Object Privileges 6-20 Object Privileges 6-21 Revoking Object Privileges with GRANT OPTION 6-22 Using Roles to Manage Privileges 6-23 Assigning Privileges to Roles and Assigning Roles to Users 6-24 Predefined Roles 6-25 Creating a Role 6-26 Secure Roles 6-27
vii Assigning Roles to Users 6-28 Privilege Analysis 6-29 Privilege Analysis Flow 6-30 Profiles and Users 6-31 Implementing Password Security Features 6-33 Creating a Password Profile 6-35 Supplied Password Verification Functions 6-36 Modifications to the Default Profile 6-37 Assigning Quotas to Users 6-38 Applying the Principle of Least Privilege 6-40 Quiz 6-42 Summary 6-46 Practice Overview 6-47 7 Managing Database Storage Structures Objectives 7-2 How Table Data Is Stored 7-3 Database Block: Contents 7-4 Exploring the Storage Structure 7-5 Creating a New Tablespace 7-6 Overview of Tablespaces Created by Default 7-12 Altering a Tablespace 7-14 Adding a Data File to a Tablespace 7-16 Making Changes to a Data File 7-17 Dropping Tablespaces 7-18 Viewing Tablespace Information 7-19 Oracle Managed Files (OMF) 7-20 Quiz 7-22 Enlarging the Database 7-23 Moving or Renaming an Online Data File 7-24 Summary 7-26 Practice Overview 7-27 8 Managing Space Objectives 8-2 Space Management: Overview 8-3 Block Space Management 8-4 Row Chaining and Migration 8-5 Quiz 8-7 Free Space Management Within Segments 8-8 Types of Segments 8-9
viii Allocating Extents 8-10 Understanding Deferred Segment Creation 8-11 Viewing Deferred Segment Information 8-12 Controlling Deferred Segment Creation 8-13 Restrictions and Exceptions 8-14 Additional Automatic Functionality 8-15 Quiz 8-16 Table Compression: Overview 8-17 Compression for Direct-Path Insert Operations 8-18 Advanced Row Compression for DML Operations 8-20 Specifying Table Compression 8-21 Using the Compression Advisor 8-22 Using the DBMS_COMPRESSION Package 8-23 Proactive Tablespace Monitoring 8-24 Thresholds and Resolving Space Problems 8-25 Monitoring Tablespace Space Usage 8-26 Shrinking Segments 8-27 Results of Shrink Operation 8-28 Reclaiming Space Within ASSM Segments 8-29 Using the Segment Advisor 8-30 Automatic Segment Advisor 8-31 Shrinking Segments by Using SQL 8-32 Shrinking Segments by Using Enterprise Manager 8-33 Managing Resumable Space Allocation 8-34 Using Resumable Space Allocation 8-35 Resuming Suspended Statements 8-37 What Operations Are Resumable? 8-39 Quiz 8-40 Summary 8-41 Practice Overview 8-42 9 Managing Undo Data Objectives 9-2 Undo Data: Overview 9-3 Transactions and Undo Data 9-5 Storing Undo Information 9-6 Comparing Undo Data and Redo Data 9-7 Managing Undo 9-8 Configuring Undo Retention 9-9 Categories of Undo 9-10 Guaranteeing Undo Retention 9-11
ixChanging an Undo Tablespace to a Fixed Size 9-12 Temporary Undo: Overview 9-13 Temporary Undo: Benefits 9-14 Enabling Temporary Undo 9-15 Monitoring Temporary Undo 9-16 Viewing Undo Information 9-17 Viewing Undo Activity 9-18 Using the Undo Advisor 9-19 Quiz 9-20 Summary 9-21 Practice Overview 9-22 10 Managing Data Concurrency Objectives 10-2 Locks 10-3 Locking Mechanism 10-4 Data Concurrency 10-5 DML Locks 10-7 Enqueue Mechanism 10-8 Lock Conflicts 10-9 Possible Causes of Lock Conflicts 10-10 Detecting Lock Conflicts 10-11 Resolving Lock Conflicts 10-12 Resolving Lock Conflicts by Using SQL 10-13 Deadlocks 10-14 Quiz 10-15 Summary 10-17 Practice Overview 10-18 11 Implementing Oracle Database Auditing Objectives 11-2 Database Security 11-3 Monitoring for Compliance 11-5 Types of Activities to be Audited 11-6 Mandatorily Audited Activities 11-7 Understanding Auditing Implementation 11-8 Administering the Roles Required for Auditing 11-9 Database Auditing: Overview 11-10 Understanding the Audit Architecture 11-11 Enabling Unified Auditing 11-12 Configuring Auditing 11-13
x Using Enterprise Manager Cloud Control 11-14 Creating a Unified Audit Policy 11-15 Creating an Audit Policy: System-Wide Audit Options 11-16 Creating an Audit Policy: Object-Specific Actions 11-17 Creating an Audit Policy: Specifying Conditions 11-18 Enabling and Disabling Audit Policies 11-19 Altering a Unified Audit Policy 11-20 Viewing Audit Policy Information 11-21 Setting the Write Mode for Audit Trail Records 11-22 Value-Based Auditing 11-23 Fine-Grained Auditing 11-25 FGA Policy 11-26 Audited DML Statement: Considerations 11-28 FGA Guidelines 11-29 Archiving and Purging the Audit Trail 11-30 Purging Audit Trail Records 11-31 Quiz 11-32 Summary 11-33 Practice Overview 11-34 12 Backup and Recovery: Concepts Objectives 12-2 DBA Responsibilities 12-3 Categories of Failure 12-5 Statement Failure 12-6 User Process Failure 12-7 Network Failure 12-8 User Error 12-9 Flashback Technology 12-10 Instance Failure 12-12 Understanding Instance Recovery: Checkpoint (CKPT) Process 12-13 Understanding Instance Recovery: Redo Log Files and Log Writer 12-14 Understanding Instance Recovery 12-15 Phases of Instance Recovery 12-16 Tuning Instance Recovery 12-17 Using the MTTR Advisor 12-18 Media Failure 12-19 Comparing Complete and Incomplete Recovery 12-20 Complete Recovery Process 12-21 Point-in-Time Recovery Process 12-22 Oracle Data Protection Solutions 12-24
xiQuiz 12-25 Summary 12-26 13 Backup and Recovery: Configuration Objectives 13-2 Configuring for Recoverability 13-3 Configuring the Fast Recovery Area 13-4 Monitoring the Fast Recovery Area 13-5 Multiplexing Control Files 13-6 Redo Log Files 13-8 Multiplexing the Redo Log 13-9 Creating Archived Redo Log Files 13-10 Archiver (ARCn) Process 13-11 Archived Redo Log Files: Naming and Destinations 13-12 Configuring ARCHIVELOG Mode 13-14 Quiz 13-15 Summary 13-16 Practice Overview 13-17 14 Performing Database Backups Objectives 14-2 Backup Solutions: Overview 14-3 Oracle Secure Backup 14-4 User-Managed Backup 14-5 Understanding Backup Terminology 14-6 Understanding Types of Backups 14-7 RMAN Backup Types 14-8 Using Recovery Manager (RMAN) 14-10 Configuring Backup Settings 14-11 Oracle-Suggested Backup 14-13 Selecting a Backup Strategy 14-14 Backing Up the Control File to a Trace File 14-15 Managing Backups 14-16 Using RMAN Commands to Create Backups 14-17 Quiz 14-18 Summary 14-19 Practice Overview 14-20 15 Performing Database Recovery Objectives 15-2 Opening a Database 15-3
xii Keeping a Database Open 15-5 Data Recovery Advisor 15-6 Loss of a Control File 15-8 Loss of a Redo Log File 15-9 Loss of a Data File in NOARCHIVELOG Mode 15-11 Loss of a Noncritical Data File in ARCHIVELOG Mode 15-12 Loss of a System-Critical Data File in ARCHIVELOG Mode 15-13 Quiz 15-14 Summary 15-15 Practice Overview 15-16 16 Moving Data Objectives 16-2 Moving Data: General Architecture 16-3 Oracle Data Pump: Overview 16-4 Oracle Data Pump: Benefits 16-5 Directory Objects for Data Pump 16-7 Creating Directory Objects 16-8 Data Pump Export and Import Clients: Overview 16-9 Data Pump Utility: Interfaces and Modes 16-10 Performing a Data Pump Export by Using Enterprise Manager Cloud Control 16-11 Performing a Data Pump Import 16-12 Data Pump Import: Transformations 16-13 Using Enterprise Manager Cloud Control to Monitor Data Pump Jobs 16-14 SQL*Loader: Overview 16-15 SQL*Loader Control File 16-17 Loading Methods 16-19 Loading Data by Using Enterprise Manager Cloud Control 16-20 SQL*Loader Express Mode 16-21 External Tables 16-23 External Table: Benefits 16-24 Defining an External Tables with ORACLE_LOADER 16-25 External Table Population with ORACLE_DATAPUMP 16-26 Using External Tables 16-27 Data Dictionary 16-28 Quiz 16-29 Summary 16-31 Practice Overview 16-32 17 Database Maintenance Objectives 17-2
xiii Database Maintenance 17-3 Viewing the Alert History 17-4 Terminology 17-5 Automatic Workload Repository (AWR): Overview 17-6 AWR Infrastructure 17-7 Automatic Workload Repository 17-8 AWR Baselines 17-10 Accessing the AWR Page 17-11 Managing the AWR 17-12 Statistic Levels 17-13 Automatic Database Diagnostic Monitor (ADDM) 17-14 ADDM Findings in Enterprise Manager Cloud Control 17-15 ADDM Findings in Enterprise Manager Database Express 17-16 Advisory Framework 17-17 Viewing the Advisor Central Page in Enterprise Manager Cloud Control 17-19 Using Packages to Invoke the Advisors 17-20 Automated Maintenance Tasks 17-21 Automated Maintenance Tasks Configuration 17-23 Server-Generated Alerts 17-24 Setting Metrics Thresholds 17-25 Reacting to Alerts 17-26 Alert Types and Clearing Alerts 17-27 Quiz 17-28 Summary 17-29 Practice: Overview 17-30 18 Managing Performance Objectives 18-2 Performance Monitoring 18-3 Tuning Activities 18-5 Performance Planning 18-6 Instance Tuning 18-8 Performance Tuning Methodology 18-9 Performance Tuning Data 18-10 Using the Enterprise Manager Database Express Performance Hub Page 18-11 Using the Enterprise Manager Cloud Control Performance Home Page 18-13 Monitoring Session Performance 18-14 Performance Monitoring: Top Sessions 18-15 Displaying Session-Related Statistics 18-16 Performance Monitoring: Top Services 18-17 Displaying Service-Related Statistics 18-18
xiv Viewing Wait Events 18-19 Oracle Wait Events 18-20 Memory Management: Overview 18-21 Managing Memory Components 18-22 Efficient Memory Usage: Guidelines 18-23 Automatic Memory Management: Overview 18-25 Oracle Database Memory Parameters 18-26 Enabling Automatic Memory Management (AMM) by Using Enterprise Manager Cloud Control 18-27 Monitoring Automatic Memory Management 18-28 Automatic Shared Memory Management: Overview 18-30 Enabling Automatic Shared Memory Management (ASMM) 18-31 Understanding Automatic Shared Memory Management 18-32 Automatic Shared Memory Advisor 18-33 Enabling Automatic Shared Memory Management 18-34 Disabling Automatic Shared Memory Management 18-35 Using V$PARAMETER to View Memory Component Sizes 18-36 Managing the Program Global Area (PGA) 18-37 Dynamic Performance Statistics 18-39 Troubleshooting and Tuning Views 18-41 Quiz 18-42 Summary 18-44 Practice: Overview 18-45 19 Managing Performance: SQL Tuning Objectives 19-2 SQL Tuning 19-3 Oracle Optimizer: Overview 19-4 Optimizer Statistics 19-5 Optimizer Statistics Collection 19-6 Using the Manage Optimizer Statistics Page 19-8 Setting Global Preferences by Using Enterprise Manager Cloud Control 19-9 Gathering Optimizer Statistics Manually 19-10 Setting Optimizer Statistics Preferences 19-12 Concurrent Statistics Gathering 19-14 Viewing Statistics Information 19-15 SQL Plan Directives 19-17 Adaptive Execution Plans 19-18 Using the SQL Advisors 19-19 Automatic SQL Tuning Results 19-20 Implementing Automatic Tuning Recommendations 19-21
xv SQL Tuning Advisor: Overview 19-22 Using the SQL Tuning Advisor 19-23 SQL Tuning Advisor Recommendations 19-25 Duplicate SQL 19-26 SQL Access Advisor: Overview 19-27 Using the SQL Access Advisor 19-28 Workload Source 19-29 Recommendation Options 19-30 Reviewing Recommendations 19-32 SQL Performance Analyzer: Overview 19-33 SQL Performance Analyzer: Use Cases 19-34 Using SQL Performance Analyzer 19-35 Quiz 19-36 Summary 19-40 Practice: Overview 19-41 20 Using Database Resource Manager Objectives 20-2 Database Resource Manager: Overview 20-3 Database Resource Manager: Concepts 20-4 Using the Resource Manager 20-5 Default Plan for Maintenance Windows 20-7 Default Plan 20-8 Creating a Simple Resource Plan 20-9 Creating a Complex Resource Plan 20-10 Specifying Resource Plan Directives 20-12 Resource Allocation Methods for Resource Plans 20-13 Comparison of EMPHASIS and RATIO 20-14 Active Session Pool Mechanism 20-16 Specifying Thresholds 20-17 Setting Idle Timeouts 20-19 Limiting CPU Utilization at the Database Level 20-20 Limiting CPU Utilization at the Server Level: Instance Caging 20-22 Instance Caging Examples 20-23 Monitoring Instance Caging 20-24 Runaway Queries and Resource Manager 20-25 Resource Consumer Group Mapping 20-27 Activating a Resource Plan 20-29 Database Resource Manager Information 20-30 Viewing Resource Manager Statistics 20-31 Monitoring the Resource Manager 20-32
xvi Quiz 20-34 Summary 20-35 Practice: Overview 20-36 21 Using Oracle Scheduler to Automate Tasks Objectives 21-2 Simplifying Management Tasks 21-3 Understanding a Simple Job 21-4 Oracle Scheduler Core Components 21-5 Using Oracle Scheduler 21-6 Quiz 21-8 Persistent Lightweight Jobs 21-9 Using a Time-Based or Event-Based Schedule 21-10 Creating a Time-Based Job 21-11 Creating an Event-Based Schedule 21-13 Creating Event-Based Schedules by Using Enterprise Manager Cloud Control 21-14 Creating an Event-Based Job 21-15 Event-Based Scheduling 21-16 Creating Complex Schedules 21-18 Quiz 21-19 Using Email Notification 21-20 Adding and Removing Email Notifications 21-21 Creating Job Chains 21-22 Example of a Chain 21-24 Using Advanced Scheduler Features 21-25 Job Classes 21-26 Windows 21-28 Prioritizing Jobs Within a Window 21-29 Creating a Job Array 21-30 Quiz 21-32 Creating a File Watcher and an Event-Based Job 21-33 Enabling File Arrival Events from Remote Systems 21-35 Scheduling Remote Database Jobs 21-36 Creating Remote Database Jobs 21-37 Scheduling Multiple Destination Jobs 21-38 Viewing Scheduler Meta Data 21-39 Quiz 21-41 Summary 21-42 Practice: Overview 21-43
xvii A Working with Oracle Support Objectives A-2 Working with Oracle Support A-3 Using My Oracle Support A-4 Researching an Issue A-6 Logging Service Requests A-8 Accessing My Oracle Support Community A-10 Managing Patches A-11 Applying a Patch Release A-12 Enterprise Manager Cloud Control: My Oracle Support Integration A-13 Using the Patch Advisor A-14 Online Patching: Overview A-15 Installing an Online Patch A-16 Benefits of Online Patching A-17 Conventional Patching and Online Patching A-18 Online Patching Considerations A-19 Quiz A-20 Using the Support Workbench A-21 Accessing the Support Workbench A-22 Viewing Problem Details A-23 Viewing Incident Details A-24 Packaging and Uploading Diagnostic Data to Oracle Support A-25 Tracking the Service Request and Implementing Repairs A-26 Summary A-27 B Basic Linux and vi Commands
Oracle Database 12c: Administration Workshop 12 - 4•Minimizes the loss of data. DBAs who follow accepted best practices can configure their databases so that no committed transaction is ever lost. Entities that assist in guaranteeing this include:-Archive log files (discussed later in this lesson)-Flashback technology-Standby databases and Oracle Data Guard (discussed in the Oracle Database 12c: Data Guard Administrationcourse)
Oracle Database 12c: Administration Workshop 12 - 11•Flashback Drop:Reverses the effects of dropping a table by returning the dropped table from the recycle bin to the database along with dependent objects such as indexes and triggers•Flashback Database:Returns the database to a past time or SCN
5.Apply undo data:While the redo was being applied, redo supporting the undo data files was also applied. So the undo is available to be applied to the data files in order to undo any uncommitted transactions. That is done next.6.Process complete:The data files are now recovered to the point in time that you chose.Oracle Flashback Database is the most efficient alternative to DBPITR. Unlike the other flashback features, it operates at a physical level and reverts the current data files to their contents at a past time. The result is like the result of a DBPITR, including the OPEN RESETLOGS, but Flashback Database is typically faster because it does not require you to restore data files and requires only limited application of redo compared to media recovery.Oracle Database 12c: Administration Workshop 12 - 23
Oracle Database 12c: Administration Workshop 13 - 7Adding a Control FileIf you are using ASM as your storage technique, then as long as you have two control files, one in each disk group (such as +DATA and +FRA), then you should not require further multiplexing. In a database using Oracle Managed Files (OMF)—such as a database using ASM storage—all additional control files must be created as part of a recovery process using RMAN (or through Enterprise Manager). In a database using regular file system storage, adding a control file is a manual operation: 1.Alter the SPFILE with the following command specifying the appropriate location of your files: ALTER SYSTEM SET control_files = '/u01/app/oracle/oradata/orcl/control01.ctl' , '/u02/app/oracle/oradata/orcl/control02.ctl' , '/u03/app/oracle/oradata/orcl/control03.ctl' SCOPE=SPFILE; 2.Shut down the database instance.3.Use an operating system command to copy an existing control file to the location you select for your new file.4.Open the database.Note:More information about using RMAN is provided in the Oracle Database 12c: Backup and Recovery Workshop and in product documentation.
Click Add Another Row to add further destinations. To change recovery settings, you must be connected as SYSDBA, SYSOPER, or SYSBACKUP.Note: If you do not want archives sent to this location, delete USE_DB_RECOVERY_FILE_DEST.Oracle Database 12c: Administration Workshop 13 - 13
RMAN can create multilevel incremental backups as follows:•Differential:Is the default type of incremental backup that backs up all blocks changed after the most recent incremental backup at either level 1 or level 0•Cumulative:Backs up all blocks changed after the most recent backup at level 0Examples •To perform an incremental backup at level 0, use the following command:RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;•To perform a differential incremental backup, use the following command:RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;•To perform a cumulative incremental backup, use the following command: RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;RMAN makes full backups by default if neither FULLnor INCREMENTALis specified. Unused block compression causes never-written blocks to be skipped when backing up data files to backup sets, even for full backups. A full backup has no effect on subsequent incremental backups, and is not considered part of any incremental backup strategy, although a full image copy backup can be incrementally updated by applying incremental backups with the RECOVERcommand.Note:It is possible to perform any type of backup (full or incremental) of a database that is in NOARCHIVELOGmode—if, of course, the database is not open. Note also that recovery is limited to the time of the last backup. The database can be recovered to the last committed transaction only when the database is in ARCHIVELOGmode. Oracle Database 12c: Administration Workshop 14 - 9
Oracle Database 12c: Administration Workshop 15 - 4-Verifies that all data files known to the control file are present unless they have been taken offline. Offline files are not checked until the administrator tries to bring them online. The administrator may take a data file offline and open the instance if the data file does not belong to the SYSTEMor UNDOtablespaces. If any files are missing, an error noting the first missing file is returned to the administrator and the instance remains in the MOUNTstate. When the instance finds files that are missing, only the first file causing a problem appears in the error message. To find all files that need recovery, the administrator can check the v$recover_filedynamic performance view to get a complete list of the files that need attention:SQL> startupORACLE instance started.Total System Global Area 171966464 bytesFixed Size 775608 bytesVariable Size 145762888 bytesDatabase Buffers 25165824 bytesRedo Buffers 262144 bytesDatabase mounted.ORA-01157: cannot identify/lock data file 4 - see DBWR trace fileORA-01110: data file 4: '/oracle/oradata/orcl/users01.dbf'SQL> SELECT name, error2 FROM v$datafile3 JOIN v$recover_file4 USING (file#);NAME ERROR----------------------------------- ------------------/oracle/oradata/orcl/users01.dbf FILE NOT FOUND/oracle/oradata/orcl/example01.dbf FILE NOT FOUND-Verifies that all data files that are not offline or read-only are synchronized with the control file. If necessary, instance recovery is automatically performed. However, if a file is out of synchronization to the extent that it cannot be recovered by using the online redo log groups, then the administrator must perform media recovery. If any files require media recovery, an error message noting the first file requiring recovery is returned to the administrator and the instance remains in the MOUNTstate:ORA-01113: file 4 needs media recoveryORA-01110: data file 4: '/oracle/oradata/orcl/users01.dbf'Again, v$recover_filegives a complete list of files that need attention. Files that are present and require media recovery are listed, but no error message is displayed.
Oracle Database 12c: Administration Workshop 15 - 7User InterfacesThe Data Recovery Advisor is available in Enterprise Manager Cloud Control. When failures exist, there are several ways to access the Data Recovery Advisor. You can also use the Data Recovery Advisor by using the RMAN command line: rman target / rman> list failure all;Supported Database ConfigurationsIn the current release, the Data Recovery Advisor supports single-instance databases. Oracle Real Application Clusters databases are not supported.The Data Recovery Advisor cannot use blocks or files transferred from a standby database to repair failures on a primary database. Furthermore, you cannot use the Data Recovery Advisor to diagnose and repair failures on a standby database. However, the Data Recovery Advisor does support failover to a standby database as a repair option (as mentioned previously).
Oracle Database 12c: Administration Workshop 15 - 10Note:Enterprise Manager does not allow you to clear a log group that has not been archived. Doing so breaks the chain of redo information. If you must clear an unarchived log group, you should immediatelytake a full backup of the whole database. Failure to do so may result in a loss of data if another failure occurs. To clear an unarchived log group, use the following command:ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP <integer>
Oracle Database 12c: Administration Workshop 16 - 6Features of Data Pump enable you to:•Compress both data and metadata, only data, only metadata, or no data during an export •Specify additional encryption options in the following areas:-You can choose to encrypt both data and metadata, only data, only metadata, no data, or only encrypted columns during an export.-You can specify a particular encryption algorithm to use during an export. -You can specify the type of security to use for performing encryption and decryption during an export. For example, perhaps the dump file set will be imported into a different or remote database and it must remain secure in transit. Or perhaps the dump file set will be imported on-site using the Oracle Encryption Wallet but it may also need to be imported off-site where the Oracle Encryption Wallet is not available. •Perform table mode exports and imports using the transportable method; specify how partitioned tables should be handled during import operations •Overwrite existing dump files during an export operation•Rename tables during an import operation •Specify that a data load should proceed even if nondeferred constraint violations are encountered (This is valid only for import operations that use the external tables access method.) •Specify that XMLType columns are to be exported in uncompressed CLOB format regardless of the XMLType storage format that was defined for them•During an export, specify a remap function that takes as a source the original value of the designated column and returns a remapped value that will replace the original value in the dump file •Remap data as it is being imported into a new database •Use legacy mode to support the use of original Export (exp) and Import (imp) scripts
Oracle Database 12c: Administration Workshop 16 - 16•The second section consists of one or more INTOTABLEblocks. Each of these blocks contains information about the table (such as the table name and the columns of the table) into which the data is to be loaded.•The third section is optional and, if present, contains input data.Log file:When SQL*Loader begins execution, it creates a log file. If it cannot create a log file, execution terminates. The log file contains a detailed summary of the load, including a description of any errors that occurred during the load.Bad file:The bad file contains records that are rejected, either by SQL*Loader or by the Oracle database. Data file records are rejected by SQL*Loader when the input format is invalid. After a data file record is accepted for processing by SQL*Loader, it is sent to the Oracle database for insertion into a table as a row. If the Oracle database determines that the row is valid, the row is inserted into the table. If the row is determined to be invalid, the record is rejected and SQL*Loader puts it in the bad file.Discard file:This file is created only when it is needed and only if you have specified that a discard file should be enabled. The discard file contains records that are filtered out of the load because they do not match any record-selection criteria specified in the control file.For more information about SQL*Loader, see the Oracle Database Utilities guide.
Oracle Database 12c: Administration Workshop 16 - 181-- This is a sample control file2LOAD DATA3INFILE ’SAMPLE.DAT’4BADFILE ’sample.bad’5DISCARDFILE ’sample.dsc’6APPEND7INTO TABLE emp8WHEN (57) = ’.’9TRAILING NULLCOLS10(hiredate SYSDATE,deptno POSITION(1:2) INTEGER EXTERNAL(3)NULLIF deptno=BLANKS,job POSITION(7:14) CHAR TERMINATED BY WHITESPACENULLIF job=BLANKS "UPPER(:job)",mgr POSITION(28:31) INTEGER EXTERNALTERMINATED BY WHITESPACE, NULLIF mgr=BLANKS,ename POSITION(34:41) CHARTERMINATED BY WHITESPACE "UPPER(:ename)",empno POSITION(45) INTEGER EXTERNALTERMINATED BY WHITESPACE,sal POSITION(51) CHAR TERMINATED BY WHITESPACE"TO_NUMBER(:sal,’$99,999.99’)",comm INTEGER EXTERNAL ENCLOSED BY ’(’AND ’%’":comm * 100")The explanation of this sample control file (by line numbers) is as follows:1.Comments can appear anywhere in the command section of the file, but they must not appear in the data. Precede any comment with two hyphens. All text to the right of the double hyphen is ignored until the end of the line.2.The LOADDATAstatement indicates to SQL*Loader that this is the beginning of a new data load. If you are continuing a load that has been interrupted in progress, use the CONTINUELOADDATAstatement.3.The INFILEkeyword specifies the name of a data file containing data that you want to load.4.The BADFILEkeyword specifies the name of a file into which rejected records are placed.5.The DISCARDFILEkeyword specifies the name of a file into which discarded records are placed.6.The APPENDkeyword is one of the options that you can use when loading data into a table that is not empty. To load data into a table that is empty, use the INSERTkeyword.7.The INTOTABLEkeyword enables you to identify tables, fields, and data types. It defines the relationship between records in the data file and tables in the database.8.The WHENclause specifies one or more field conditions that each record must match before SQL*Loader loads the data. In this example, SQL*Loader loads the record only if the 57th character is a decimal point. That decimal point delimits dollars and cents in the field and causes records to be rejected if SALhas no value.9.The TRAILINGNULLCOLSclause prompts SQL*Loader to treat any relatively positioned columns that are not present in the record as null columns.10. The remainder of the control file contains the field list, which provides information about column formats in the table that is being loaded.
The following is an example of the input data file named test.datcontaining two records to load and excerpts of the two log files generated after the load completed. The table HR.TESTwas created with three columns, C1NUMBER, C2VARCHAR2(10), and C3VARCHAR2(10).$ more test.dat3 C WWW4 D UUU$ sqlldr hr TABLE=test$ more test.log…Express Mode Load, Table: TESTData File: test.datBad File: test_%p.bad …Table TEST, loaded from every logical record.Insert option in effect for this table: APPENDColumn Name Position Len Term Encl Datatype-------------------- ---------- ----- ---- ---- ---------C1 FIRST * , CHARACTER C2 NEXT * , CHARACTER C3 NEXT * , CHARACTER Generated control file for possible reuse:OPTIONS(EXTERNAL_TABLE=EXECUTE, TRIM=LRTRIM)LOAD DATA INFILE 'test' APPEND INTO TABLE TESTFIELDS TERMINATED BY "," ( C1, C2, C3)End of generated control file for possible reuse.…creating external table "SYS_SQLLDR_X_EXT_TEST"CREATE TABLE "SYS_SQLLDR_X_EXT_TEST" ("C1" NUMBER,"C2" CHAR(1),"C3" VARCHAR2(20)) ORGANIZATION external(TYPE oracle_loader DEFAULT DIRECTORY SYS_SQLLDR_XT_TMPDIR_00000ACCESS PARAMETERS ( RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCIIBADFILE 'SYS_SQLLDR_XT_TMPDIR_00000':'test_%p.bad'LOGFILE 'test_%p.log_xt'READSIZE 1048576FIELDS TERMINATED BY "," LRTRIM REJECT ROWS WITH ALL NULL FIELDS ("C1" CHAR(255),"C2" CHAR(255),"C3" CHAR(255)))location ('test.dat')) REJECT LIMIT UNLIMITEDexecuting INSERT statement to load database table TESTINSERT /*+ append parallel(auto) */ INTO TEST (C1, C2, C3) SELECT "C1", "C2", "C3" FROM "SYS_SQLLDR_X_EXT_TEST" …Table TEST: 2 Rows successfully loaded.Oracle Database 12c: Administration Workshop 16 - 22
Statspack is a bundled utility that provides a subset of the collection and reporting capability of the AWR. However, there is no supported path to migrate Statspack data into the workload repository. Also, the workload repository is not compatible with the Statspack schema. Statspack is not accessible through Enterprise Manager; it requires setup, and does not have automatic retention settings, or automatic purge. The Statspack utility does provide scripts for setup, automatic snapshot collection, and reporting. Statspack snapshots can be marked for retention, as part of a Statspack baseline, or purged with provided scripts.Statspack is documented in the $ORACLE_HOME/rdbms/admin/spdoc.txtfile. Oracle Database 12c: Administration Workshop 17 - 9
Oracle Database 12c: Administration Workshop 17 - 18Memory AdvisorsThe Memory Advisor is actually a collection of several advisory functions that help determine the best settings for the total memory used by the database instance. The System Global Area (SGA) has a set of advisors for the shared pool, database buffer cache, Java pool, and streams pool. The Java pool and streams pool advisors are not exposed on the Enterprise Manager Memory Advisor page. There is an advisor for the Program Global Area (PGA). In addition to the advisory functions, this advisor provides a central point of control for the large pool and the Java pool.Mean-Time-To-Recover (MTTR) AdvisorUsing the MTTR Advisor, you set the length of time required for the database to recover after an instance crash.Segment AdvisorThis advisor looks for tables and indexes that consume more space than they require. The advisor checks for inefficient space consumption at the tablespace or schema level and produces scripts to reduce space consumption where possible.SQL Access AdvisorThis advisor analyzes all SQL statements that are issued in a given period and suggests the creation of additional indexes or materialized views that will improve performance.SQL Tuning AdvisorThis advisor analyzes an individual SQL statement and makes recommendations for improving its performance. Recommendations may include actions, such as rewriting the statement, changing the instance configuration, or adding indexes.Undo Management AdvisorWith the Undo Management Advisor, you can determine the undo tablespace size that is required to support a given retention period. Undo management and the use of the advisor is covered in the lesson titled “Managing Undo Data.”Data Recovery AdvisorThis advisor automatically diagnoses persistent data failures, presents repair options to the user, and executes repairs at the user’s request. The purpose of the Data Recovery Advisor is to reduce the mean time to recover (MTTR) and provide a centralized tool for automated data repair. SQL Repair AdvisorYou run the SQL Repair Advisor after a SQL statement fails with a critical error that generates a problem in the Automatic Diagnostic Repository. The advisor analyzes the statement and, in many cases, recommends a patch to repair the statement. If you implement the recommendation, the applied SQL patch circumvents the failure by causing the query optimizer to choose an alternative execution plan for future executions. This is done without changing the SQL statement itself.
Any application must be tested under a representative production workload. This requires estimating database size and workload, and generating test data and system load.Performance must be considered as new applications (or new versions of applications) are deployed. Sometimes, design decisions are made to maintain compatibility with old systems during the rollout. A new database should be configured (on the basis of the production environment) specifically for the applications that it hosts.A difficult and necessary task is testing the existing applications when changing the infrastructure. For example, upgrading the database to a newer version, or changing the operating system or server hardware. Before the application is deployed for production in the new configuration, you want to know the impact. The application will almost certainly require additional tuning. You need to know that the critical functionality will perform, without errors.Oracle Database 12c: Administration Workshop 18 - 7
•Monitored SQL:Shows information about monitored SQL statements that were executing or that completed during the selected time period•ADDM:Shows performance findings and recommendations from the Automatic Database Diagnostics Monitor (ADDM) for tasks performed in the database during the selected time periodThe following tab is only available if you select real-time data:•Current Findings:Shows ADDM findings for the past five minutesThe following tabs are only available if you select historical data:•Database Time:Shows wait events by category for various metrics, and to view time statistics for various metrics for the selected time period•Resources:Shows operating system resource usage statistics, I/O resource usage statistics, and memory usage statistics for the selected time period•System Statistics:Shows database statistics by value, per transaction, or per second for the selected time periodOracle Database 12c: Administration Workshop 18 - 12
Memory has an upper limit in all current machines. That limit may be imposed by the hardware, operating system, or the cost of the memory. The goal of memory tuning is to produce the most efficient use of existing memory. When the workload changes often, the most efficient division of memory between the SGA components will change. There is also the amount of memory allocated to SGA and PGA. Online transaction processing (OLTP) systems typically use very little PGA memory compared to data warehouse (DW) or decision support systems (DSS).Enterprise Manager Cloud Control and Enterprise Manager Database Express both provide Memory Advisors. These tools monitor the memory usage by the SGA components, and PGA, and project the differences in terms of efficiency for increased and decreased memory allocations. These projections use the current workload. They can help you size the SGA on the basis of the activity in your particular database. The advisors will make sizing recommendations for manual settings, when the automatic memory management is disabled. These same advisors provide input to the automatic memory management, to determine the most efficient component sizes. Using the existing memory efficiently also includes tuning the applications. A poorly tuned application can use large quantities of memory. For example, an application that uses frequent full table scans because indexes do not exist or are unusable can cause a large amount of I/O, reducing performance. The first and most effective tuning technique is to tune high cost SQL statements. Tuning SQL statements is covered in more detail in the lesson titled “Managing Performance: SQL Tuning.”Oracle Database 12c: Administration Workshop 18 - 24
Cursor and SQL AreasThe application developer of an Oracle Pro*C program or Oracle Call Interface (OCI) program can explicitly open cursorsor handles to specific private SQL areas, and use them as a named resource throughout the execution of the program. Recursive cursors that the database issues implicitly for some SQL statements also use shared SQL areas.Work AreaFor complex queries (for example, decision support queries), a big portion of the PGA is dedicated to work areas allocated by memory-intensive operators, such as:•Sort-based operators, such as ORDERBY, GROUPBY, ROLLUP, and window functions•Hash-join•Bitmap merge•Bitmap create•Write buffers used by bulk load operationsA sort operator uses a work area (the sort area) to perform the in-memory sort of a set of rows. Similarly, a hash-join operator uses a work area (the hash area) to build a hash table from its left input.The size of a work area can be controlled and tuned. Generally, bigger work areas can significantly improve the performance of a particular operator at the cost of higher memory consumption. Session MemorySession memory is the memory allocated to hold a session’s variables (logon information) and other information related to the session. For a shared server, the session memory is shared and not private.Automatic PGA Memory ManagementBy default, Oracle Database automatically and globally manages the total amount of memory dedicated to the instance PGA. You can control this amount by setting the initialization parameter PGA_AGGREGATE_TARGET. Oracle Database then tries to ensure that the total amount of PGA memory allocated across all database server processes and background processes never exceeds this target. But this is target value and not a hard limit. PGA_AGGREGATE_LIMITsets a hard limit for the amount of PGA that can be used. The minimum value is 1024MBand the maximum is 120% of physical memory minus the total SGA, and it must be at least as large as PGA_AGGREGATE TARGET. If PGA_AGGREGATE_LIMITis not set, it defaults to 200% of PGA_AGGREGATE_TARGETwithin the same minimum and maximum as stated. When PGA_AGGREGATE_LIMITis exceeded, the sessions using the most memory will have their calls aborted. Parallel queries will be treated as a unit. If the total PGA memory usage is still over the limit, sessions using the most memory will be terminated. SYSprocesses and fatal background processes are exempt from this limit.Oracle Database 12c: Administration Workshop 18 - 38
If you choose not to use automatic statistics gathering, you must manually collect statistics in all schemas, including system schemas. If the data in your database changes regularly, you also need to gather statistics regularly to ensure that the statistics accurately represent characteristics of your database objects. To manually collect statistics, use the DBMS_STATSpackage. This PL/SQL package is also used to modify, view, export, import, and delete statistics. You can also manage optimizer and system statistics collection through database initialization parameters. For example:•The OPTIMIZER_DYNAMIC_SAMPLINGparameter controls the level of dynamic sampling performed by the optimizer. You can use dynamic sampling to estimate statistics for tables and relevant indexes when they are not available or are too out of date to trust. Dynamic sampling also estimates single-table predicate selectivity when collected statistics cannot be used or are likely to lead to significant errors in estimation. •The STATISTICS_LEVELparameter controls all major statistics collections or advisories in the database and sets the statistics collection level for the database. The values for this parameter are BASIC, TYPICAL, and ALL. You can query the V$STATISTICS_LEVELview to determine which parameters are affected by the STATISTICAL_LEVELparameter. Note:Setting STATISTICS_LEVELto BASICdisables many automatic features and is not recommended.Oracle Database 12c: Administration Workshop 19 - 7
Oracle Database 12c: Administration Workshop 19 - 11Gathering statistics manually for routine statistics collection is not recommended because the statistics are gathered more efficiently and with less impact on users during the maintenance windows. A manual job can also be submitted if the automatic job has failed or been disabled. You can also gather optimizer statistics with the DBMS_STATSpackage directly:SQL> EXEC dbms_stats.gather_table_stats('HR','EMPLOYEES');SQL> SELECT num_rows FROM dba_tables2 WHERE owner='HR' AND table_name = 'EMPLOYEES';NUM_ROWS----------214Notice that the number of rows now correctly reflects what was in the table at the time that the statistics were gathered. DBMS_STATSalso enables manual collection of statistics for an entire schema or even for the whole database.System statistics do not change unless the workload significantly changes. As a result, system statistics do not need frequent adjustment. The DBMS_STATS.GATHER_SYSTEM_STATSprocedure will collect system statistics over a specified period, or you can start the gathering of system statistics and make another call to stop gathering. Best-practice tip:Use the following command when you create a database:SQL> EXEC dbms_stats.gather_system_stats('NOWORKLOAD');The NOWORKLOADoption takes a few minutes (depending on the size of the database) and captures estimates of I/O characteristics such as average read seek time and I/O transfer rate.
Oracle Database 12c: Administration Workshop 19 - 13When the various gather procedures execute, they retrieve the object-level preferences that were set for each object. You can view the object-level preferences in the DBA_TAB_STAT_PREFSview. Any preferences that are not set at the object level will be set to the global-level preferences. You can see the global preferences by calling the DBMS_STATS.GET_PREFSprocedure for each preference.You can set, get, delete, export, and import those preferences at the table, schema, database, and global levels. The preference values are expected to be set from global to table levels, applying the preferences to the smallest group last. Preferences include:•CASCADE– Determines whether index statistics are collected as part of gathering table statistics•DEGREE– Sets the degree of parallelism that is used for gathering statistics•PUBLISH– Is used to decide whether to publish the statistics to the dictionary or store them in a private area. This enables the DBA to validate the statistics before publishing them to the data dictionary with the PUBLISH_PENDING_STATSprocedure.•STALE_PERCENT– Is used to determine the threshold level at which an object is considered to have stale statistics. The value is a percentage of the rows modified since the last statistics gathering. The example changes the 10 percent default to 13 percent for SH.SALESonly.•INCREMENTAL– Is used to gather global statistics on partitioned tables in an incremental way•METHOD_OPT– Determines the columns and histogram parameters that are used to gather column statistics•GRANULARITY– Determines the granularity of statistics to collect (which is pertinent only if the table is partitioned) •NO_INVALIDATE– Is used to determine whether to invalidate cursors•ESTIMATE_PERCENT– Is used to determine the number of rows to sample to obtain good statistics. It is a percentage of the number of rows in the tableNote:For details about these preferences, see the DBMS_STATSdocumentation in the Oracle Database PL/SQL Packages and Types Reference.Preferences may be deleted with the DBMS_STATS.DELETE_*_PREFSprocedures at the table, schema, and database levels. You can reset the global preferences to the recommended values with the DBMS_STATS.RESET_PARAM_DEFAULTSprocedure.
The server displays all calculated system statistics in the V$SYSSTATview. You can query this view to find cumulative totals since the instance started.Example:SQL>SELECT name, class, value FROM v$sysstat;NAMECLASS VALUE------------------------------- ------ ----------...table scans (short tables) 64 135116table scans (long tables) 64 250table scans (rowid ranges) 64 0table scans (cache partitions) 64 3table scans (direct read) 64 0table scan rows gotten 64 14789836table scan blocks gotten 64 558542...Systemwide statistics are classified by the tuning topic and the debugging purpose. The classes include general instance activity, redo log buffer activity, locking, database buffer cache activity, and so on. Each of the system statistics can belong to more than one class, so you cannot do a simple join on V$SYSSTATS.CLASSand V$SYSTEM_WAIT_CLASS.WAIT_CLASS#.You can also view all wait events for a particular wait class by querying V$SYSTEM_WAIT_CLASS, as in this example (with formatting applied):SQL> SELECT * FROM V$SYSTEM_WAIT_CLASS2 WHERE wait_class LIKE '%I/O%';CLASS_ID CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED---------- ------ ------------ ----------- -----------1740759767 8 User I/O 1119152 390384108307767 9 System I/O 296959 27929SGA Global StatisticsThe server displays all calculated memory statistics in the V$SGASTATview. You can query this view to find cumulative totals of detailed SGA usage since the instance started, as in the following example:SQL>SELECT * FROM v$sgastat;POOL NAME BYTES------------------------------- ----------fixed_sga 7780360buffer_cache 25165824log_buffer 262144shared pool sessions 1284644shared pool sql area 22376876...The results shown are only a partial display of the output.When the STATISTICS_LEVELparameter is set to BASIC, the value of the TIMED_STATISTICSparameter defaults to FALSE. Timing information is not collected for wait events and much of the performance-monitoring capability of the database is disabled. The explicit setting of TIMED_STATISTICSoverrides the value derived from STATISTICS_LEVEL.Oracle Database 12c: Administration Workshop 19 - 16
•Execution Time Limit:Allows you to specify a maximum execution time allowed for an operation. The Oracle Database server uses cost-based optimizer statistics to estimate how long an operation will take. If it is longer than the maximum time allowed (MAX_EST_EXEC_TIME), the operation returns an error and is not started. If a resource consumer group has more than one plan directive with MAX_EST_EXEC_TIMEspecified, the Resource Manager chooses the most restrictive of all incoming values.•Idle Time Limit:Enables you to specify an amount of time for which a session can be idle, after which it will be terminated (MAX_IDLE_TIME). You can further restrict the Resource Manager to terminate only those sessions that are blocking other sessions (MAX_IDLE_TIME_BLOCKER).•Consumer Group Switching:Specifies conditions that will cause a session to switch consumer groups. Typically, overuse of a resource is specified and a session is switched to a more restrictive consumer group. The session remains in the switched consumer group until it becomes idle, or if directed after the top-level call is completed. Then it will return to the initial consumer group. The initial consumer group is the group that a session is assigned to at login. The top is the current PL/SQL block or each SQL statement that is issued outside a PL/SQL block by the client. You can create a plan directive, so that the Resource Manager automatically switches the user back to the initial consumer group at the end of the top call.•Database Consolidation: The Resource Manager enables you to optimize resource allocation among concurrent database sessions. Database consolidation requires that applications are isolated from each other. If one application experiences an increase in workload, that increase should not affect other applications. In addition, the performance of each application should be consistent. Good candidate applications for database consolidation are automated maintenance tasks because currently, these applications can take up to 100% of the server CPU resources. •Server Consolidation: Because many test, development and small production databases are unable to fully utilize the servers that they are on, server consolidationprovides a possible alternative. With server consolidation, resources are more fully utilized by running multiple database instances on the server. The method for managing CPU allocations on a multi-CPU server with multiple database instances is called Instance Caging. Because Instance Caging is simple to configure and does not require any new software to be licensed or installed, it is an excellent alternative to other server consolidation tools, such as virtualization and O/S workload managers.You can access resource plans with the graphical interface of Enterprise Manager Cloud Control or the command line of the DBMS_RESOURCE_MANAGERpackage.Oracle Database 12c: Administration Workshop 20 - 6
4. Create the resource plan: When you create the resource plan, you provide a name and optionally specify the resource allocation method for CPU (EMPHASISor RATIO), active session pool resource allocation method (ACTIVE_SESS_POOL_ABSOLUTE), resource allocation method for degree of parallelism (PARALLEL_DEGREE_LIMIT_ABSOLUTE), and queuing resource allocation method (FIFO_TIMEOUT). Use CREATE_PLANto create a resource plan. Additional information follows in this lesson.5. Create resource plan directives: Resources are allocated to consumer groups based on the resource plan directives. Through resource plan directives, you can specify:-The maximum number of concurrently active sessions for a consumer group-A limit on the degree of parallelism for any operation-The time (in CPU seconds) that a call can execute before an action is taken-A maximum in kilobytes (K) on the total amount of undo for uncommitted transactions that can be generated by a consumer groupUse CREATE_PLAN_DIRECTIVEto specify resource plan directives. 6. Validate the pending area: Use the VALIDATE_PENDING_AREAprocedure to validate the pending area at any time. The validate procedure checks for the following:-Plans do not contain loops-All plans and resource consumer groups referred to by plan directives exist-All plans have plan directives that point to either plans or resource consumer groups-All percentages in any given level do not add up to greater than 100-A plan that is currently being used as a top plan by an active instance is not being deleted-That certain parameters appear only in plan directives that refer to resource consumer groups-No more than 28 resource consumer groups appear in any active plan-Plans and resource consumer groups do not have the same name-A plan directive for OTHER_GROUPSappears somewhere in any active plan7. Submit the pending area: After validating the pending area, submit it by using SUBMIT_PENDING_AREA. When you submit the pending area, new and updated plan information is stored in the data dictionary. New plans are not activated when the pending area is submitted. Modified plans are reactivated with their new plan definition. Oracle Database 12c: Administration Workshop 20 - 11
The RATIOpolicy is a single-level CPU allocation method. Instead of percentages, you specify numbers corresponding to the ratio of CPU you want to give to the consumer group. For example, given three consumer groups OLTP_USERS, DSS_USERS, and BATCH_USERS, you can specify the following ratios:•OLTP_USERS:4•DSS_USERS:3•BATCH_USERS:2•OTHER:1This is similar to saying that OLTP users should get 40% of the resources, DSS users should get 30% of the resources, BATCH users should get 20% of the resources, and all other consumer groups should get 10% of the available resources.If there are no consumers in the OTHERor DSS_USERSconsumer groups currently utilizing CPU resources, the OLTP_USERSconsumer group would get two-thirds (4 shares out of 6 shares) of the available resources and the BATCH_USERSconsumer group would get the other third (2 shares out of 6). If all groups had sessions running, the division would be based on 10 shares.Oracle Database 12c: Administration Workshop 20 - 15
This functionality is mostly beneficial for three-tier applications where the middle-tier server implements session pooling. In this case, the middle tier tends to do one call for an end user and then use the same session for a call for a different end user. Therefore, the boundaries of work are really calls, and the actions of a prior end user should not affect the next end user.Note:You cannot specify both the SWITCH_TIME_IN_CALLand SWITCH_TIMEparameters within the same directive. The SWITCH_TIMEparameter is primarily intended for client/server applications, whereas the SWITCH_TIME_IN_CALLparameter is for three-tier applications.Oracle Database 12c: Administration Workshop 20 - 18
-RM_LAST_ACTION_REASON: The reason for the most recent action that was taken on this SQL operation by Resource Manager. Its value is one of the following: SWITCH_CPU_TIME, SWITCH_IO_REQS, SWITCH_IO_MBS, SWITCH_ELAPSED_TIME, SWITCH_IO_LOGICAL-RM_LAST_ACTION_TIME: The time of the most recent action that was taken on this SQL operation by Resource Manager-RM_CONSUMER_GROUP: The current consumer group for this SQL operationNote:V$RSRCMGRMETRICand V$RSRCMGRMETRIC_HISTORYwill always produce a row every minute regardless of whether there is a Resource Manager plan set.Oracle Database 12c: Administration Workshop 20 - 26
Example to give the Client OS User a higher priority than the Client Program:BEGINdbms_resource_manager.clear_pending_area();dbms_resource_manager.create_pending_area();dbms_resource_manager.set_consumer_group_mapping(dbms_resource_manager.oracle_user,'SCOTT','LOW_GROUP');dbms_resource_manager.set_consumer_group_mapping_pri(EXPLICIT => 1,SERVICE_MODULE_ACTION => 2,SERVICE_MODULE => 3,MODULE_NAME_ACTION => 4,MODULE_NAME => 5,SERVICE_NAME => 6,ORACLE_USER => 7,CLIENT_OS_USER => 8,CLIENT_PROGRAM => 9,CLIENT_MACHINE => 10);dbms_resource_manager.submit_pending_area();END; Oracle Database 12c: Administration Workshop 20 - 28
There is no view that shows the Active Session Pool queue directly, but you can get some information from:•V$SESSION:The CURRENT_QUEUE_DURATIONcolumn shows how long a session has been queued, or 0 (zero) if the session is not currently queued.•V$RSRC_CONSUMER_GROUP:The QUEUE_LENGTHcolumn shows the number of sessions currently queued per consumer group.Oracle Database 12c: Administration Workshop 20 - 33
The schedule specifies attributes about when the job is run, such as:•A start time, which defines when the job is picked for execution and an end time, which specifies the time after which the job is no longer valid and is not scheduled any more•An expression specifying a repeating interval for the job•A complex schedule created by combining existing schedules •A condition or change in state, called an event, that must be met before the job is startedBy using a schedule (instead of specifying the execution times for a job within the job definition), you can manage the scheduled execution of multiple jobs without having to update multiple job definitions. If a schedule is modified, each job that uses that schedule automatically uses the new schedule.3. Creating and Running a JobA job is a combination of a schedule and a description of what to do, along with any additional arguments that are required by the job. There are many attributes that you can set for a job. Attributes control how the job executes. Oracle Database 12c: Administration Workshop 21 - 7
The JOB_ACTIONparameter can be the name of the procedure to run, the name of a script or operating system command, or an anonymous PL/SQL code block, depending on the value of the JOB_TYPEparameter.In the example in the slide, JOB_TYPEis specified as EXECUTABLEand JOB_ACTIONis the full OS-dependent path of the desired external executable plus optionally any command-line arguments.An external job is a job that runs outside the database. All external jobs run as a low-privileged guest user, as has been determined by the database administrator while configuring external job support. Because the executable is run as a low-privileged guest account, you should verify that it has access to necessary files and resources. Most, but not all, platforms support external jobs. For platforms that do not support external jobs, creating or setting the attribute of a job or a program to type EXECUTABLEreturns an error.Refer to your Oracle database platform-specific documentation for more information about configuring the environment to run external programs with the Scheduler. Oracle Database 12c: Administration Workshop 21 - 12
After you enable job state change events for a job, the Scheduler raises these events by enqueuing messages onto the default event queue SYS.SCHEDULER$_EVENT_QUEUE.The default Scheduler event queue is a secure queue. Depending on your application, you may have to configure the queue to enable certain users to perform operations on it. See the Oracle Streams Concepts and Administrationdocumentation for information about secure queues.The default Scheduler event queue is intended primarily for Scheduler-generated events. Oracle does not recommend the use of this queue for user applications, or user-defined events.Event TypeDescriptionJOB_STARTEDThe job is started.JOB_SUCCEEDEDThe job is successfully completed.JOB_FAILEDThe job failed, either by raising an error or by abnormally terminating. JOB_BROKENThe job is disabled and changed to the BROKENstate, because it exceeded the number of failures defined by the MAX_FAILURESjob attribute. JOB_COMPLETEDThe job is completed, because it reached the values set by the MAX_RUNSor END_DATEjob attributes. JOB_STOPPEDThe job is stopped by a call to the STOP_JOBprocedure. JOB_SCH_LIM_REACHEDThe job’s schedule limit is reached. The job is not started, because the delay in starting the job exceeded the value of the SCHEDULE_LIMITjob attribute. JOB_DISABLED The job is disabled by the scheduler or by a call to the SET_ATTRIBUTEprocedure.JOB_CHAIN_STALLED A job running a chain is put into the CHAIN_STALLEDstate. A running chain becomes stalled if there are no steps running or scheduled to run and the chain EVALUATION_INTERVALis set to NULL.The chain waits for manual intervention.JOB_ALL_EVENTS JOB_ALL_EVENTSis not an event, but a constant, that provides an easy way for you to enable all events.JOB_OVER_MAX_DUR The job has run over the maximum time it was set to be allowed to run. JOB_RUN_COMPLETED A job run is completed. It either failed, succeeded, or is stopped.Oracle Database 12c: Administration Workshop 21 - 17
To define a step that waits for an event to occur, you use the DEFINE_CHAIN_EVENT_STEPprocedure. Procedure arguments can point to an event schedule or can include an inline queue specification and event condition. A step that points to an event waits until the specified event is raised. If the event occurs, the step completes successfully.3.After creating the chain object, you define chain rules. Chain rules define when steps run, and define dependencies between steps. Each rule has a conditionand an action:-If the condition evaluates to TRUE, the action is performed. The condition can contain any syntax that is valid in a SQL WHEREclause. Conditions are usually based on the outcome of one or more previous steps. For example, you may want one step to run if the two previous steps succeeded, and another to run if either of the two previous steps failed. -The action specifies what is to be done as a result of the rule being triggered. A typical action is to run a specified step. Possible actions include starting or stopping a step. You can also choose to end the execution of the job chain, returning either a value or a step name and error code.All rules added to a chain work together to define the overall behavior of the chain. When the job starts and at the end of each step, all rules are evaluated to see what action or actions occur next. You add a rule to a chain with the DEFINE_CHAIN_RULEprocedure. You call this procedure once for each rule that you want to add to the chain. 4.Starting the chaininvolves two actions: -Enable a chain with the ENABLEprocedure. (A chain is always created disabled, so you can add steps and rules to the chain before it is executed by any job.) Enabling an already enabled chain does not return an error.-To run a chain, you must create a job of type “CHAIN”. The job action must refer to the chain name. You can use either event-based or time-based schedules for this job.Oracle Database 12c: Administration Workshop 21 - 23
•Set resource allocation for member jobs. Job classes provide the link between the Database Resource Manager and the Scheduler because each job class can specify a resource consumer group as an attribute. Member jobs then belong to the specified consumer group and are assigned resources according to settings in the current resource plan. Alternatively, you can leave the RESOURCE_CONSUMER_GROUPattribute as NULLand set the service attribute of a job class to a desired database service name. That service can in turn be mapped to a resource consumer group. If both the RESOURCE_CONSUMER_GROUPand service attributes are set, and the designated service maps to a resource consumer group, the resource consumer group named in the RESOURCE_CONSUMER_GROUPattribute takes precedence. If a resource consumer group is not specified when a job class is created, the job class maps to the DEFAULT_CONSUMER_GROUPresource consumer group. Jobs in the default job class or in a job class associated with the default resource consumer group may not be allocated enough resources to complete their tasks when the Resource Manager is enabled. •Group jobs for prioritization. Within the same job class, you can assign priority values of 1–5 to individual jobs so that if two jobs in the class are scheduled to start at the same time, the one with the higher priority takes precedence. This ensures that you do not have a less important job preventing the timely completion of a more important one. If two jobs have the same assigned priority value, the job with the earlier start date takes precedence. If no priority is assigned to a job, its priority defaults to 3.Oracle Database 12c: Administration Workshop 21 - 27
4.Create an event-based job that references the file watcher. You can use the DBMS_SCHEDULER.SET_ATTRIBUTEprocedure to enable the job to run for each instance of the file arrival event, even if the job is already processing a previous event. Set the PARALLEL_INSTANCESattribute to TRUE. BEGINDBMS_SCHEDULER.SET_ATTRIBUTE('','PARALLEL_INSTANCES', TRUE); END;This enables the job to run as a lightweight job so that multiple instances of the job can be started quickly. If PARALLEL_INSTANCESis set to the default value of FALSE, file watcher events that occur while the event-based job is already processing another will be discarded.5.Enable the file watcher, the program, and the job.Oracle Database 12c: Administration Workshop 21 - 34
For job chains:•*_SCHEDULER_RUNNING_CHAINS: Shows all active chains•*_SCHEDULER_CHAIN_STEPS: Shows all steps for all chains•*_SCHEDULER_CHAINS: Shows all chains•*_SCHEDULER_CHAIN_RULES: Shows all rules for all chainsFor windows an other advanced objects:•*_SCHEDULER_WINDOWSshow all windows.•*_SCHEDULER_WINDOW_GROUPSshow all window groups.•*_SCHEDULER_WINGROUP_MEMBERSshow the members of all window groups, one row for each group member.•*_SCHEDULER_JOB_LOGshows all state changes made to jobs.•*_SCHEDULER_JOB_ROLESshow all jobs by database role.Lightweight jobs are visible through the same views as regular jobs:•*_SCHEDULER_JOBS: Shows all jobs, including the JOB_STYLE=‘LIGHTWEIGHT’•*_SCHEDULER_JOB_ARGS: Shows all set argument values also for lightweight jobsBecause lightweight jobs are not database objects, they are not visible through the *_OBJECTSviews.Starting with the Oracle Database 11g Release 2:•*_SCHEDULER_NOTIFICATIONSshows which email notifications have been set.•*_SCHEDULER_FILE_WATCHERSshows file watcher configuration information.The following views display information about multiple destination jobs:•*_SCHEDULER_DESTS: Shows all the destinations on which remote jobs can be scheduled. The views contain both the external destinations (for remote external jobs) as well as the database destinations for remote database jobs.•*_SCHEDULER_EXTERNAL_DESTS: Shows all the agents that have registered with the database and can be used as a destination for remote external jobs.•*_SCHEDULER_DB_DESTS: Shows all the databases on which you can schedule remote database jobs.•*_SCHEDULER_GROUPS: Shows the groups in your schema or all groups in the database.•*_SCHEDULER_GROUP_MEMBERS: Shows the group members in your schema or all group members in the database.•*_SCHEDULER_JOB_DESTS: Shows the state of a job at a remote database.Note:In the views listed above, the asterisk at the beginning of a view name can be replaced with DBA, ALL, or USER.Oracle Database 12c: Administration Workshop 21 - 40
Oracle Database 12c: Administration Workshop A - 5You can use the Knowledge tab to access the Knowledge Browser if you prefer a drilldown method of searching for information rather than searching by keyword. The Knowledge Browser provides easy-to-use access to OSS’s most frequently used technical content.The Knowledge Browser is organized to provide up-to-date information at your fingertips:•Recent announcements and information in the Featured News and Articlessection•Information by product category•Case studies•Tools and training•Online documentation•Electronic technical reference manuals (eTRMs)•Oracle Integration Repository•Customer Knowledge ExchangeMy Oracle Support Forums (Forums) enables you to interact with other Oracle customers to share ideas and discuss Oracle products. You can use My Oracle Support Forums to find out how other customers perform complex tasks or meet various business requirements with Oracle products. You should not use Forums as a substitute for logging an SR. Customers can use the patch engine to search for patches by using a variety of methods. The following are the most common patch searches:•Patch Number:If you know the patch number, you can enter it.•Latest Consolidated Patch:You can use this when upgrading to determine the latest patches for the products you are using.•Includes File:When a problem is encountered in a specific piece of code, a patch is often available to fix the issue. For this reason, support representatives often recommend that customers apply a patch to update code to the most current version available for the release. You can find and apply the latest versions of Oracle software by identifying the name and version of the code and then using the patch search utility to find out whether a more current version of the code is available.Note:For detailed information about performing these searches, refer to My Oracle Support Technical Note 166650.1 (“Working Effectively with Global Customer Support”). You can use the BUGs link to search the BUG database when researching issues. A variety of methods are available for searching the BUG database.
Oracle Database 12c: Administration Workshop A - 73.Self-service toolkits:Self-service toolkits (SSTKs) provide a wealth of information about each product. In most cases, they contain FAQs, patch listings, and other helpful information that can assist you in researching and troubleshooting the issues that you are facing. Because SSTKs contain the most frequently used content about each product, you should reference them periodically to identify known issues before they cause problems within your environment.4.Diagnostics and flows:Many recent innovations in Oracle Support Services have been in the area of automated diagnostic tests and business flows. Tests and flows have been created for you to check the setup of your system or gather information about a problem. In the case of diagnostic tests, this can be done by running a Java or SQL script. The output of these tests can help you in resolving issues and can also help Oracle Support Services identify the cause of your problem if it becomes necessary to log a service request.5.Patches and BUGs:There are times when BUGs are found in Oracle products, and patches are required to correct the problem. When troubleshooting a problem, you should review your system to see whether patches are available to provide you with a more recent release of the product. With the patch search tool, you can search for patches that contain specific files. Searching for the latest code and patching your environment to the most recent version improves the troubleshooting process by eliminating existing BUGs that could be possible candidates for the problem. You should also leverage the BUG search engine to see whether a BUG has been logged for your issue but not yet fixed.6.Logging a service request (SR):When all self-service options fail, it may become necessary to engage a support representative to assist in resolving your issue.
Oracle Database 12c: Administration Workshop A - 9If the search results fail to resolve the issue, the SR creation process continues with a series of questions and requests for information. After the questions are answered, the SR is submitted electronically and routed to a support representative who analyzes the issue further. Any files, screenshots, or other additional information must be uploaded immediately after the SR is logged by using the upload utility provided in the SR section of My Oracle Support.You must ensure that the following items are clearly documented in the SR. By providing the following information, you can equip the support representative effectively to prioritize and work on the issue:•Clear explanation of the problem, including exact error messages•Explanation of the steps taken to troubleshoot the problem and the findings•Exact versions of the software•Steps required to reproduce the problem•Business impact of this issue, including milestones, dates, and costsEach SR is assigned a unique identifier called an SR number. When you log an SR, My Oracle Support provides you with the SR number (or your support representative advises you about the SR number if you log the SR by telephone). The support representative subsequently receives the SR in his or her queue through an automated allocation process that Oracle Support Services uses to distribute all phone- and web-sourced service requests. This automated process ensures that all SRs are assigned to the support representative who is best able to work on the specific issue that is being reported.Note:For more information, refer to My Oracle Support Technical Note 166650.1 (“WorkingEffectively with Global Customer Support”).
___________________ Appendix B Basic Linux and vi Commands ___________________
Oracle Database 12c: Administration Workshop B - 2 viCommands The Visual Interpreter/Editor (vi) is the most widely used text editor available for the UNIX environment. While almost everybody curses its unwieldy command syntax, it is still the only editor that is almost certain to be included with every version of the UNIX and Linux operating system. The following is a partial list of available vicommands. vihas two modes: Command-line (where anything typed is taken as an editing command) and input mode (where everything typed will be treated as part of the file being edited). To enter the input mode, type a, A, i, I, o, O, c, C, s, S, r, or R. To return to the command-line mode, use the Esc key. To access the vieditor from SQLPlus, enter the following command: SQL>define _editor=vi To edit a file from the SQLPlus prompt, edit <filename> (press Enter); and from the Linux command prompt, vi <filename> (press Enter). To MOVE the cursor: h - move left j - move down k - move up l - move right w - one word forward b - one word backward e - end of current word W, B, or E - same as lowercase but ignores punctuation 0 (zero) - Move to beginning of current line $ - end of current line G - go to last line of file H - go to top line on the screen L - go to last line on screen M - go to middle line on the screen /<string> - Search forward to the next occurrence of <string> ?<string> - Search backward to the next occurrence of <string> n - Repeat previous search N - Repeat previous search in opposite direction Ctrl + f - Scroll forward one page Ctrl + b - Scroll backward one page To UNDO previous changes: u - Will undo the most recent change U - Will undo the most recently deleted text :e! - re-edit current file without saving any changes made since last change To ENTER NEW text: a - Append text after the current cursor position. A - Append text to the end of a line (jumps to end of line and begin appending) c - Change object C - Change from current cursor position to end of the line i - Insert text before the current cursor position I - Insert text at the beginning of a line
Oracle Database 12c: Administration Workshop B - 3 o - Insert a blank line BELOW the current cursor position O - Insert a blank line ABOVE the current cursor position r - Replace character at current cursor position R - Replace all characters until Esc is pressed s - Substitute text for character under cursor :s/A/B/opt substitutes string B for string A. %s/A/B/opt is global replace options include: g (change all occurences on current line) c (confirm prior to each change) p (print changed lines) S - Substitute entire line to the end . <period> - repeat last change n. <integer><period> repeat last change ntimes To leave the input mode, press Esc. To DELETE existing text: x - Will delete the character directly under the current cursor location dd - Will delete the entire line where the cursor is located dnd (where nis some integer) - Will delete nlines from current cursor position dw - Delete current word D - Delete to end of current line J - Delete return at end of current line. Join this line and the next. <int> J - Join the next <int> lines COPY, CUT, and PASTE:viuses a single buffer where the last changed or deleted text is stored. This text may be manipulated with the following commands: Y - Yank a copy of the current line y <integer> - Yank a copy of next <int> lines yw - Yank a copy of the current word yb - Yank a copy of the previous word p - Put buffer contents after cursor P - Put buffer contents before cursor Also, see the s and S commands under the input section To SAVE edited changes to an operating system file: zz - Will terminate edit mode :w filename - Will save changes to the filename specified :wq - Write all changes and quit the edit mode To QUIT without saving changes: ZZ - Will terminate edit mode :q! - Will terminate the file without saving changes
Oracle Database 12c: Administration Workshop B - 4 Basic Linux Commands This appendix is meant to serve only as a quick reference while you are in class. For more details on these commands, consult the man pages, your Linux documentation, or other Linux command reference books. Files and Directories Linux CommandsDescription/CommentsCommand manual man <command> man –k <string> man man Find the manual entry for this <command>. Show all the manual entries that contain this <string>. Displays the manual page forman.Command information info <command> Show the information system entry for this command. Using info infoshows a tutorial of the infodocumentation system.Print to standard out cat <file> Concatenate and print; print the named file to the terminal screen. List users cat /etc/password Change working directory cd <directory> Change working directory to specified directory cd with no parameters changes to $HOME.Copy a file cp <source_file> <destination_file> Copy a source file to a destination file.View a file less <file> View a file a page at a time. This is a GNU version of more, or pg. View a file more <file> View a file a page at a time. BSD version.List directory ls <directory> Options: –l: long listing, -R: recursive, -a: show hidden files, -t: sort by time, -r: reverse sort, default directory is current working directory.Create a directory mkdir <directory> Make a directory defaults into the current working directory, full path may be specified.Move or rename a file mv <old_file> <new_file> Move changes the name of a file or moves it to a different directory. Process List ps ps -ef Shows the processes report Shows all processes on the system with a full listing. Many option exist see the man page for details.
Oracle Database 12c: Administration Workshop B - 5 Print working directory pwd Print to stdout the current working directory.Remove or erase a file rm <file> Removing a file on Linux is permanent. Options –r: recursive, and –f: force (including subdirectories) are very dangerous. Often the rmcommand is aliased with rm –iThe option –iasks ‘Are you sure?’ Create an empty file touch <file> Create a file.Name of the machine hostname Returns the name of the machine.The IP address of the machine host <machine_name> Queries the Domain Name Server, and returns the IP address of the machine name. Remote shell rsh <host> <command> Execute a <command> on <host>. Rsh is not secure, use ssh instead.Remote shell ssh <host> Secure shell, has features to replace rsh, rcp, ftp, and telnet.Remote shell telnet <host> Start a terminal session on <host>. Telnet is not secure use ssh instead.Search a file for a pattern grep <option> <pattern> <file> Search a <file> or stream for a regular expression defined by <pattern> and show the line that contains that pattern. A common option is –ifor case insensitive. grepcan accept input from a file or stdinthrough a pipe as in: netstat –a| grep ESTABLISHED Source a script . <script_file> In the bashshell this command ‘.’ forces the script to run in the shell. Normal behavior is for the script to run in a child shell.
Oracle Database 12c: Administration Workshop B - 6 An interpreter awk A macro language for reformatting or interpreting input. For each line of input, a variety of actions can be taken. May be referred to as nawk – for “new awk.”Sort a file sort Sort a file takes input from stdin or a filename argument, many options to sort by a particular column, field, etc. See man page. Command-line editor sed Sed is a command-line editor, with many possible commands and options that are very good for editing from a shell script.Visual editor vi <file> Terminal based editor available on every UNIX system, Linux provides vim, an improved vi, that is a superset of vi.Gnu editor emacs <file> This is a GPL editor with extensive customizable features available on most UNIX and Linux distributions.WYSIWYG editor gedit <file> A full-screen editor, requiring X. Available under Gnome.WYSIWYG kate <file> A full-screen editor, requires X. Available under KDETerminal output stdout Standard out (stdout) is not a command but a concept, most Linux commands write to stdout by default unless redirected.Terminal input (keyboard) stdin Standard in (stdin) is not a command but a concept, most Linux commands read from stdin by default unless redirected.Alias alias <command> <alias> Make a substitution when a user types <command> substitute and execute <alias>, common alias is alias ‘rm’ ‘rm –i’. These aliases are set in the .bashrcfile.Show shell variables set Prints all of the variables that are currently defined in the shell.
Oracle Database 12c: Administration Workshop B - 7 Show environment variables printenv or env Prints all the environment variables – an environment variable has been ‘exported’ so that it will be inherited by child processes.File Creation mask umask –S u=rwx,g=rx,o=rx Set the default permissions for all files created by this shell or its children. The –Soption uses the symbolic notation, the numeric notation is obsolete.Clock xclock An X client that shows a clock on the screen. Often used to test the X windows system.X access control xhost xhost +<Xclient> Show the current access control in place. Add an Xclient that is allowed to access the local DISPLAY, if no <Xclient> is given all are allowed.
Oracle Database 12c: Administration Workshop B - 8 System AdministrationLinux CommandsDescription / CommentsSubstitute user su - username Change the user that is currently performing the work. This can be used by any user to change who is the effective id of the session user. Normal users must provide a password, root does not. The ‘-‘ parameter is optional. It runs the new users login scripts.Limited root privileges sudo The root user may configure which users can execute certain commands as root, and whether a password is required or not. Useful for allowing specific users to perform certain root commands e.g. mount and unmount removable volumes such as CDROMs.Root file system / The root directory for the system directory tree.Home Directory /home Typically the directory where all user home directories are placed. For example: /home/oracle. Tmp directory /tmp A temporary storage area. Do not put anything here you want to keep. SA often has a cron job to remove everything periodically.Boot directory /boot A small partition to hold the kernel image(s) and boot loader instructions.Log directory /var/log The location of most system log files.Sample configuration files /etc/inittab Configuration files are located per the application. Any configuration file that you change after installation should be included in the backup.Password files /etc/passwd /etc/shadow The /etc/passwdfile holds user information and must be readable by others; even with encrypted passwords this can be a security hole. The /etc/shadowfile holds the encrypted passwords and is only readable by root.
Oracle Database 12c: Administration Workshop B - 9 Groups file /etc/group The /etc/groupsfile defines the groups on a server and the users that are members of the group; primary group for a user is defined in the /etc/passwdfile.X configuration file /etc/X11/XF86Config The file that sets the X server settings for your video card, monitor, mouse, and keyboard. Usually set up with an OS vendor-supplied tool. Schedule a command to run at a regularly scheduled time crontab -e Use this command to edit the crontabfile, to create the specification for the crondaemon to use.Schedule a script to run at a particular frequency /etc/anacrontab Edit the file to specify a script to run at a particular frequency (see man anacrontabfor details).Schedule a command to run at a single specified time at <options> TIME Runs a job specified by <options> at a specified TIME parameter.Schedule a command batch <options> <TIME> Run a command when the load average drops below .8, optionally after a set TIME.Mount a file system mount <opt> <dev> <mount_point> Mount a file system on device <dev> at <mount_point> with the options specified by <dev>.Unmount a file system umount <dev> umount <mount_point> Unmount the file system or device.Maximum # of user ID 65535 Recover root password {lilo} control-x linux S passwd root {grub} c kernel vmlinuz-2.4.9-13 singlero root=/dev/hda8 initrd /initrd-2.4.9-13.img boot passwd root This is a procedure to recover the root password if it is lost. This requires physical access to the machine and system console. You start by rebooting the machine, then during the LILO boot press and hold Ctrl + X to get a prompt and command LILO to boot linux to runlevel S. The second procedure uses the grub boot loader. Create new user useradd The –Doption alone shows the defaults.
Oracle Database 12c: Administration Workshop B - 10 –Dwith other options changes the defaults options; without –Doverride, the default (e.g., –g) sets a primary group. Delete user userdel Remove a user and optionally all files belonging to the user.Modify user account usermod Change /etc/passwordinformation.Create new group groupadd –gsets the group id; default is first free value above 500.Delete group groupdel Remove a group from the system. May not remove a group that is a primary group for a user. Files owned by deleted group must be manually changed with chown.Change run levels init <runlevel> The initcommand causes the rcN.d scripts to be evaluated, for the change in run level. init 6forces a reboot.Synchronize the disks sync Forces the buffer cache and page cache to write all dirty buffers to disk. Used just before a reboot to prevent disk corruption.Shut down the Linux system shutdown <mode> <delay> Do a graceful shutdown of the system, shut down processes, run all shutdown scripts, and sync disks. The modes are –r(reboot) and –h(halt). The delay is a required parameter is a number in seconds or ‘now’. Option shutdown warning message may be sent as well.Error logs dmesg View boot messages. This log is circular, and limited system errors could overwrite boot information after a time.Network IP configuration /etc/sysconfig/network-scripts/ This directory holds scripts executed as part of the boot up sequence by rc.sysinit.
Oracle Database 12c: Administration Workshop B - 11 Hosts IP addresses /etc/hosts A list of hosts that your machine knows about. Must at minimum include the name of the local machine and loopback IP.Name service switch /etc/nsswitch.conf Network parameters sysctl -a | grep net View all net parameters that are set for the kernel.Routing daemon routed NIC Configurations ifconfig -a Show all the network devices currently configured.Secondary IP Address modprobe ip_alias ifconfig eth0:1 IP Login prompt /etc/issue Banner message user sees when issued the login prompt.YP/NIS service binder /sbin/ypbind Finds and attaches to a NIS server for name resolution and other services.Module information modinfo <options> <module> Display information about kernel modules: –lshows license, –pparameters, –ddescription.List modules lsmod Show currently loaded modules.Load module insmod Load a loadable module.Unload module rmmod Unload a loadable module.Install Software rpm -ivh package Install –i, verbose –v, with progress hash marks –h.Uninstall software rpm -e package Erase package –e; will not uninstall if dependencies exist.List installed software rpm -qa Query –q, All –a, lists all installed packages.Verify installed software rpm -V package Compares installed files with the rpm database information.List all files rpm -ql package List all the files that are part of a package.Package owner rpm -qf file List the package when given the full file name.Machine model uname -m Shows CPU level (e.g., i686).OS Level uname -r Shows kernel version.Run Level runlevel Shows previous and current runlevel.Kernel Parameters sysctl -a Show settings of all settable kernel parameters.
Oracle Database 12c: Administration Workshop B - 12 Max # File Descriptors sysctl fs.file-max Shows the value of maximum number of file descriptor per process. Kernel parameter settings /etc/sysctl.conf Compiled in kernel parameters; may be reset at bootup by setting them in this file. Change Kernel Parameter echo <value> > </proc/<file> Write the new value of a kernel parameter into the /proc file system.echo 2147483648 >/proc/sys/kernel/shmmax Set the value of the maximum size of a shared memory segment.Shared Memory sysctl kernel.shmmax Show the shmmaxparameter. Change Kernel Parameter sysctl –w <parameter>=<value> Change a kernel parameter; the –poption reads the setting from a file and sets them. The default file is /etc/sysctl.confSet Process limits ulimit <option> <value> Set limits on a shell and processes started by the shell. Users can make limits more restrictive; generally only root can make limit less restrictive; some options require root privilege. Options: –usets number of processes, –nnumber of file handles; many others (see man bash). Show process limits ulimit Without options ulimit shows the current limit settings.Interprocess Communication (Shared Memory and Semaphores) ipcs <option> Options: –mthe current usage of shared memory; –susage of semaphores; –ashows all.Remove a shared memory segment ipcrm shm <shmid> Releases the shared memory segment identified by <shmid>. This is very dangerous. You can corrupt a database that is using the segment that is released.
Oracle Database 12c: Administration Workshop B - 13 System PerformanceLinux CommandsDescription / CommentsPerformance monitor top View real-time OS and process statistics.System activity reporter sar –<options> <interval> <count> Options: –qshows CPU queue, –uCPU utilization, –ddevice activity, –nDEV network device activity, many more (see manpage). Interval is in seconds.Virtual Memory statistics vmstat <interval> < count> Interval is in seconds.Virtual Memory statistics cat /proc/meminfo Shows instantaneous virtual memory usage. Kernel Cache statistics cat /proc/slabinfo Kernel slab allocator statistics: frequently allocated cache objects such as inode, dentries, and asynchronous IO buffers. I/O statistics iostat <option> <interval> <count> Options: –ddevice activity, –cCPU activity, –xextended disk activity statistics. The interval is in seconds.Multiprocessor Statistics mpstat –P <cpu> <count> <interval> Return CPU statistics for particular processor or allCPUs in an smp system. Physical RAM 64 GB(Theoretical) Maximum physical RAM requires enterprise kernel (Red Hat Enterprise Linux AS 21 supports only up to 16 GB).Swap device swapon -s Shows devices currently in use for swap. The swap device is arbitrary designated at install. It may be changed or added to. Multiple swap devices may be created; swap size should be at least as large as physical memory.
Oracle Database 12c: Administration Workshop B - 14 Display swap size free Show the current memory and swap usage.Activate Swap swapon -a Turn on swap.Free disk blocks df -k Measured in KB; use –mfor MB units.Device listing cat /proc/devices List devices known to the system by major and minor number.Disk information cat /proc/scsi/scsi0/sda/model cat /proc/ide/ide0/hda/model View SCSI disk information. View IDE disk information.Print network statistics netstat <options> Print a wide variety of network statistics (see man netstat).Graphical system statistics viewer xosview An X-based display of recent OS statistics.
Oracle Database 12c: Administration Workshop B - 15 Misc System InformationLinux CommandsDescription / CommentsNFS exported /etc/exports Database files are not supported on simple NFS.NFS Client mounted directories /var/lib/nfs/xtab Max File System 2 TB with 4KB block size (on 32 kernel) With ext3 and ext2, others vary.Max File Size File size can not exceed file system 2 GB {512B block size} 2 TB {4KB block size} The Oracle database can create files up to 64 GB with a 16 KB database block size. The 32-bit kernel limits file and block devices to 2 TB.File System Block size dumpe2fs <device> Dump the file system properties to stdout.Filesystem table /etc/fstab Mounts these file systems at boot up.Journal Filesystem types ext3 reiserfs Disk Label fdisk -l fdiskis not available on all distributions.Extend File system resize2fs Extending a file system is applicable to only some file system types. resize_reiserfs Backup tar cvf /dev/rst0 / Create a backup of the root / file system.Restore tar xvf /dev/rst0 Restore the root / file system.Prepare boot volumes /sbin/lilo Must be run after changing /etc/lilo.confto push changes to boot loader.Startup script /etc/rc.d/rc Kernel /boot/vmlinuz Kernel Bits getconf WORD_BIT POSIX call to get kernel information. There are many other variables besides WORD_BIT.
Oracle Database 12c: Administration Workshop B - 16 Boot single user {lilo} control-x linux S {grub} c kernel vmlinuz-2.4.9-13 singlero root=/dev/hda8 initrd /initrd-2.4.9-13.img boot Use LILO facility. Use GRUB Boot Loader.Time zone Management /etc/sysconfig/clock SW Directory /var/lib/rpm Directory where rpm databases are kept.Devices /dev This directory holds all the device files.CPU cat /proc/cpuinfo Shows CPU static information.Whole Disk /dev/sda Device name.CDROM /dev/cdrom Usually mounted at /mnt/cdrom.CDROM file type iso9660 Floppy drive /dev/fd0 Usually mounted at /mnt/floppy. System information /proc The /procfile system is a memory-based file system that allows access to process and kernel settings and statistics.Compile and link a executable make –f <file> <command> Use a make file <file> to determine which parts of a large program need to be recompiled, and issue the commands required to compile, link, and prepare the executable for use.
Oracle Database 12c: Administration Workshop B - 17 LVM Linux (UnitedLinux)Description / CommentsLVM Logical Volume Manager This package is not provided by Red Hat Enterprise Linux AS 2.1 and may not be added without tainting the kernel. Kernel support is provided in United Linux.LVM Concepts logical extents A logical volume is made up of logical extents.logical volume A set of logical extents taken from a volume group and presented to the OS as a disk volume. These extents may be striped across multiple disks.volume group A set of physical disk partitions created by fdiskor the like, initialized with pvcreate, then grouped into a physical volume with vgcreate.Display volume group vgdisplay -v Modify physical volume pvchange Prepare physical disk pvcreate List physical volume pvdisplay Remove disk from volume group vgreduce Move logical volumes to another physical volumes pvmove Create volume group vgcreate Remove volume group vgremove Volume group availability vgchange Restore volume group vgcfgrestore
Oracle Database 12c: Administration Workshop B - 18 Exports volume group vgexport Imports volume group vgimport Volume group listing vgscan Change logical volume characteristics lvchange List logical volume lvdisplay Make logical volume lvcreate Extend logical volume lvextend Reduce logical volume lvreduce Remove logical volume lvremove Create striped volumes lvcreate -i 3 -I 64