Tải bản đầy đủ (.pdf) (40 trang)

oracle 8 database administration volume 1 instruction guide phần 4 ppsx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (250.54 KB, 40 trang )

Trace Files and the ALERT File
......................................................................................................................................................

Controlling the Trace File
Instance
SGA Shared pool

User
process

Server
process

ALERT file

USER_DUMP_DEST
3-24

BACKGROUND_DUMP_DEST

Copyright © Oracle Corporation, 1998. All rights reserved.

The following parameters control the location and size of the trace files:
BACKGROUND_DUMP_DEST
defines the location of the background trace
file and ALERT file.
USER_DUMP_DEST
defines where trace files will be created at
the request of the users.
MAX_DUMP_FILE_SIZE
specified in O/S blocks, limits the size of


user trace files.
Note
• The MAX_DUMP_FILE_SIZE and USER_DUMP_DEST parameters
are dynamic initialization parameters.
• On UNIX, the alert file is named alert_<SID>.log and is located in the
$ORACLE_HOME/rdbms/log directory by default.
• On Windows NT, the alert file is named <SID>alrt.log and is located in
the %ORACLE_HOME%\RDBMS80\TRACE directory by default.

......................................................................................................................................................
Oracle8: Database Administration
3-41


Lesson 3: Managing an Oracle Instance
......................................................................................................................................................

.

Guidelines
Check the ALERT file periodically to:
• Detect internal errors (ORA-600)
and block corruption errors
• Monitor database operations
ã View the nondefault initialization
parameter

3-25

Copyright â Oracle Corporation, 1998. All rights reserved.


It is important for the database administrator to check the ALERT file
regularly to detect problems before they become serious.
The following information is logged in the ALERT file:
• All internal errors (ORA-00600) and block corruption errors
(ORA-01578)
• Operations that affect database structures and parameters, and Server
Manager statements such as STARTUP, SHUTDOWN, ARCHIVE
LOG, and RECOVER
• The values of all nondefault initialization parameters at the time the
instance starts
Instructor Note
You may query the current setting for BACKGROUND_DUMP_DEST,
change to that directory, and show the alert and trace files in the directory.

......................................................................................................................................................
3-42
Oracle8: Database Administration


Summary
......................................................................................................................................................

Summary

Summary
• Starting up and shutting down an
instance
• Understanding the use of dynamic
performance views

ã Describing the use of trace files

3-26

Copyright â Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
Oracle8: Database Administration
3-43


Lesson 3: Managing an Oracle Instance
......................................................................................................................................................

Quick Reference
Context
Initialization parameters

Reference
DB_NAME
CONTROL_FILES
SHARED_POOL_SIZE
BACKGROUND_DUMP_DEST
DB_BLOCK_BUFFERS
COMPATIBLE
IFILE
LOG_BUFFER
PROCESSES

Dynamic initialization

parameters

Dynamic initialization
parameters (deferred)
Dynamic performance views

SQL_TRACE
USER_DUMP_DEST
MAX_DUMP_FILE_SIZE
TIMED_STATISTICS
SORT_AREA_SIZE
V$FIXED_TABLE
V$PARAMETER
V$CONTROLFILE
V$DATABASE
V$DATAFILE
V$DATAFILE_HEADER
V$INSTANCE
V$LOGFILE
V$OPTION
V$PROCESS
V$PWFILE_USERS
V$SESSION
V$SGA

V$VERSION

......................................................................................................................................................
3-44
Oracle8: Database Administration



Summary
......................................................................................................................................................

Data dictionary views
Commands

None
CONNECT / AS SYSDBA
CONNECT / AS SYSOPER
STARTUP
SHUTDOWN
SHOW PARAMETER
ALTER SYSTEM KILL SESSION
ALTER SYSTEM DISCONNECT SESSION ...
POST_TRANSACTION
ALTER SYSTEM ENABLE RESTRICTED SESSION
ALTER SYSTEM DISABLE RESTRICTED SESSION
ALTER SESSION SET
ALTER SYSTEM SET
ALTER SYSTEM SET... DEFERRED
ALTER DATABASE MOUNT

Packaged procedure and
functions

ALTER DATABASE OPEN
None


......................................................................................................................................................
Oracle8: Database Administration
3-45


Lesson 3: Managing an Oracle Instance
......................................................................................................................................................

......................................................................................................................................................
3-46
Oracle8: Database Administration


4
................................

Creating a Database


Lesson 4: Creating a Database
......................................................................................................................................................

Instructor Note
Topic
Lecture

Timing
60 minutes

Practice


60 minutes

Total

120 minutes

......................................................................................................................................................
4-2
Oracle8: Database Administration


Objectives
......................................................................................................................................................

Objectives

Objectives
• Preparing the operating system
• Preparing the parameter file
• Creating the database

4-2

Copyright © Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
Oracle8: Database Administration
4-3



Lesson 4: Creating a Database
......................................................................................................................................................

Overview

Overview
Instance
SGA

User
process

Shared Pool

Server
process
PGA

Control
files
Parameter
file
Redo log
files

Datafiles
Password
file
4-3


Database

Copyright © Oracle Corporation, 1998. All rights reserved.

Creating the database is the first step in managing and organizing a database
system.
Database creation is a task that prepares several operating system files and is
needed only once no matter how many data files the database has. This is a
very important task because the database administrator must decide on
database settings, such as the size of the database block and the database
character set, which cannot be changed after the creation.
Depending on the operating system, a database may have been created
automatically as part of the installation.
You can use this initial database, or you can erase it and create a new one
manually.
During migration from an older version of Oracle, database creation is
necessary only if an entirely new database is needed. Otherwise you can use
a migration utility—for example, MIG80 on NT—to migrate from an earlier
version of the database.
You can create a database with new data files or by erasing information in an
existing database that has the same physical structure.
The CREATE DATABASE command initiates the creation of the control
files, redo log files, and the data dictionary structure that Oracle server
requires to access the database.

......................................................................................................................................................
4-4
Oracle8: Database Administration



Preparing the Operating System
......................................................................................................................................................

Preparing the Operating System

Creation Prerequisites
• A privileged account authenticated in
one of the following ways:
- By the operating system
- Using a password file




4-4

Memory to start the instance
Sufficient disk space for the planned
database

Copyright © Oracle Corporation, 1998. All rights reserved.

The database administrator should be fully privileged on the operating
system or should use the password file authentication (see the lesson
“Managing an Oracle Instance”).
Before you create the database, make sure that the memory for the SGA, the
Oracle executable, and the processes is sufficient. Refer to your operating
system installation and administration guides.
Calculate the necessary disk space for the database, including online redo

log files, control files, and the data files.

......................................................................................................................................................
Oracle8: Database Administration
4-5


Lesson 4: Creating a Database
......................................................................................................................................................

Planning Database File Locations
• Keep at least two active copies of a database
control file on at least two different devices.
• Multiplex the redo log files and put group
members on different disks.
• Separate data files whose data:
– Will participate in disk resource contention

across different physical disk resources
– Have different life-spans
– Have different administrative characteristics
4-5

Copyright © Oracle Corporation, 1998. All rights reserved.

Planning File Location
Plan how to protect the database, including the online redo log files, control
files, data files, and archived redo log files, and provide a backup strategy.
Control Files
For the sake of safety, you should create at least two control files on two

different disks (see the lesson “Maintaining the Control File”). Because
control file copies must always be placed on different disks, they can have
identical names, such as control01.ctl on UNIX or control.ora on NT.
Online Redo Log Files
The online redo log files of a database should consist of multiplexed groups
of online redo log files. A group of log files consists of identical copies,
which should be located on different disks (see the lesson “Maintaining
Redo Log Files”).
To distinguish between groups and their members, use a name like
log0101.rdo or log01a.rdo.

......................................................................................................................................................
4-6
Oracle8: Database Administration


Preparing the Operating System
......................................................................................................................................................

Data Files
Name data files by relating to the contents as the root of the name—for
example, data files such as system01.dbf, temp01.dbf, users01.dbf on UNIX
and system01.ora, temp01.ora on NT.
Consider the characteristics of the data to be stored before determining the
structure appropriate for your database in order to:
• Minimize fragmentation
• Minimize disk contention
• Separate objects
To minimize fragmentation of the database, you should separate database
objects with different life spans, such as application data and temporary

data, into different tablespaces.
To ensure well-balanced I/O loads, you should separate objects with
competing I/O requirements, such as tables and indexes into different
tablespaces.
Note
These subjects are covered in detail in the lessons “Maintaining Tablespaces
and Data Files” and “Storage Structure and Relationships.”

......................................................................................................................................................
Oracle8: Database Administration
4-7


Lesson 4: Creating a Database
......................................................................................................................................................

Oracle Software Locations
/u01/app/oracle
/product

/u02/app/applmgr
/product

/8.0.3
/bin
/dbs
/orainst
/sqlplus
...


/7.3.3
/admin

/admin

/local

/local
Copyright © Oracle Corporation, 1998. All rights reserved.

4-6

Oracle Database Files
/u03/

/u02/
oradata/
db01/
system01.dbf
control01.ctl
redo0101.rdo
...

db02/
system01.dbf
control01.ctl
redo0101.rdo
...
4-7


oradata/
db01/
tools01.dbf
control02.ctl
redo0102.rdo
...

db02/
users01.dbf
control02.ctl
redo0102.rdo
...

Copyright © Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-8
Oracle8: Database Administration


Preparing the Operating System
......................................................................................................................................................

Optimal Flexible Architecture
Another important issue during installation and creation of a database is
organizing the file system so that it is easy to administer growth by adding
data into an existing database, adding users, creating new databases, and
adding hardware and distributing I/O load across sufficiently many drives.
The Optimal Flexible Architecture (OFA) standard, which provides one
solution to these issues was written by an Oracle team responsible for

installing, tuning, and upgrading UNIX Systems. OFA facilitates
configuration of complex Oracle systems with low maintenance. During an
Oracle installation on several UNIX platforms, Oracle automatically uses
this standard configuration.
The following steps explain the OFA structure:
1 Name all devices that might contain Oracle server data as a collection
into a unit, called a mount point. (A mount point is a directory on UNIX
denoting where the file subsystem for a single disk slice will be linked
into an existing file system. The selection of mount points makes it
possible to hide device details). In the example, u01 and u02 are
different mount points.
2 Name all devices that might contain Oracle server data so that a wildcard
can be used to refer to the collection of devices as a unit.
In the example, /u01/app/oracle is the Oracle software owner home
directory and /u02/app/applmgr is the Oracle Financial Applications
owner.
3 Distinguish between product files, which consist of Oracle server
software and tools, administrative files like database creation scripts,
initialization scripts, and local software which is used with Oracle.
In the example, the directories product, admin, and local satisfy this
requirement.
4 Store each version of Oracle server distribution software in a directory
matching the software such as /u01/app/oracle/product/7.3.3 or /u01/
app/oracle/product/8.0.3
5 Make a directory explicitly for storing Oracle server data at the same
level of each of the devices, such as /u02/oradata.
6 Make a directory beneath the Oracle directory for each of the databases
on the system. In the example, the databases are named dba01 and db01.

......................................................................................................................................................

Oracle8: Database Administration
4-9


Lesson 4: Creating a Database
......................................................................................................................................................

Note
• Environment variables such as ORACLE_BASE and ORACLE_HOME
are used to identify the directory structure.
• The OFA directory structure for NT is not identical to that for UNIX
because of the naming conventions and the lack of symbolic links. To
circumvent this problem, the creation of hard directories instead of
symbolic links like u01 and u02 is necessary.
For example, instead of the creation /u01/oradata/db01/, where u01
represents a mount point on UNIX, you would create a directory
DISK_3:\ORADATA\DB01\ on NT.
Instructor Note
For information about OFA architecture, see The OFA Standard—Oracle7
for Open Systems, by Cary V. Millsap, Oracle Corporation. Oracle part
number A19308-1
or :80/sgrepo/papers/cmillsap
For information about OFA and NT see
/>
......................................................................................................................................................
4-10
Oracle8: Database Administration


Preparing the Operating System

......................................................................................................................................................

Oracle Software Directory Structure
After the Oracle installation, the ORACLE_HOME directory is
/mount_point/app/oracle/product.
On UNIX the ORACLE_HOME directory contains the following
subdirectories, as well as subdirectories for each Oracle product, depending
on the Oracle products available on the platform:
Subdirectory

Description

bin

Binaries for all products

dbs

Database files, init<sid>.ora and sql.bsq script

lib

Oracle product libraries

orainst

Installation files and programs

rdbms


Server files, scripts, and libraries required for the database

plsql

PL/SQL, procedural option

sqlplus

SQL*Plus

network

Oracle Net8

svrmgr

Server Manager

Some examples of the contents of the product subdirectories are:
Subdirectory

Description

admin

Administrative scripts

demo

Demonstration scripts and data files


admin

Administrative scripts

doc

README files

install

Product installation scripts

lib

Product libraries

log

Log files

Note
The directory structure on NT is similar to that on UNIX.

......................................................................................................................................................
Oracle8: Database Administration
4-11


Lesson 4: Creating a Database

......................................................................................................................................................

Creating a Database

Creating a Database: Considerations
• On UNIX:
– Created automatically during an

installation
– Created manually after installation

• On NT:
– Created using the Oracle Database

Assistant
– Created manually

4-8

Copyright © Oracle Corporation, 1998. All rights reserved.

If you use the installer to create a database, the installer prompts you to enter
the number and the location of the mount points, the character set, the
national character set, passwords for user SYS and SYSTEM, and the UNIX
group password to enable operating system authentications.
On NT, during the installation you are prompted to create a database with a
wizard, the Oracle Database Assistant. This utility can also be used after
installation to create or to delete a database.

......................................................................................................................................................

4-12
Oracle8: Database Administration


Creating a Database
......................................................................................................................................................

Creating a Database Manually
1. Decide on a unique instance and
database name and database character
set.
2. Set the operating system variables.
3. Prepare the parameter file.
4. Create a password file (recommended).
5. Start the instance.
6. Create the database.
7. Run scripts to generate the data dictionary
and accomplish postcreation steps.
4-9

Copyright © Oracle Corporation, 1998. All rights reserved.

This lesson covers the first six steps in detail. The last step, generating the
data dictionary, is discussed in the lesson “Data Dictionary Views and
Standard Packages.”

......................................................................................................................................................
Oracle8: Database Administration
4-13



Lesson 4: Creating a Database
......................................................................................................................................................

Operating System Environment
On UNIX set the following environment
variables:
ã ORACLE_HOME
ã ORACLE_SID
ã ORACLE_BASE
ã ORA_NLS 33
ã PATH

4-10

Copyright â Oracle Corporation, 1998. All rights reserved.

Decide on a unique name for the instance and set the following environment
variables:
Variable

Description

ORACLE_HOME Set to the directory where the Oracle software will be installed
(Example: /u01/app/oracle/product/8.0.3)
ORACLE_SID

Specifies the instance name and must be unique for Oracle
instances running on the same machine.


ORACLE_BASE

Not required, but recommended as part of an OFA-compliant
installation (Example: /u01/app/oracle)

ORA_NLS33

Required when creating a database with a character set other
than US7ASCII (Example: $ORACLE_HOME/ocommon/nls/
admin/data)

PATH

Search path which must include $ORACLE_HOME/bin

......................................................................................................................................................
4-14
Oracle8: Database Administration


Creating a Database
......................................................................................................................................................

For example, set the environment variables in a Korn Shell with the
following command:
$ORACLE_SID=U16; export ORACLE_SID

In a C-shell, execute the following command:
$setenv ORACLE_SID U16


Note
• If ORA_NLS is not set and the database is started with other languages
and character sets than the database default, they will not be recognized.
• The value of the SID can be up to eight characters, depending on the
operating system.

......................................................................................................................................................
Oracle8: Database Administration
4-15


Lesson 4: Creating a Database
......................................................................................................................................................

Operating System Environment
On NT
• Set the variable ORACLE_SID to use
SVRMGR30.
• Create the service and the password
file with ORADIM80.
C:\> ORADIM80 -NEW -SID u16
-INTPWD password -STARTMODE auto
-PFILE ORACLE_HOME\DATABASE\initU16.ora

4-11

Copyright © Oracle Corporation, 1998. All rights reserved.

Oracle on NT uses variables in the NT registry similar to the way Oracle on
UNIX uses shell environment variables.

The Oracle Installer, the ORADIM80, and the Oracle Database Assistant
utilities define variables in the registry as well as registering the Oracle
instance as a service. You can edit the registry manually via the regedit.exe
utility.
For example, parameters such as ORACLE_HOME, ORA_NLS33, and
ORACLE_SID (the default is ORCL for the starter database), are stored in
the folder HKEY_LOCAL_MACHINE\ SOFTWARE \ORACLE folder.
Therefore the creation of a new database requires ORACLE_SID to be set
with the following command:
C:\> set ORACLE_SID=U16

Now you create a new service and the new password file, if required, to run
the database with the ORADIM80 utility:
C:\>ORADIM80 -NEW -SID sid [-INTPWD internal_pwd][SRVC svrcname]
[MAXUSERS number][STARTMODE auto,manual][-PFILE filename]

......................................................................................................................................................
4-16
Oracle8: Database Administration


Creating a Database
......................................................................................................................................................

Note
The Oracle server records all operations that are executed with the
ORADIM80 utility in the ORACLE_HOME\RDBMS80\ORADIM80.LOG
file.
Instructor Note
The students can review the description of the ORADIM80 utility in

the lesson “Managing an Oracle Instance.”

......................................................................................................................................................
Oracle8: Database Administration
4-17


Lesson 4: Creating a Database
......................................................................................................................................................

Preparing the Parameter File
1. Create the new init<SID>.ora.
$cp init.ora $ORACLE_HOME/dbs/initU16.ora

2. Modify the initU16.ora by editing
the parameters.

Copyright © Oracle Corporation, 1998. All rights reserved.

4-12

Editing the Parameter File
db_name = U16
db_files = 100
# db_files = 400

# MEDIUM

# db_files = 1000 # LARGE
db_file_multiblock_read_count =


8

# db_file_multiblock_read_count = 16 # MEDIUM
# db_file_multiblock_read_count = 32 # LARGE
control_files = (/disk1/control01.con,/disk2/control02.con)
db_block_size = 8192
db_block_buffers = 2000
# db_block_buffers = 550

# SMALL
# MEDIUM

# db_block_buffers = 3200 # LARGE
shared_pool_size = 30000000
# shared_pool_size = 5000000 # MEDIUM
# shared_pool_size = 9000000 # LARGE
log_buffer = 65536
# log_buffer = 32768

# MEDIUM

# log_buffer = 163840 # LARGE
...
4-13

Copyright © Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-18

Oracle8: Database Administration


Creating a Database
......................................................................................................................................................

Preparing the Parameter File
When preparing the new database, copy the default init.ora file with the new
name init<SID>.ora.
Change the settings for some parameters; others can be left to default.
You should specify at least the following parameters before starting the
instance:
Parameter

Description

DB_NAME

Database identifier of eight characters or fewer.
This is the only parameter that is required when
creating a new database.This parameter does not
need to match the ORACLE_SID, but must match
the name used in the CREATE DATABASE
statement.

CONTROL_FILES

Specifies a list of control files (Always specify at
least two control filenames, placed on separate
disks if possible. The control files do not need to

exist at this point. The Oracle server can create
new operating system files when creating the
database.)

DB_BLOCK_SIZE

Determines the database block size (The block
size cannot be changed after database creation.)

Note
The database name is associated with a database at create database time and
is stored in the control files. To change the name of an existing database, use
the CREATE CONTROLFILE command to re-create the control file (see the
course Oracle8: Backup and Recovery Workshop).

......................................................................................................................................................
Oracle8: Database Administration
4-19


×