0% found this document useful (0 votes)
36 views

Introduction To The Oracle Database

The document discusses Oracle database architecture including memory structures like the SGA and PGA, process structures like user processes and background processes, storage structures like data files and redo logs, and how to start up and shut down an Oracle database instance.

Uploaded by

adexprudent
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Introduction To The Oracle Database

The document discusses Oracle database architecture including memory structures like the SGA and PGA, process structures like user processes and background processes, storage structures like data files and redo logs, and how to start up and shut down an Oracle database instance.

Uploaded by

adexprudent
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 22

Security Level:

Basic Knowledge of Oracle

M2000 TSD

www.huawei.com

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential


 After learning this course, you will have a
basic knowledge of Basis information,
maintenance of the Oracle database and
the usage of SQL.

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 2


Oracle Database Architecture: Overview
Instance
Memory structures SGA Shared pool

Library
Database cache
User Server Redo log
buffer
process process buffer
cache Data dictionary
cache

Processes DBWn CKPT LGWR SMON PMON ARCn RECO Others

Database

Storage structures

Control Online redo


Data files files log files

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 3


Summary of Structural Components

 Memory structures:
 System Global Area (SGA): Database buffer cache, redo buffer, and
various pools
 Program Global Area (PGA)
 Process structures:
 User process and server process
 Background processes: SMON, PMON, DBWn, CKPT, LGWR, ARCn, and
so on
 Storage structures:
 Logical: Database, schema, tablespace, segment, extent, and Oracle
block
 Physical: Data files, control files, and redo log files

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 4


Oracle Database Memory Structures DB structures
Memory
- Process
- Storage

Server Server Background


PGA PGA PGA
process 1 process 2 process

Data dictionary SGA


Shared
cache
SQL area

Library Other
cache

Redo log Shared pool


buffer
Free memory
Database buffer I/O buffer
cache
Response Request
Java pool Streams queue queue
pool Large pool

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 5


Process Architecture DB structures
- Memory
 Process
 User process - Storage
 Is started when a database user or a batch process connects to Oracle
Database
 Database processes
 Server process: Connects to the Oracle instance and is started when a
user establishes a session
 Background processes: Are started when an Oracle instance is started

Instance

SGA Shared pool

Library
Database cache
Redo log
buffer
buffer
PGA cache Data dictionary
cache
User Server
process process Background processes
DBWn CKPT LGWR SMON PMON ARCn RECO Others

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 6


Database Storage Architecture DB structures
- Memory
- Process
 Storage

Control files Data files Online redo log files

Parameter file Backup files Archived redo log


files

Password file Alert log and trace files


HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 7
Logical and Physical Database Structures
Logical Physical

Database

Schema Tablespace Data file

Segment

Extent

Oracle data
OS block
block

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 8


Startup and Shutdown of Oracle

OPEN

STARTUP Start all files described in


Control file of the Instance
MOUNT

Open the
Control file
NOMOUNT

Start Instance

SHUTDOWN
SHUTDOWN

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 9


Instruction to the Oracle shutdown model

Shutdown model A I T N
Allow the new connection x x x x

Wait until the current connections finished x x x o


Wait until the current sessions finished x x o o
Execute the checkpoint by force and
shutdown all the files x o o o

Command format:
SQL> shutdown <Model> x NO
Shutdown model: o YES
• NORMAL
• TRANSACTIONAL
• IMMEDIATE
• ABORT

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 10


How to start and showdown the oracle
1.Execute the following commands 2. Run the following command to start the monitor:
to start oracle: ~>lsnrctl start
# su - oracle LSNRCTL for Linux IA64: Version 10.2.0.3.0 - Production on 22-SEP-
~> sqlplus / as SYSDBA 2008 00:35:31
SQL>startup Copyright (c) 1991, 2006, Oracle. All rights reserved.
ORACLE instance started. Starting /opt/oracle/oradb/home/bin/tnslsnr: please wait...
Total System Global Area 1610612736 ………………………………………………………………
bytes Service "PLSExtProc" has 1 instance(s).
Fixed Size 2046264 bytes Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this
Variable Size 385877704 bytes service...
Database Buffers 1207959552 bytes The command completed successfully
Redo Buffers 14729216 bytes • If the preceding message is displayed, you can infer that the
Database mounted. monitor is started.
Database opened.
Execute the following commands to shutdown oracle:
• If the preceding message is
displayed, you can infer that the # su - oracle
database is started. ~>sqlplus / as SYSDBA
• If the M2000 server applications SQL> shutdown immediate
are installed, the Oracle starts Database closed.
automatically upon the restart of Database dismounted.
the operating system. ORACLE instance shut down.
• If the preceding message is displayed, you can infer that the
database is stopped.

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 11


Check the status of Oracle
1. Run the following command to check whether 2.Check whether the user connection is
the database service is started: normal:
# ps -ef |grep ora |grep -v grep ~> sqlplus / as SYSDBA
oracle 28064 1 0 Sep01 ? 00:00:00 ora_pmon_ossdb
SQL>select PID, SPID, USERNAME from
oracle 28080 1 0 Sep01 ? 00:00:01 ora_mman_ossdb v$process;
oracle 28082 1 0 Sep01 ? 00:00:11 ora_dbw0_ossdb
PID SPID USERNAME
oracle 28084 1 0 Sep01 ? 00:01:01 ora_lgwr_ossdb
oracle 28086 1 0 Sep01 ? 00:00:01 ora_ckpt_ossdb ---------- ------------ ---------------
oracle 28088 1 0 Sep01 ? 00:00:14 ora_smon_ossdb 1
oracle 28090 1 0 Sep01 ? 00:00:00 ora_reco_ossdb 2 15156 oracle
oracle 28096 1 0 Sep01 ? 00:00:10 ora_mmon_ossdb 3 15158 oracle
oracle 28100 1 0 Sep01 ? 00:00:00 ora_mmnl_ossdb 4 15160 oracle
oracle 28118 1 0 Sep01 ? 00:00:00 ora_arc0_ossdb 5 15162 oracle
………………………………………………………
6 15164 oracle
oracle 28066 1 0 Sep01 ? 00:00:00 ora_vktm_ossdb
oracle 28070 1 0 Sep01 ? 00:00:00 ora_diag_ossdb 7 15166 oracle
oracle 28072 1 0 Sep01 ? 00:00:00 ora_dbrm_ossdb 8 15168 oracle
oracle 5974 1 0 00:35 ? 00:00:00 /opt/oracle/oradb/ 9 15170 oracle
home/bin/tnslsnr LISTENER -inherit • If the preceding message is displayed, yo
oracle 5979 1 0 00:36 ? 00:00:01 oracleossdb u can infer that the connection is
(LOCAL=NO) normal.
• Note: the system output contains at least the
seven processes in red, you can infer that the
database service and the monitor are started.

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 12


Query the version of Oracle
Command:
oracle@osssvr:~>sqlplus / as SYSDBA
SQL> select * from v$version;
BANNER ----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for Linux IA64: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
•From the output, we can see the version is 10.2.0.3.0.
•Now, we use this version in HP platform.
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for Linux: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
•From the output, we can see the version is 11.1.0.6.0.
•Now, we use this version in ATAE platform.

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 13


Alarm Logs
1.The location of alarm logs files with Oracle 11g.
• $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/bdump
• $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/cdump
• $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace

2.Pay more attention to the alarm file:


• $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace/alert_SID.log
• Example:/oracle/db/diag/rdbms/ora11g/ora11g1/trace/alert_ora11g1.log

3.Focus on ORA-XXXXX in the alarm file.

4.Query the error messages according to the error number:


oerr tool’s command: oerr <Error kind> <Error number>
Example:~> oerr ora 1652
• 01652, 00000, "unable to extend temp segment by %s in tablespace %s"
• // *Cause: Failed to allocate an extent of the required number of blocks for
• // a temporary segment in the tablespace indicated.
• // *Action: Use ALTER TABLESPACE ADD DATAFILE statement to add one or more
• // files to the tablespace indicated.

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 14


Info from Alarm logs
1.The abnormal status of Oracle:
Thu Jun 2 16:28:30 2005
Errors in file /database/oracle/admin/ora92/bdump/ora921_dbw0_26367.trc:
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/database/oracle/oradata/rdata10'
ORA-27037: unable to obtain file status
HP-UX Error: 2: No such file or directory
Additional information: 3
2.The switchover of redo log:
Sun Oct 05 02:05:20 2008
Thread 1 advanced to log sequence 2 (LGWR switch)
Current log# 2 seq# 2 mem# 0: /data/redo/redo02.log
Sun Oct 05 02:07:43 2008
Thread 1 advanced to log sequence 3 (LGWR switch)
Current log# 3 seq# 3 mem# 0: /data/redo/redo03.log
3.The parameter’s setting of Oracle
processes memory_target/memory_max_target cursor_sharing
audit_trail cluster_database log_archive_dest_1

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 15


Query the Oracle’s parameter
1.Query the system view:
select name, value from v$parameters
SQL> SET LIN(ESIZE)=2000
Name value
--------------- ----------
processes 150
Sessions 170
cpu_count 8
2.Query the parameter file:
• Can be the text pfile file. Ex:intiora921.ora.
• The default parameter file spfile is bin format. You can use command: SQL>create
pfile=‘/tmp/initora921.ora’ from spfile; to change it to PFILE.
3.SQL command:
• SQL>show parameter;
4.Alter the parameter:
• SQL> alter system set xxx=xxx scope=memory/spfile/both;

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 16


How to use SQlPlus
Login SQLPlus:~>sqlplus <user name>/<password> as <role>
Example:
• Login with SYS user and dba role: sqlplus sys/emsems as SYSDBA
• Login with OMCDB user and common role: sqlplus omcdb/emsems
Exit the sqlplus with exit command:
• SQL> exit
Query the version of sqlplus:
• ~> sqlplus -V
The syntax of SQLPlus:
• There are no difference between Cap and minuscule with table name, row,
view and key word .
• ”” and ’’ are different in Oracle. ”” stands for objects or row name, ’’ stands
for the variable of character string
How to get the help:
• SQL>HELP <TOPICS>;
• SQL>HELP INDEX; .
DESCRIBE the structure of table:
• SQL>DESC <table name>

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 17


Query, update and control
1. Data Query:
• select from tablename where/group by/having/order by
Note:
• Where : Supported operator are =,<>, ! =,>=,<=,in,between,like ( %_ ) ,is null or
is not null , not , or , and.
• order by: asc (default)) or desc
2. Data update:
• insert into tablename(l1,l2) values(v1,v2);
• insert into tablename ( rowlist ) select ;
• update tablename set rowname1=, rowname2= where
• delete from tablename where
3. Session control:
• commit
• set autocommit on
• rollback
• savepoint

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 18


The useful setting with SQLPLus
@/sta[rt] Runs the specified command file.
l[ist] Lists one or more lines of the SQL buffer.
/ Executes the SQL command or PL/SQL block.
spool Spool the output to a file.
spool off Stop the Spool.
Sets a system variable to alter the SQL*Plus
set
environment for your current session.
The LONG data will wrap on your screen; SQL*Plus will not
set long n
truncate until the set character.
The length of the command and the PL/SQL statement cannot
set line n
exceed the length defined by SET LINESIZE.
set pagesize n Set the page size.
set linesize n Set the row number of displayed characters .
set feedback off Don’s display the row numbers of the result. Default is on.
set heading off Don’s display the row name of the structure. Default is on.
set echo off Don’t display the command line of @ script. Default is off.
To spool output generated by commands in a command file without
set termout off
displaying the output on the screen, use SET TERMOUT OFF.
HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 19
The useful SQL Comands(1)
Use UNIX or Linux command SQL> !<Command>
Query the structure of tables SQL>DESC <table name>
Query all the sessions SQL> select * from v$session;
Query the events waited by session SQL> select * from v$session_wait;
Query the locked object SQL> select * from v$locked_object;
Query the status of SGA SQL> select * from v$SGA;
Query the data file used by database SQL> select name, bytes from v$datafile;
SQL> select sum(bytes) / 1048676 from user_extents
Query the used space of Table/Index
where segment_name=‘T_PUB_COMMONINFO’;
Query the table space SQL> select * from dba_tablespaces;
Query the objects of current user SQL> select * from user_objects;
Query the constraints of current user SQL> select * from user_constraints;

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 20


The useful SQL Commands(2)

SQL> alter index idx_commoninfo rebuild;


Rebuild the index
SQL> alter index idx_commoninfo rebuild online;
SQL> Alter database add logfile group 5
Add the log file group
('/dev/vgdata/rlv_redo51', '/dev/vgdata/rlv_redo52') size 200M;
Delete the log file group SQL> Alter database drop logfile group 5;
Switch the log file group
SQL> Alter system switch logfile;
manually
Query the size of SGA SQL> Show sga;
Query the location of
SQL> show parameter pfile;
parameter file
Query the Monitor lsnrctl status

Query the version of Oracle SQL> select * from v$version;

HUAWEI TECHNOLOGIES CO., LTD. Huawei Confidential Page 21


Thank you
www.huawei.com

You might also like