oracle 8 database administration volume 1 instruction guide phần 6 pps

40 311 0
oracle 8 database administration volume 1 instruction guide phần 6 pps

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

LGWR, Log Switches, and Checkpoints LGWR, Log Switches, and Checkpoints Oracle Architecture Instance SGA Database buffer cache DBWR Redo log buffer CKPT LGWR ARCH Control files Parameter file Password file Data files Redo log files Archived log files Database 7-5 Copyright © Oracle Corporation, 1998 All rights reserved Redo Log Buffer and the Background Process LGWR The Oracle Server sequentially records all changes made to the database in the redo log buffer The redo log buffer is used in a circular manner The redo entries are written to one of the online redo log groups called the current online redo log group by the LGWR process under the following situations: • When a commit occurs • When the redo log buffer pool becomes one-third full • When an LGWR timeout occurs (every three seconds) • Before the DBWR writes modified blocks in the database buffers cache to the data files Log Switches LGWR writes to the online redo log files sequentially—that is, when the current online redo log group is filled, LGWR begins writing to the next group When the last available online redo log file is filled, LGWR returns to the first online redo log group and starts writing again Oracle8: Database Administration 7-7 Lesson 7: Maintaining Redo Log Files A log switch is the event during which LGWR stops writing to one online redo log group and starts writing to another The database administrator can also force log switches (see subsequent sections) Each time a log switch occurs and LGWR begins writing to a new log group, the Oracle server assigns a number known as the log sequence number to identify the set of redo entries When a log switch occurs, an event called a checkpoint is initiated Checkpoints During a checkpoint: • All dirty database buffers covered by the log being checkpointed are written to the data files by DBWR • The checkpoint background process CKPT updates the headers of all data files and control files to reflect that it has successfully completed Checkpoints can occur for all data files in the database or for only specific data files A checkpoint occurs, for example, in the following situations: • At every log switch • When an instance has been shut down with the normal, transactional, or immediate option • When forced by setting the initialization parameters, LOG_CHECKPOINT_INTERVAL and LOG_CHECKPOINT_TIMEOUT (see subsequent sections) • When manually requested by the database administrator (see subsequent sections) Information about each checkpoint is recorded in the ALERT file if the initialization parameter LOG_CHECKPOINTS_TO_ALERT is set to TRUE The default value of FALSE for this parameter does not log checkpoints Instructor Note Mention that there are additional situations in which checkpoints occur; for example when taking a tablespace offline or making it read only 7-8 Oracle8: Database Administration Archiving Redo Log Files Archiving Redo Log Files Without Archiving Backup Disk failure Control files Data files 50 101 100 51 t1 t2 Copyright © Oracle Corporation, 1998 All rights reserved 7-6 With Archiving Backup Archived redo logs Disk failure 50 Data files Control files 50 51 t1 7-7 99 100 101 t2 Copyright © Oracle Corporation, 1998 All rights reserved Oracle8: Database Administration 7-9 Lesson 7: Maintaining Redo Log Files Archiving Redo Log Files One of the important decisions that a database administrator has to make is whether the database is configured to operate in ARCHIVELOG or in NOARCHIVELOG mode NOARCHIVELOG Mode In NOARCHIVELOG mode, the online redo log files are overwritten each time an online redo log file is filled, and log switches occur LGWR will not overwrite a redo log group until the checkpoint for that group is completed ARCHIVELOG Mode If the database is configured to run in ARCHIVELOG mode, inactive groups of filled online redo log files must be archived Since all changes made to the database are recorded in the online redo log files, the database administrator can use the physical backup and the archived online redo log files to recover the database without losing any committed data due to any kind of failure There are two ways in which online redo log files can be archived: • Manually • Automatically The initialization parameter LOG_ARCHIVE_START indicates whether archiving should be automatic or manual when the instance starts up • TRUE indicates that archiving is automatic ARCH will initiate archiving of the filled log group at every log switch • FALSE, the default value, indicates that the database administrator will archive filled redo log files manually A Server Manager command must be executed each time you want to archive an online redo log file All or specific online redo log files can be archived manually Note This is covered in more detail in the course Oracle8: Backup and Recovery Workshop Instructor Note Point out that ARCHIVELOG mode is a database setting, whereas automatic archiving is a characteristic of the instance 7-10 Oracle8: Database Administration Obtaining Log and Archive Information Obtaining Log and Archive Information Obtaining Information About Archiving • Server Manager command: ARCHIVE LOG LIST; • V$DATABASE: – NAME LOG_MODE ã V$INSTANCE ARCHIVER 7-8 Copyright â Oracle Corporation, 1998 All rights reserved The following Server Manager command shows the database log mode and if the automatic archival is enabled SVRMGR> ARCHIVE LOG LIST Database log mode Automatic archival Archive destination Oldest online log sequence Current log sequence No Archive Mode Disabled ?/dbs/arch 688 689 Oracle8: Database Administration 7-11 Lesson 7: Maintaining Redo Log Files Query the dynamic performance views V$DATABASE and V$INSTANCE to show the database log mode and the archiving mode SVRMGR> SELECT name, log_mode 2> FROM v$database; NAME LOG_MODE - U15 NOARCHIVELOG row selected SVRMGR> SELECT archiver 2> FROM v$instance; ARCHIVE STOPPED row selected 7-12 Oracle8: Database Administration Obtaining Log and Archive Information Obtaining Information About Groups V$THREAD: • GROUPS • CURRENT_GROUP# • SEQUENCE# 7-9 Copyright © Oracle Corporation, 1998 All rights reserved To see the number of online redo log groups, the current log group, and the sequence number, query the dynamic performance view V$THREAD This is of particular interest for Parallel Server administrators SVRMGR>SELECT groups, current_group#,sequence# 2>FROM v$thread; GROUPS CURRENT_GR 1 row selected SEQUENCE# -689 Oracle8: Database Administration 7-13 Lesson 7: Maintaining Redo Log Files Obtaining Information About Groups and Members V$LOG: • GROUP# • MEMBERS • STATUS • SEQUENCE# • BYTES 7-10 Copyright © Oracle Corporation, 1998 All rights reserved The following query returns information about the online redo log file from the control file: SVRMGR>SELECT group#,sequence#,bytes,members,status 2>FROM v$log; GROUP# SEQUENCE# BYTES MEMBERS 688 1048576 689 1048576 rows selected STATUS CURRENT INACTIVE The following items are the most common values for the STATUS column: • UNUSED indicates that the online redo log group has never been written This is the state of an online redo log file that was just added • CURRENT indicates the current online redo log group This implies that the online redo log group is active 7-14 Oracle8: Database Administration Obtaining Log and Archive Information • • ACTIVE indicates that the online redo log group is active but is not the current online redo log group It is needed for crash recovery It may or may not be archived INACTIVE indicates that the online redo log group is no longer needed for instance recovery It may or may not be archived Oracle8: Database Administration 7-15 Lesson 7: Maintaining Redo Log Files Obtaining Information About Groups and Members V$LOGFILE: • GROUP# • STATUS • MEMBER 7-11 Copyright © Oracle Corporation, 1998 All rights reserved To obtain the names of all the members of a group, query the dynamic performance view V$LOGFILE in which the value of the STATUS column could be: • INVALID indicates that the file is inaccessible • STALE indicates that contents of the file are incomplete; for example, adding a log file member • DELETED indicates that the file is no longer used • NULL indicates that the file is in use SVRMGR>SELECT * 2>FROM v$logfile; GROUP# STATUS -1 MEMBER /DISK3/log1a.rdo /DISK4/log2a.rdo 7-16 Oracle8: Database Administration Lesson 7: Maintaining Redo Log Files Quick Reference Context Initialization parameters Dynamic initialization parameters Dynamic performance views Reference LOG_FILES LOG_CHECKPOINTS_TO_ALERT LOG_CHECKPOINT_TIMEOUT LOG_CHECKPOINT_INTERVAL V$THREAD V$LOG V$LOGFILE Data dictionary views Commands V$DATABASE None ALTER SYSTEM SWITCH LOGFILE ALTER SYSTEM CHECKPOINT ARCHIVE LOG LIST ALTER DATABASE ADD LOGFILE ALTER DATABASE ADD LOGFILE MEMBER ALTER DATABASE RENAME FILE ALTER DATABASE DROP LOGFILE ALTER DATABASE DROP LOGFILE MEMBER Packaged procedures and functions ALTER DATABASE CLEAR LOGFILE None 7-32 Oracle8: Database Administration Managing Tablespaces and Data Files Lesson 8: Managing Tablespaces and Data Files Instructor Note Topic Lecture Timing 70 minutes Practice 45 minutes Total 115 minutes 8-2 Oracle8: Database Administration Objectives Objectives Objectives • Describing the logical structure of the database • Creating tablespaces • Changing the size of tablespaces using different methods • Changing the status and storage settings of tablespaces • Relocating tablespaces • Preparing necessary tablespaces 8-2 Copyright © Oracle Corporation, 1998 All rights reserved Oracle8: Database Administration 8-3 Lesson 8: Managing Tablespaces and Data Files Overview Overview Control files Data files Redo log files Database 8-3 Copyright © Oracle Corporation, 1998 All rights reserved The database architecture includes the logical and physical structures that make up the database The physical structure consists of control files, online redo log files, and data files The logical database structure includes tablespaces, segments, extents, and data blocks The separation of logical and physical structure provides a fine-grained control of disk space management When logical storage structures are created, space is allocated in the database according to predefined parameters The database administrator has the ability to override or configure these database parameters To use space efficiently and effectively it is important to understand the logical database structure 8-4 Oracle8: Database Administration Logical Database Structure Logical Database Structure Database Structure Database Tablespace Logical Data file Physical Segment Extent Oracle block 8-4 O/S Block Copyright © Oracle Corporation, 1998 All rights reserved Relationship Between Database, Tablespaces, and Data Files An Oracle database can be divided into smaller logical areas of space known as tablespaces Tablespaces • A tablespace can belong to only one database • Each tablespace consists of one or more operating system files • Tablespaces can be brought online while the database is running • Except for the SYSTEM tablespace or a tablespace with an active rollback segment, tablespaces can be taken offline, leaving the database running • Tablespaces can be switched between read-write and read-only status Oracle8: Database Administration 8-5 Lesson 8: Managing Tablespaces and Data Files Tablespace Uses • Controlling space allocation and assigning space quotas to users • Controlling availability of data by taking individual tablespaces online or offline • Distributing data storage across devices to improve I/O performance and to reduce I/O contention against a single disk • Performing partial backup and partial recovery operations • Keeping large amounts of static data on read-only devices Data Files Each tablespace in an Oracle database consists of one or more files called data files These are physical structures that conform with the operating system on which the Oracle server is running • A data file can belong to only one tablespace • An Oracle server creates a data file for a tablespace by allocating the specified amount of disk space plus a small overhead • The database administrator can change the size of a data file after its creation or can specify that a data file should dynamically grow as objects in the tablespace grow This functionality implies that the database can consist of fewer data files per tablespace, and the database administrator can circumvent the MAXDATAFILES limitation 8-6 Oracle8: Database Administration Logical Database Structure Relationship Between Segments, Extents, and Data Blocks Oracle enables fine-grained control of disk space use through the logical storage structures, including segments, extents, and data blocks Segments A segment is the space allocated for a specific type of logical storage structure within a tablespace The following are examples of segments: • Table segment • Index segment • Temporary segment • Rollback segment A segment such as a data segment may span multiple files that belong to the same tablespace Extents The next level of logical database space is called an extent An extent is a set of contiguous number of blocks Each type of segment is made up of one or more extents An extent may not span a data file, but must exist in one data file Data Blocks At the finest level of granularity, the data in an Oracle database is stored in data blocks One data block corresponds to one or more physical file blocks allocated from an existing data file Data block size is specified for each Oracle database by the initialization parameter DB_BLOCK_SIZE when the database is created A database block is the smallest unit of input-output Instructor Note You may mention what the phrase “contiguous number of blocks” means while using a UNIX system or OS striping Oracle8: Database Administration 8-7 Lesson 8: Managing Tablespaces and Data Files Creating Tablespaces SYSTEM and Non-SYSTEM Tablespaces SYSTEM Tablespace contains: – Data dictionary information – SYSTEM rollback segment Non-SYSTEM Tablespace contains: – Rollback segments – Temporary segments – Application data – Application indexes 8-5 Copyright © Oracle Corporation, 1998 All rights reserved Types of Tablespaces A database consists of at least one tablespace: the SYSTEM tablespace Create additional tablespaces in the database for increased control and long-term ease of maintenance Essentially, the Oracle server perceives two types of tablespaces: SYSTEM and others that are not the SYSTEM tablespace SYSTEM Tablespace • Required in all databases for database operation • Contains data dictionary information, definitions of stored procedures, packages, and database triggers • Contains the SYSTEM rollback segment • Should not contain user data although it is allowed 8-8 Oracle8: Database Administration Creating Tablespaces Non-SYSTEM Tablespace • Enable more flexibility in database administration • Can store rollback segments, temporary segments, application data, and application indexes Oracle8: Database Administration 8-9 Lesson 8: Managing Tablespaces and Data Files Creating Tablespaces Example CREATE TABLESPACE app_data DATAFILE ‘/DISK4/app01.dbf’ SIZE 100M, ‘/DISK5/app02.dbf’ SIZE 100M MINIMUM EXTENT 500K DEFAULT STORAGE (INITIAL 500K NEXT 500K MAXEXTENTS 500 PCTINCREASE 0); 8-6 Copyright © Oracle Corporation, 1998 All rights reserved You can create a tablespace with the following CREATE TABLESPACE command: CREATE TABLESPACE tablespace DATAFILE filespec [autoextend_clause] [, filespec [autoextend_clause]] [MINIMUM EXTENT integer[K|M]] [DEFAULT storage_clause] [PERMANENT|TEMPORARY] [ONLINE|OFFLINE] 8-10 Oracle8: Database Administration Creating Tablespaces storage_clause:= = STORAGE ( [INITIAL integer[K|M]] [NEXT integer[K|M]] [MINEXTENTS integer] [MAXEXTENTS {integer|UNLIMITED}] [PCTINCREASE integer] ) where: tablespace is the name of the tablespace to be created DATAFILE specifies the data file or files that make up the tablespace DEFAULT STORAGE specifies the default storage parameters for all objects created in the tablespace MINIMUM EXTENT ensures that every used extent size in the tablespace is a multiple of the integer value ONLINE makes the tablespace available for use immediately upon creation OFFLINE makes the tablespace unavailable immediately after creation PERMANENT specifiesthatthetablespacecanbeusedtohold permanent objects TEMPORARY specifies that the tablespace will only be used to hold temporary objects; for example, segments used by implicit sorts to handle ORDER BY clause Oracle8: Database Administration 8-11 Lesson 8: Managing Tablespaces and Data Files OEM Use Oracle Storage Manager Select Tablespace—>Create In the General page of the property sheet, enter the name and choose the ADD field to display the Create Datafile property sheet In the Create Datafile property sheet, specify each data file In the Extents page of the property sheet, enter storage information Click Create Limits The maximum number of tablespaces per database is 64K But the number of tablespaces cannot exceed the number of data files The maximum number of data files per tablespace is 1023 Note With the setting of the MINIMUM EXTENT option, the database administrator controls the fragmentation in the tablespace This option can only be specified for a tablespace, not for the storage of individual objects 8-12 Oracle8: Database Administration Creating Tablespaces Storage Parameters The following parameters influence the segment storage allocation: • INITIAL • NEXT • MAXEXTENTS • MINEXTENTS • PCTINCREASE 8-7 Copyright © Oracle Corporation, 1998 All rights reserved The amount of space used by a segment is determined by the storage clause These parameters are determined at the creation of the segment If no specific storage parameters are given in the CREATE commands of the segments—such as CREATE TABLE, CREATE INDEX, CREATE CLUSTER or CREATE ROLLBACK SEGMENT—then the segment will use the default storage parameters for the tablespace in which it is stored • INITIAL defines the size of the first extent The minimum size of the first extent is two blocks, that is (2*DB_BLOCK_SIZE) The default size is blocks, that is (5* DB_BLOCK_SIZE) • NEXT refers to the size of the second extent The minimum size of the next extent is one block The default size is blocks, that is (5* DB_BLOCK_SIZE) Oracle8: Database Administration 8-13 Lesson 8: Managing Tablespaces and Data Files • • MINEXTENTS is the number of extents allocated when the segment is created The minimum and default is PCTINCREASE is the percent by which the extent size grows The size of an extent is calculated using the following formula: PCTINCREASE Size n = NEXT ×  + -   100 where: • Sizen (n – 2) is the size of the nth extent For example, if NEXT is set to 200K, and PCTINCREASE is 50, the second extent would be 200K in size, the third extent would be 300K (50% more than the second extent), the fourth extent would be 450K (50% more than the third extent), and so on The minimum value is 0, and the default value is 50 The calculated value is rounded up to next data block which is a multiple of 5* DB_BLOCK_SIZE MAXEXTENTS determines the maximum number of extents that a segment can have The miminum value is The default maximum value depends on the data block size The maximum size can also be specified by the keyword UNLIMITED, which is equivalent to a value of 2147483645 Note If MINIMUM EXTENT is specified for a tablespace, the extents allocated for a segment in this tablespace are multiples of this parameter 8-14 Oracle8: Database Administration ... Oracle Corporation, 19 98 All rights reserved 7 -6 With Archiving Backup Archived redo logs Disk failure 50 Data files Control files 50 51 t1 7-7 99 10 0 10 1 t2 Copyright © Oracle Corporation, 19 98. .. group#,sequence#,bytes,members,status 2>FROM v$log; GROUP# SEQUENCE# BYTES MEMBERS 68 8 10 485 76 68 9 10 485 76 rows selected STATUS CURRENT INACTIVE The following items are the most common values... LIST Database log mode Automatic archival Archive destination Oldest online log sequence Current log sequence No Archive Mode Disabled ?/dbs/arch 68 8 68 9 Oracle8 : Database Administration

Ngày đăng: 08/08/2014, 20:21

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan