Oracle DBA
Oracle DBA
Lesson 1
Oracle Server Architecture
Overview
u Set of data to store and access information
u Based on a relational model of rows and columns stored in tables
u Also Object-oriented (OO) structures
n Abstract datatypes and methods
u Contains these components:
n Physical
n Memory
n Process
Instance Structure
u Memory structures are allocated
n Collectively known as System Global Area.
n 95% defined by data block buffer cache, Shared SQL Pool, Large Pool
and Java Pool.
u Oracle background processes are started.
u Single database accessible by multiple instances – RAC (Real
Application Cluster) a.k.a. parallel server
Instance Defined
u Defined by initialization parameter(s) that determine the size
and composition
u Can be dynamically altered
u initSID.ora (ascii file)
u spfileSID.ora (binary file)
u configSID.ora (usually only used to create a database – not
widely used)
SGA Composition
u Buffer cache
u Shared SQL Pool
u Large pool (optional)
u Java pool
u Redo log buffer
u Dictionary cache
u Other miscellaneous items
10
Oracle Instance
u Required Background Processes:
n DBWn
n LGWR
n SMON
n PMON
n CKPT (9i)
11
Oracle Instance
u Optional Background Processes:
(not all inclusive)
n ARCn
n CKPT (prior to 9i)
n RECO
n Lock (LCK0)
n Job Queue (SNPn)
n Queue Monitor (QMNn)
n Dispatcher (Dnnn)
n Server (Snnn – for dedicated MTS servers)
12
SGA
u Buffer Cache
u Redo Log BUFFER
u Shared SQL Pool
u Dynamic (as of Oracle 9i)
14
Dynamic SGA
u Defined in Granules
n SGA < 128mb 4mb size
n SGA > 128mb 16mb size
u Can be modified on the fly (9i)
u Establish an overall maximum
u Initially allocated – 4 for small, 3 for large
(fixed SGA, buffer cache, Shared pool)
15
16
17
18
19
Shared Pool
20
Shared Pool
u Library Cache
n SHARED by all users for commonly used SQL
statements
n Shared and Private SQL areas for executed
statements
n PL/SQL Procedures and Packages
n Allocation and Reuse of Memory
21
22
Library Cache
u PL/SQL Program Units
n Procedures, functions, Packages, anonymous blocks and
database triggers
u Allocation and Reuse of Memory
n Every SQL statement submitted, Oracle automatically allocates
memory
u Checks for existence
u Allocate private SQL area
u May flush the shared pool
23
PGA
24
25
Questions
u What is the name of Oracle’s memory structure?
u What are its contents?
u How is it divided?
u If I have 150 mb SGA, why does Oracle change the size?
u Can you vary sizes of Oracle blocks?
n If so, how?
26
Oracle Database
u Composed of two structures:
n Physical (Operating System view)
27
Physical Structure
u Made up of:
n Data files
n Redo Log Files – two or more with members
n One or more Control Files
n One Parameter File
n Trace and alert log files
n One Password file
29
Datafile
30
31
Control Files
u Record of the overall architecture and status of the
database
u Easily moved and recovered
u Contain the following:
n Database NAME
n Datafiles NAMES and LOCATIONS
n Redo log file NAMES, Log sequence number and LOCATIONS
32
Parameter File
u Attributes of an instance are defined through an Oracle
Parameter File
33
34
35
Logical View
Structures
37
Tablespace(s)
u Logically divides a database
u One or more datafiles are explicity created for each one
u Logically divided into segments that are further divided into
extents and blocks
u Can be defined as read-only
u A unit of space to store a schema’s objects
38
Object(s)
u Schema(s)
n A collection of objects owned by one Oracle user
u Object(s)
n Tables, indexes, views, sequences, stored
procedures, functions, packages, UNDO segments
39
40
Questions
u What are the physical files of a database system?
u What are the logical entities of a database?
u What is the smallest structure?
u Which structure MUST be contiguous?
u Which structure will tell you event information?
41
Background Processes
Review
43
Background Processes
u DBW0 (DBWn)
u LGWR
u PMON
u SMON
u CKPT
u ARCn
44
Database Buffer
u After the changed data (redo entries) are written to the
online redo log files, the changed data will be written to disk
u These changed data are called ‘dirty’
u Dirty data are moved to the ‘write’ list
u Dirty data can be on the ‘write’ list and on the LRU list
45
46
47
48
49
50
51
52
53
54
55
SMON
u INSTANCE RECOVERY performed at startup
u CLEANS up temp segment(s) no longer in use
u Can coalesce fragmented tablespaces
56
CKPT
u Updates the header record of the data files with a SCN
(System Change Number)
u This SCN is used for synchronization of all files
u Does this on behalf of the LGWR
u Can be a source of I/O contention with the LGWR
57
58
ARCn
u Copies the REDO logs to the ARCHIVE storage
when the REDO logs become filled
n Process was optional before 9i, but now is
automatically started when archivelog mode is set.
n Must be turned on
59
ARCn
u ARCn copies a filled online redo log file to an
archived redo log file
u ARCn gives each archived redo log file a unique
name
u ARCn must be finished copying the online redo
log before it is overwritten
60
61
63
64
Session
u The activity of a user from the time the user
connects to the database to the time the user
disconnects from the database
u Can execute multiple transactions
65
66
67
A Transaction is Started
u Ends with a COMMIT or ROLLBACK SQL
statement
n Explicitly with a COMMIT or ROLLBACK
n Implicitly when a DDL statement is issued
68
Dedicated Server
• Assume for now that we have a Dedicated Server
Architecture
(Multi Threaded Server, MTS will be discussed later)
n Each user has one server process
n Each server process works for only one user
n Session information is stored in the PGA
69
70
Server Process
u An OS process that works on behalf of the user
u Reads the data from disk into the buffer cache
u Communicates with the database for the user
n User processes do not connect directly to the database
71
73
74
n Arrays
75
76
77
PARSE
u CHECKS the statement for syntactic and semantic validity
n Data Dictionary
u Ensures the processes issuing the command has the
RIGHTS to execute the command
u ALLOCATES a private SQL area for the statement ( PGA )
u SCANS existing SQL area for matching statement
78
79
EXECUTE
u Will only execute if the PARSE is successful
u APPLIES the PARSE TREE to the data
u PERFORM physical and logical reads
80
EXECUTE
u CHANGES data where necessary
81
82
83
SGA Review
Buffer Cache
Shared Pool
Redo Log Buffer
85
86
87
88
Shared Pool
u Has two mandatory structures:
n Library Cache
n Dictionary Cache
u One optional structure
n Large Pool
89
Mandatory Contents
u Data Dictionary cache (also called
row cache)
n Dictionary row information recently accessed
u Library cache
n Parsed statements
n Execution plans
90
UNDO Segments
u Main purpose
n Read consistency
n Transaction rollback
u User initiated ROLLBACK
u Abnormal termination
u Abnormal database termination
92
UNDO Segments
u Contains
n Block Information
n File names and block ID
n Data as it existed before a transaction
n Transaction numbers
93
94
UNDO Segments
u Record the transaction that occurred on the data
n Should an error occur during a modification of data,
the record retained by the UNDO SEGMENT will
restore the data prior to the modification attempt
95
Read Consistency
u Ensures data seen by a statement is consistent
with respect to a point-in-time
u Even data changed by another transaction is not
seen during the transaction
96
97
COMMIT
u When a statement is executed and saved
u Can be explicitly or implicitly commited
u Ends the current transaction
u Generates a System Change Number (SCN)
98
COMMIT
u What happens when a COMMIT is made?
n Modification becomes PERMANENT
n A copy of the transaction is placed in the REDO
BUFFER
n Redo buffer is FLUSHED to the REDO LOGS
99
100
101
102
103
104
105
106
107
1,3,5,..
A_LOG1 B_LOG1 Group 1
LGWR
A_LOG2 B_LOG2
Group 2
2,4,6,..
108
109
CONTROL FILE
u Contains
n DATABASE NAME
n TIMESTAMP of database creation
n TIMESTAMP of last access
n NAMES and LOCATIONS of databases and redo log files
n Current LOG SEQUENCE number
110
TRANSACTION
u Logical unit of work
n One or more SQL statements executed by a single
user
111
112
TRANSACTION
u The TRANSACTION is aborted when:
n A ROLLBACK occurs
n User TERMINATES
n ABNORMAL user exit
n Processor FAILURE
n Media FAILURE
113
Parameter File
u initSID.ora
u configSID.ora
114
115
116
117
118
Archiving Parameters
u Standby_archive_dest
u Log_archive_dest_n
n As of 9i can be up to 10 locations
n (SERVICE=tns_service | LOCATION= local location)
n MANDATORY | OPTIONAL
u Log_archive_dest_state_n
n Used for managing the 1-10 archive destinations
119
Archiving Parameters
u Log_archive_duplex_dest
u Log_archive_min_succeed_dest
n V$archive_dest
n V$archive
n V$logs
120
u Parameters
n log_checkpoint_interval (blocks)
n log_checkpoint_timeout (seconds)
u 0 value will turn it off
121
122
123
Server Configurations
u Three types
n DEDICATED server
n MULTITHREAD server
n COMBINED user/server process
125
DEDICATED server
u Two tasks
n USER process and SERVER process
n If the two processes are on the same machine, the program
interface is handled by the LOCAL MACHINE'S I/O
n If the two processes are on different machines, the program
interface is handled by a COMMUNICATION MECHANISM
(SQL*Net/Net80)
126
127
MULTITHREADED server
u Allows many user processes to share a server
process
n This allows the system resources to be freed, but
can cause decreased response time for heavy users
128
MULTITHREADED Server
Application
Code
Client Workstation
Database Server
Dispatcher Processes
Oracle
Server Code
Request Response
queue Queues
129
130
131
Summary
u Oracle database
n Data, redo log, control, trace, alert log and parameter files
u Oracle Instance
n The set of background processes which access data, log, and
control files.
n An Oracle Instance is defined by one or more Parameter Files
that is read at startup time
132
n CONTROL FILES
133
Physical structure
u One or more DATA files that contain data
134
DATAFILE
u How is a DATAFILE used?
n Data is read into stored memory cache
135
136
CONTROL FILES
u Why does Oracle need them?
n When an Oracle database is started, the CONTROL
file that is listed first in the parameter file is read
n Identifies the database
n Opens the redo logs to allow the database to
function
137
SETTING BUFFERS
u Parameter File
u Data buffers
n DB_CACHE_SIZE
u Cannot be used with db_block_buffers
u Redo log
n LOG_BUFFER
138
u DEDICATED PGA
n PGA allocates the memory to the user sessions as
needed
139
BACKGROUND PROCESSES
u DBWn (Database Writer) u PMON (Process Monitor)
u LGWR (Log Writer) u ARCn (Archiver)
u CKPT (Check Point) u RECO (Recover)
u SMON (System Monitor) u Dnnn (Dispatcher)
140
RECO
u Resolves in-doubt transactions in distributed
database systems
141
142
LCKn
u Used with the PARALLEL (RAC – 9i) server option
n It instantly LOCKS data to prevent data corruption
caused by simultaneous access of data by different
processes
143
CKPT
u Primary goal
n Make sure all modified data buffers get written to files
n FORCES DBWR to clean the BUFFER CACHE
n CAUSES the switching of REDO LOG FILES
n FLUSHES the REDO LOG BUFFER to disk
144
145
u Agenda
n Application(s) used in starting a database
n Required environment settings to startup a
database
n Various levels of a database startup and
shutdown
147
148
149
SQLPLUS
u The replacement for Server Manager (svrmgrl) starting
with release 8.1.5
u With Password file
n Sqlplus /nolog
n Then issue
connect <username>/<syspassword> as sysdba (9i)
n Connect internal as sysdba (8i – to be desupported after
9i)
150
u TOAD
n Downloadable version - minimal
151
152
153
154
155
156
157
Setting Environment - NT
u ORADIM – can be used to create it
n Oradim –NEW –SID sid –SRVC service
u Please refer to the documentation for full syntax
158
159
160
Startup by OS
u User must have OS PRIVILEGES:
n Unix: group DBA(defined in /etc/groups)
161
162
163
164
165
166
NOMOUNT
u Typically used during database creation
u Starts the background processes and allocates
memory
u Also used in recovery
167
Nomount - example
C:\Documents and Settings\vdevore>sqlplus /nolog
168
169
Mount - example
C:\Documents and Settings\vdevore>sqlplus /nolog
170
OPEN
u Opening the database involves:
n Opening the data file(s) and online redo logs for read-write
n Allowing regular users to connect to the database
n Attempts to acquire one or more UNDO segments
n Performs automatic crash recovery if database was shutdown
abnormally
171
172
STARTUP – No Arguments
u Oracle assumes that STARTUP with no arguments implies a
STARTUP OPEN
u It is also assumed that the current SID environment variable
is what will be used.
n DBAs must ALWAYS be sure that the proper environment is set
u PFILE or SPFILE must be defined and accessible or it will
fail
u DBA must have SYSDBA or OSDBA
173
Starting an instance
u NOMOUNT, MOUNT, and OPEN are different
stages of an Oracle database startup
n When a STARTUP OPEN is issued, the database first
startups in a NOMOUNT state, then proceeds to a
MOUNT state, and finally proceeds to an OPEN state
174
175
RESTRICT - Example
SQL> startup restrict
ORACLE instance started.
Total System Global Area 4199600 bytes
Fixed Size 42028 bytes
Variable Size 4026500 bytes
Database Buffers 122880 bytes
Redo Buffers 8192 bytes
Database mounted.
Database opened.
SQL>
176
FORCE
u STARTUP FORCE is used for troubleshooting a failed or
failure to open database
u If the database is closed, forces the database open
u If the database is open, it will abort the database and then
open it
Example:
To shutdown the current instance, restart it without mounting or
opening and allow only DBA access:
STARTUP FORCE NOMOUNT RESTRICT
177
178
179
180
181
182
u In this case, the DBA must first shutdown the database and
then issue a STARTUP MOUNT command
183
u Syntax
SHUTDOWN [ABORT|IMMEDIATE|NORMAL|TRANSACTIONAL]
184
185
186
187
Shutdown Abort
u SHUTDOWN ABORT
n Immediately terminates the Oracle instance
n All buffered writes are NOT flushed to disk
n Does not perform a rollback on uncommitted transactions
n An instance recovery is required on the next database startup
(performed automatically)
188
Database shudown
u SHUTDOWN TRANSACTIONAL
(new with Oracle 8i)
n All current sessions in a transaction are allowed to complete
n No new sessions are allowed to start
n Any connected sessions are disconnected either by issuing a
new transaction or once all transactions are committed or
aborted
189
190
Database shutdown
u (SHUTDOWN IMMEDIATE) USER CONNECTIONS ARE
TERMINATED
u All database data in the SGA is written back to the database files
u All redo log buffer data is written back to the redo log files
u Database is dismounted
u The control files are closed
u The SGA is removed from memory and the background processes
are closed
191
192
193
Questions?
u Which OEM manager can use to start up a database?
u How must you connect to startup a database?
u Which shutdown command satisfies these conditions?
u The database shuts down when the last user logs off
u Force the database to close with users connected and disconnects
their transactions midstream
u Force the database to close with users connected, but let
transactions complete
194
Summary
u Start an Oracle DATABASE
n Log onto the host O/S, set up the proper environment and then run
sqlplus /nolog
u A database startup proceeds in three stages:
n Starting the instance (NOMOUNT)
n Opening the controlfile(s) (MOUNT)
n Opening the datafiles and redo logfiles (OPEN)
u Ways to shutdown a database:
n Abort, Immediate, Normal and transactional
195
197
198
199
200
201
202
n Tablespace storage
u This includes the type of data file to create
n Segment storage
n Disk contention
n Free space and segment fragmentation
203
Tablespace Storage
u Tablespace Storage considerations
n System limitation on datafile size
204
205
Tablespace Storage
u Each tablespace contains object segment(s)
206
Tablespace Storage
207
208
Database Blocks
u Not identical to operating system-level file blocks
u A logical database block may span multiple
system level blocks
u Should be created to either fit into an OS-level file
block or be the same
209
Database Blocks
u The size of each database block is determined by the
parameter DB_BLOCK_SIZE in the initialization parameter
file
u This size is fixed during database creation time. Cannot be
changed unless the database is re-created
u The default DB_BLOCK_SIZE is 2048 bytes
210
211
212
213
214
215
Datafile Naming
u The datafile name must contain the absolute path
n No UNIX/NT variable names nor VMS logicals should be
specified in the datafile name
216
217
218
VMS Naming
u Example:
n Create a tablespace called RBS
219
220
NT Naming
u Example
n Create a tablespace called NEWDATA
221
NT Naming Example
u The answer is:
222
223
u Example
n The third datafile of the SYSTEM tablespace
belonging to the SEED database
system_SEED_03.dbf
224
225
226
Datafile Options
227
228
229
230
231
Tablespace
Datafile #1 Datafile #2
232
233
234
235
236
OEM
237
238
240
241
242
243
244
245
246
247
248
249
250
251
Parameter File
u Great care should be taken in the sizing of each
parameter
u If a parameter is not defined, Oracle will provide
defaults
n To view all defined and defaulted values, run sqlplus as sys or
system and issue:
Show parameters or view v$parameter
252
u NT
n Oracle looks under
$ORACLE_HOME\database\init<SID>.ora
253
u For example,
n If you have a database with a SID of SEED, Oracle looks for the
associated parameter file under:
u $ORACLE_HOME/dbs/initSEED.ora (Unix)
u ORA_ROOT:[db_seed]PLUTO_SEED_init.ora (VMS)
254
Questions?
u Refer to the workbook for a sample init.ora file
n What is the default block size?
n Is the buffer cached defined in blocks or bytes?
n Can you have more than one value for the service_names
value?
n Which control file is read when the database is opened?
255
256
257
258
259
260
261
262
263
264
SQL> @?/rdbms/admin/catalog
SQL> @?/rdbms/admin/catproc
265
266
Data dictionary
u Composed of a set of tables and views
u Read-only
267
268
Data dictionary
u Scripts that construct the data dictionary
n CATALOG.SQL
u Commonly used data dictionary views
n CATPROC.SQL
u Scripts for PL/SQL on server
n NOTE: The owner of the data dictionary is SYS
269
270
271
Basics of Storage
u Tablespace - Logical storage area within an Oracle
Database that subdivides the database
n The placement and composition of a tablespace are
critical for optimization
u Data File - Physical files that make up a tablespace
n Size and structure should be well planned out
273
274
275
276
277
Example
278
Storage Considerations
u Object creation parameters override tablespace default
storage parameters with the exception of locally managed
tablespaces as of Oracle8i
u Locally managed tablespaces enforce the use of uniform
extent size or the size that has been autoallocated by Oracle
n One exception -- import (discussed in DBAII)
279
n Locally managed
u Never have tablespace fragmentation with uniform extents
u Never have to worry about extent growth with autoallocate
280
281
RAID
u RAID
n Important to have for an Oracle system
n Jbod – Lowest data cost – low overhead
n 0 – low data cost – load balancing
n 1, 0+1 – high data cost – most expensive
n 5 – Highest data cost – safe
u It takes four I/Os for one write (read data, read parity,write
data, write parity)
u Minimum of three disks, plus 66-87% of space
u The more disks, the higher the gain
282
283
Storage issues
u Disk contention
n Background process content for data access
u Segment fragmentation
n Seek time is reduced
u Free space fragmentation
n Cannot allocate a contiguous extent
284
Disk Contention
u Too many heavily used segments on a single disk slows
down access time and causes degradation in database
performance
285
286
Levels of Fragmentation
u Levels of fragmentation
n Application Interim Segment
u Data changes are moderate, allowing for some fragmentation
n UNDO Segments
u Used regularly with constant changes to data. Fragmentation is
high
n Temporary Segments
u Data is swapped in and out constantly. Fragmentation is highest
287
288
289
Segment Fragmentation
u Caused by segments requiring multiple extents
u Using a uniform extent size (i.e. locally managed
tablespaces) will alleviate this
u Manage this by monitoring dba_segments and
dba_free_space
290
Common Methodologies
u Uniform Extent sizes
n Eliminates unusable free space fragmentation
n Does not eliminate segment fragmentation
n Minimizes maintenance efforts
n Extent sizes should be carefully chosen to achieve
best performance
291
292
Common Methodologies
u Using Pctincrease 100
n Minimizes segment fragmentation
n Minimizes maintenance efforts
n Extent sizes grow exponentially
n Requires large free space chunks to be available
293
Dictionary Views
u DBA_FREE_SPACE
n How much free space is available
u DBA_SEGMENTS
n Information about all segments
u DBA_EXTENTS
n Describes the extents of all objects
294
295
u Agenda
n Theory behind rollback/UNDO segments
n Rollback/UNDO segments within an Oracle Database
n Rollback/UNDO segments used in transactions
n Rollback/UNDO segments used in read-consistency
297
298
UNDO Segments
u Undo management is new term for rollback
u Two options under 9i
n Manual undo management
u Oracle7/8i/9i rollback segments
n Automatic undo management
u AKA Automatic Undo Management (AUM) or System
Managed Undo (SMU)
299
300
301
302
303
304
UNDO values
u UNDO_TABLESPACE
n Defines the name of the tablespace used to hold the
undo segments
u UNDO_RETENTION
n Controls amount of undo data to retain
u Specify in seconds
u Read consistency and Oracle Flashback
305
UNDO Segments
u Discrete database objects
n Reside within a specific tablespace
306
307
308
u Cannot be deleted
309
310
311
Storage clause
u Allows the DBA to set the sizing of the rollback
segment(s)
u The DBA may allow Oracle to size the rollback
segment automatically
u MINEXTENTS for rollback segments must be ≥ 2
312
313
314
315
316
317
318
319
Statement is Executed
SQL> update emp set sal=30000 where empno=0500;
1 row updated.
320
Rollback Statement
u To undo changes
n Execute a ROLLBACK SQL statement
n This undoes the update statement and copies information back
into the table
SQL> rollback;
Statement processed.
321
322
Using Flashback
u User needs execute on DBMS_FLASHBACK
u Retention time must be long enough to be useful
u Query as usual after enabling Flashback
CALL dbms_flashback.enable_AT_time
('25-MAR-02:08:00:00');
SELECT * FROM emp;
CALL dbms_flashback_disable();
323
Dictionary Views
u V$rollstat
n Number of times a rollback segment has wrapped
n Number of times it has extended
n Number of times it has shrunk
u V$rollname
n Maps the rollback segment to its name by USN
324
325
Summary
u UNDO segments provide the user the ability to undo DML
statements within the database
326
u Agenda
n Create new Database Users
n Modify existing Database Users
n Monitor information about Database Users
n Drop Database Users
n Terminate user sessions
328
329
330
331
332
Create a User
u Example:
n Create a user SAISUSR with a password of u_pick_it
n Assign a default tablespace of USERS and a quota of 100KB on
the DEVELOPMENT tablespace
n Specify the temporary tablespace to be TEMP
n (Syntax is on the next slide.)
333
334
User Passwords
u During the CREATE USER command, the assigned
password echoes on the screen
u Note that the password is stored in encrypted form
u The encryption algorithm is DES-128 bit
335
Password Aging
u You can use Password Management
n Run the script utlpwmg.sql to start
u You can set
u Password attempts
u Grace periods
u History
u Many more!
336
337
338
339
340
u If the object is not yours, the only way you can see
the object(s) is for you to have been granted rights
to it.
341
342
343
u Unix
n Can connect as SYSDBA only if the user is in the DBA group
(defined under /etc/group)
u VMS
n Can connect as SYSDBA only if the user is granted the
ORA_<sid>_DBA identifier under SYS$SYSTEM:AUTHORIZE
u NT
n Can connect as SYSDBA only if the user is in the ORA_DBA
group
344
Altering Users
u Purpose: To change the authentication or
database resource characteristics of a database
user
u Several ways to make the change:
n ALTER USER SQL command
n OEM Management Console
n Other third-party tools
345
346
347
Dropping a User
u Drop a database user with the DROP USER SQL
statement and to optionally to remove the users’s
objects:
u Again, this can be done with OEM and SQL
DROP USER <username>
[CASCADE]
348
u Example
n Drop the user saisusr and include all objects in this
user's schema
349
350
351
352
353
354
355
OEM
356
357
358
u Example:
359
SID SERIAL#USERNAME
--- ------------------------
13 9 JOE
360
361
362
Summary
n Create new Database Users
n Modify existing Database Users
n Monitor information about Database Users
n Drop Database Users
n Terminate user sessions
363
Managing Resources
u Agenda
n Password management
365
Profiles
u Can be used to limit system and database
resources available to a user
u Define a set of resource limits
u Useful in large multi-user systems
u Simplifies resource management
366
367
368
369
370
Managing Resources
u When resource limits are enabled for a database, the
system creates a profile called DEFAULT
n Users who are not explicitly assigned a profile are assigned to
DEFAULT
n All unspecified limits in later profile definitions have the
corresponding value of DEFAULT
n Initially, all DEFAULT values are unlimited
n DEFAULT profile should not be modified. It will also affect SYS
and SYSTEM!
371
372
373
Managing Resources
u Example
n Create a profile called developer_profile
n Maximum of five concurrent sessions
n Unlimited CPU time for a call
n Maximum idle of 60 minutes
n (Syntax on next slide.)
374
Managing Resources
375
376
Managing Resources
377
Managing Resources
u Can change an existing user's profile in an ALTER
USER SQL statement
378
379
Managing Resources
u When a session-level resource limit has been
exceeded:
n The user’s current statement stops executing, and
all changes are rolled back
380
Managing Resources
u When a call-level resource limit has been
exceeded:
n Processing of the statement is halted
381
382
383
384
385
Managing Resources
u Alter the default profile
n Specify a maximum of 5 sessions, and 30 minutes of
idle time
SQL> alter profile default limit
2> sessions_per_user 5
3> idle_time 30
/
Profile altered.
386
Resource Composites
u Total resource usage may be limited through the use of
composite limits
n A composite weighted sum can only be used on these resource
limits:
n CPU_PER_SESSION
n CONNECT_TIME
n PRIVATE_SGA(MTS only)
n LOGICAL_READS_PER_SESSION
n Used to limit total resource usage for a session
387
388
Managing Resources
u Example:
n The DBA wants to set a composite limit of 1000 for the above
quantities
389
Managing Resources
SQL> alter resource cost
2> cpu_per_session 1
3> connect_time 1
4> logical_reads_per_session 1
5> /
Statement processed.
SQL>
390
391
Managing Resources
u In this example, if the total cpu_per_session,
connect_time and logical_reads_per_session
exceeds 2000, then a user exceeds his/her profile
limits
392
Managing Resources
u To remove a profile from the database, use the
DROP PROFILE SQL statement
393
394
Managing Resources
u Example
n Drop the profile developer_profile, and reassign all
users that had this profile to the DEFAULT profile.
395
Managing Resources
u Query the data dictionary to view information about profiles
defined in the database
u Views that hold information about profiles defined in the
database include:
n DBA_USERS (What profiles)
n DBA_PROFILES (What values)
n RESOURCE_COST (Composite limits)
n USER_RESOURCE_LIMITS (User limits)
396
397
Managing Resources
u Example
398
Password Limits
u Use for login attempts
u Password history
u Account management
u May need to run utlpwdmg.sql to set up password
management
399
400
Other Options
u Resource Consumer Groups
n Can give one set of user 75% CPU usage, another 25%
(*more in DBAII)
u SQL*plus command restrictions
n Use product_user_profile
n Restrict access to items like HOST,
SET <set command>, etc.
401
Summary
n Control resource usage within the database
402
404
405
406
407
408
409
410
411
412
413
414
415
416
417
u Example
n Allow sue to insert into the table emp
418
419
420
421
422
423
424
425
426
427
428
Summary
u Define database privileges
u Grant and control system privileges
u Grant and control object privileges
429
Role Management
u Agenda
n Describe roles
n Creating and modifying roles
n Manage roles
431
Role Management
u Privilege management can be tedious
n For example, if you have 100 users that each require the
following privileges:
u CREATE SESSION
u CREATE TABLE
u DROP TABLE
u SELECT ANY TABLE
n To assign these privileges, the DBA must execute each grant
for all 100 users
432
433
434
435
436
Role management
Privilege Role
CREATE SESSION Normal User
SELECT ANY TABLE
UPDATE ANY TABLE
User
Joeuser
437
Role management
u Create roles using the CREATE ROLE SQL
statement
CREATE ROLE <role name> [not identified | identified
{by password | using [schema.]package | externally |
globally}]
438
439
440
Role management
u After a role is created:
n Privileges may be assigned to roles in the same
manner they are assigned to users
n The assignments are done through GRANT SQL
statements
n (See next slide for syntax.)
441
442
Role management
u Once defined, a role can then be granted to users
n A role grant to a user grants all associated privileges
to the user
443
Role management
SQL> grant standard_user to user1;
Statement processed.
SQL> grant standard_user to user2;
Statement processed.
SQL> grant standard_user to user3;
Statement processed.
.
.
.
(etc)
444
445
Role management
SQL> grant update on spriden to standard_user;
Statement processed.
446
Role management
u Roles may also be granted to other roles
447
448
Role management
u The exception to this is that no role can be granted
to itself, even indirectly
449
Default Roles
u Users can have none or many default roles
u If no default role is assigned, all roles granted to
the user will be in effect throughout their session
u If a user has a default role and wants to set
another role, the user must issue the set role
command
450
451
Setting Roles
u A user may activate another role that he/she has previously
been granted using a SET ROLE SQL statement
u User Joe can set any role that he was granted during his
session.
u Refer to the workbook for the syntax
452
Role management
u If joe has a default role set for his user account,
then that role will be active for his entire session.
453
454
u If Joe wants to delete all the roles from table SPRIDEN, can
he simply log in and do this?
u If not, what must Joe do to give him the privilege?
455
456
457
458
459
460
Role management
u Banner Security
n Password-protected roles are the key to security in Banner
n In Banner, three roles are created :
u BAN_DEFAULT_CONNECT
u BAN_DEFAULT_Q <with password protection>
u BAN_DEFAULT_M <with password protection>
461
Role management
u BAN_DEFAULT_CONNECT
n Role consisting of the CREATE SESSION privilege
u Allows users to only connect to the database, but not
to have access to ANY objects
462
u BAN_DEFAULT_M
n Allows select / execute / insert / delete / update on all
objects
463
Role management
u All three roles are granted to EACH Banner user with
BAN_DEFAULT_CONNECT set as the default role
n See the next slide for the syntax.
464
Role management
SQL> grant ban_default_connect to saisusr;
Statement processed.
SQL> grant ban_default_q to saisusr;
Statement processed.
SQL> grant ban_default_m to saisusr;
Statement processed.
SQL> alter user saisusr default role ban_default_connect;
Statement processed.
465
466
Role management
u These roles are invoked ONLY when the user executes the
appropriate form
467
Cautions
u As described earlier, be aware of default roles
u Another one is if you grant a role with a system privilege
with admin option:
n A user with the role grants the system privilege to another user
n The role was dropped
n The new user with the system privilege will still have that
privilege!
468
469
Summary
n Describe roles
n Creating and modifying roles
n How Banner utilizes roles
n Methods of combining privileges for user group
activies
470
472
473
Local Connections
u Local connections are useful in some circumstances, such
as DBA tasks
u Local connections in many other cases are less useful.
They require that:
n An account is set up on the operating system level for all Oracle users.
This is a serious security problem, especially under UNIX where
numerous security holes exist with shell (/bin/sh, /bin/ksh) level
n The client resides on the same machine as the database server. This
reduces performance of the database server
474
475
N-tier Applications
u Distributes the workload associated to database
applications
u Introduced the N-tier Architecture
u Thin clients were now able to run applications
u Oracle Net allowed for distribution of the workload across
the network
476
Thin clients
u The client has now been transferred to a middle
tier
u The application load can now be spread over the
network
u Browser-based connections have now eliminated
fat PC requirements
477
478
Oracle Net
u An IP networking protocol
u Must be installed on both client and server machines before
remote connections can take place
u Defined as a session-level protocol that runs on top of
network and transport layers
u Under the OSI(Open Systems Interconnect) theoretical
network model
479
480
481
Oracle Net
u Installed to run under TCP/IP, since it is present on
virtually all machine types
u Easily configured
n Manually with any text editor
n Using a configuration assistant
482
Connection configuration
u Oracle Net Configuration Assistant
483
484
Oracle Net
u Either located in $ORACLE_HOME/network/admin or in the
location that is defined by the system
n $ORACLE_HOME/network/admin (Unix)
n TNS_ADMIN (VMS/NT)
485
Service Name(s)
u Registered by PMON which provides:
n Service name(s) for each running database
486
487
Oracle Net
u The executable that controls the listener is called
lsnrctl
n When you invoke this application you should see something
similar to:
LSNRCTL>
488
Oracle Net
u To start or stop a particular listener, you can
either enter the command at the prompt:
lsnrctl start <LISTENER_NAME>
489
490
Oracle Net
u To stop a listener, invoke lsnrctl and enter the
following:
LSNRCTL> stop <LISTENER_NAME>
491
Oracle Net
u Typically, the Oracle software owner starts/stop
the listener, although anyone in the dba group can
do so
u If someone other than ORACLE starts it, the log
file will be produced where the user is logged in at
492
493
Oracle Net
u Multiple listeners (cont.)
n If the DBA needs to restrict users from remotely logging into
specific databases while the databases are open, the databases
should be attached to separate listeners
494
Oracle Net
u The listener.ora file shown in the workbook defines:
495
496
Oracle Net
u To prevent users from remotely logging to the
TEST, for example, the DBA can shut down
SECONDLISTENER
497
498
499
Connection Management
u Oracle Net Manager
500
Oracle Net
u The tnsnames.ora file consists of a series of
database connect/host string definitions. Each
string defines a specific database which the client
can connect to.
u The basic syntax of these strings is shown in the
workbook.
501
502
Oracle Net
u While the DBA is free to choose any name she/he
wants as the host string, each value in the string
MUST match those defined in the corresponding
Oracle listener
u Port
u Host
u SID or Service Name
503
Oracle Net
u For an example of using the latter listener.ora file,
the workbook ilustrates the configuration
association of these.
504
505
Oracle Net
u Oracle clients require three parameters for remote
connects:
506
Oracle Net
u From the command line, setting up a remote
connection is very similar to that of a local
connection
n Start the desired Oracle client as before
n During the database logon specify a username
followed by an "@<connect string>" during the
username prompt
507
508
Oracle Net
u For example, to connect to SQL*PLUS from a GUI-based
session, you would enter the following:
509
Oracle Net
u The Oracle client first takes the host string specified in the
login and attempts to find a matching string in
tnsnames.ora
n If it finds a match, it attempts to find a listener running at the
specified host and port
n If an Oracle listener is found, the client application attempts to
locate a database with the SID as specified in the host string
n If the client finds this database, it takes the username and
password and attempts to login
510
511
Oracle Net
u Any Oracle system account can test the connect string with
TNSPING. This will test to see if the host machine is
listening and recognizes the connect string
u Sometimes DNS resolution gets in the way, you can specify
an IP for the HOST= parameter. It is faster
512
513
514
515
516
517
Tuning
u Packet transferring
n SDU
n TDU
u Server and dispatchers
u Connect time
u queuesize
518
Summary
n Describe the purpose and goal of Oracle Net
n Setup Oracle Net servers on the database host
n Setup Oracle Net clients that connect
to Oracle Net servers
519