Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1/1
Agenda
Connecting to Database Database Startup Database Shutdown Setting Database Initialization Parameters
1/5
The three components (database instance, database listener, and optionally Database Control) have their own command-line utilities that can be used for startup In single instance environment Oracle Corporations recommended sequence for starting a database is to start Database Control, then the database listener, and then the database Starting a Database Control
Database Control is a tool for managing only one database The configuration of Database Control will have been done at database creation time
http://asghars.blogspot.com
2/5
To start Database Control, use the emctl utility. This will be located in the ORACLE_HOME/bin directory
emctl start|status|stop dbconsole
For any of these commands to work, three environment variables must be set: PATH, ORACLE_HOME, and ORACLE_SID Figure shows the startup of Database Control
http://asghars.blogspot.com
3/5
To connect to Database Control, use any reasonably upto-date browser with URL https://hostname:port/em The port number can be find by using the emctl status dbconsole command or alternatively, you can look in the file ORACLE_HOME/install/portlist.ini To see the Database Control logon window the database listener and instance must be running The database listener is a process that monitors a port for database connection requests
http://asghars.blogspot.com
4/5
There are three ways to start the database listener: With the lsnrctl utility With Database Control As a Windows service (Windows only) The lsnrctl utility is in the ORACLE_HOME/bin directory. The key commands are:
lsnrctl start|status [listener]
Where listener is the name of listener Figure on next slide shows the startup of default listener
http://asghars.blogspot.com
5/5
http://asghars.blogspot.com
1/5
Connecting to Database
An instance may be started and stopped A database is mounted and opened, and then dismounted and closed This can be done from either SQL*Plus or through Database Control Ordinary users cannot start up or shut down a database This is because ordinary users are authenticated against data dictionary which cannot be read until the database is open You must therefore connect with some form of external authentication: i.e by OS or external password file
8 http://asghars.blogspot.com
2/5
Connecting to Database
The syntax of the CONNECT command tells Oracle what type of authentication you wish to use: the default of data dictionary authentication, password file authentication, or operating system authentication
http://asghars.blogspot.com
3/5
Connecting to Database
In these examples;
The connect_alias will be resolved to a connect string, this is necessary if the connection is to be made across a network The first example is normal, data dictionary, authentication The second two examples instruct Oracle to go to the external password file to validate the username/password combination The last two examples use operating system authentication; Oracle will go to the host operating system and check whether the operating system user running SQL*Plus is a member of the operating system group that owns the Oracle software
http://asghars.blogspot.com
10
4/5
Connecting to Database
Database Control will by default attempt to connect through a listener, but it can also use operating system authentication SYSOPER and SYSDBA are special privileges with special capabilities They can only be enabled when users are connecting with an external authentication method: either operating system or password file You may be wondering what Oracle user you are actually logging on as when you use operating system authentication
11 http://asghars.blogspot.com
5/5
Connecting to Database
user
command
The SYSDBA privilege logs you on to the instance as user SYS The SYSOPER privilege connects you as a user PUBLIC
12
http://asghars.blogspot.com
1/13
Database Startup
When you start up a database, you create an instance of that database and you determine the state of the database When you issue a startup command, Oracle will attempt to locate a parameter file
Oracle will work its way down the list, using the first file it finds and ignoring the rest. If none of them exist, the instance will not start
13 http://asghars.blogspot.com
2/13
Database Startup
The startup process is staged: whenever you issue a startup command, it will go through these stages:
14
http://asghars.blogspot.com
3/13
Database Startup
SHUTDOWN State
When the database is SHUTDOWN, all files are closed and the instance does not exist In NOMOUNT mode, the instance has been built in memory (the SGA has been created and the background processes started, according to the parameter file), but no connection has been made to a database
NOMOUNT State
15
http://asghars.blogspot.com
4/13
Database Startup
The startup process with NOMOUNT mode is described graphically in the figure Database is started in NOMOUNT state during:
16
http://asghars.blogspot.com
5/13
Database Startup
MOUNT State
Associating database with instance Instance locates and reads the control file using control_files parameter Obtaining names & statuses of data and online redo log fiels by reading the control file
Renaming data files Enabling & disabling online redo log file archiving Performing database recovery
http://asghars.blogspot.com
17
6/13
Database Startup
The startup process with MOUNT mode is described graphically in the figure
OPEN State
18
7/13
Database Startup
In OPEN state all the data files and online redo log files are checked fro consistency, if required the SMON perform the instance recovery The overall startup process is described graphically
19
http://asghars.blogspot.com
8/13
Database Startup
20
http://asghars.blogspot.com
9/13
Database Shutdown
Shutdown require either a SYSDBA or a SYSOPER connection Following are the different shutdown modes:
NORMAL TRANSACTIONAL IMMEDIATE ABORT In normal shutdown, no new connection is allowed and the database will wait for all currently connected users to disconnect
http://asghars.blogspot.com
NORMAL
21
10/13
Database Shutdown
Typically, a normal shutdown is useless: there is always someone logged on, even if it is only Database Control itself
TRANSACTIONAL
In transactional shutdown mode no new connection and transcation is allowed, wait for all the transactions to complete It prevents clients from losing work
22
http://asghars.blogspot.com
11/13
Database Shutdown
IMMEDIATE
In immediate shutdown mode no new connection and transaction is allowed, any uncommited transactions are rolledback and disconnects all connected users Next startup will not require instance recovery
ABORT
In abort mode no new connection and transaction is allowed, uncommited transactions are not rollback and all connected users are implicitly disconnected
http://asghars.blogspot.com
23
12/13
Database Shutdown
A shutdown abort will not damage the database, but some operations (such as backups) are not advisable after an abort
The normal, immediate, and transactional shutdown modes are usually referred to as clean, consistent, or orderly shutdowns In clean shutdowns:
PMON will roll back any incomplete transactions Then a checkpoint is issued, which forces the DBWn to write all updated data from the database buffer cache down to the datafiles
http://asghars.blogspot.com
24
13/13
Database Shutdown
LGWR also flushes any change vectors still in memory to the log files
The abort mode, sometimes referred to as a disorderly shutdown, leaves the database in an inconsistent state Which must be repaired by instance recovery
There is a startup command startup force that can save time. It is two commands in one: a shutdown abort followed by a startup
25
http://asghars.blogspot.com
1/5
The parameters used to build the instance initially come from either the parameter file (pfile or spfile) or from defaults Every parameter has a default, except for the DB_NAME parameter; this must always be specified
2/5
Parameters that can be changed while the instance is running called dynamic parameters while static parameters are fixed at instance startup time To view the parameters and their current values
select name,value from v$parameter order by name;
V$PARAMETER shows the parameter values currently in effect in the running instance while V$SPPARAMETER shows the values in spfile on disk
27
http://asghars.blogspot.com
3/5
The views can also be seen through Database Control. From the database home page, take the Server tab and the Initialization Parameters link
28
http://asghars.blogspot.com
4/5
Note; If the instance is started with a pfile, then SCOPE=SPFILE will fail
29
http://asghars.blogspot.com
5/5
30
http://asghars.blogspot.com
1/2
Run sqldeveloper Connect as user SYS, with the SYSDBA privilege Check whether basic parameters have all been set or are still on default
2) 3)
31
http://asghars.blogspot.com
2/2
All the basic parameters should be considered, investigated to see if the default is appropriate Change the PROCESSES parameter to 200. This is a static parameter. The next illustration shows how to do this by specifying a SCOPE and then bouncing the database
5)
32
http://asghars.blogspot.com
1/2
The alert log (alert_ SID.log) is a continuous record of critical operations applied to the instance and the database Alert log location is determined by the instance parameter BACKGROUND_DUMP_DEST
For many DBAs, the first thing they do when they are asked to look at a database for the first time is locate the alert log and scan through it, just to get an idea of what has been going on
The trace files are generated by the various background processes, usually when they hit an error
33 http://asghars.blogspot.com
2/2
34
http://asghars.blogspot.com
1/1
2.
35
http://asghars.blogspot.com
1/4
The data dictionary is metadata: data about data User definitions, security information, integrity constraints, and (from release 10 g onward) performance monitoring information are all part of the data dictionary It is stored in the SYSTEM and SYSAUX tablespaces To query the dictionary, Oracle provides a set of views. The views come in three forms, prefixed DBA_, ALL_, or USER_
36 http://asghars.blogspot.com
2/4
Any view prefixed USER_ will be populated with rows describing objects owned by the user querying the view Any view prefixed ALL_ will be populated with rows describing objects to which you have access (given permission) Any view prefixed DBA_ will have rows for every object in the database Some of those commonly used by DBAs are:
37
DBA_OBJECTS
http://asghars.blogspot.com
3/4
The dynamic performance views give access to a phenomenal amount of information about the instance, and (to a certain extent) about the database The dynamic performance views are created at startup, updated during the lifetime of the instance, and dropped at shutdown
38 http://asghars.blogspot.com
4/4
Dynamic performance views are populated from the instance or the controlfile
39
http://asghars.blogspot.com
1/1
2.
40
http://asghars.blogspot.com