Configuring Multipathing for Oracle Linux and Oracle ZFS Storage ...
OCA 05 - Configuring the Oracle Network Environment
-
Upload
muhammad-asghar-khan -
Category
Documents
-
view
99 -
download
0
description
Transcript of OCA 05 - Configuring the Oracle Network Environment
05 - Configuring the Oracle Network Environment
By Muhammad Asghar Khan
Reference: OCA Oracle Database 11g - Admin I Exam Guide by John Watson
http://asghars.blogspot.com2
Agenda Configure and Manage the Oracle Network
Oracle Net Establishing a Session Methods of Name Resolution Listener Net Manager TNS Ping Database Links EXERCISE 5-1 Configure Oracle Net
Use the Oracle Shared Server Architecture EXERCISE 5-2: Set Up a Shared Server Environment
1/1
http://asghars.blogspot.com3
Configure and Manage the Oracle Network Oracle calls its set of connectivity solutions Oracle
Net Oracle Net
In the Oracle environment, no user has direct access to the database
A user interacts with a user process (e.g. SQL *Plus) The server process is a process running on the
database server machine that executes the SQL it receives from the user process
The execution of a SQL statement goes through four stages: parse, bind, execute, and fetch
1/23
http://asghars.blogspot.com4
Configure and Manage the Oracle Network Parse Phase
Server process works out what the statement actually means, and how best to execute it
Bind Phase Any variables used in SQL statement are expanded to
literal values Execute Phase
Data in the database buffer cache will be read or updated and changes written to the redo log buffer
If the relevant blocks are not in the database buffer cache, server process will read them from the datafiles
This is the only point in the execution of a statement where the database itself is involved
2/23
http://asghars.blogspot.com5
Configure and Manage the Oracle Network Fetch Phase
The server process sends the result set generated by the statement’s execution back to the user process, which should then format it for display
Oracle Net provides the mechanism for launching a server process to execute code on behalf of a user process, this mechanism is called establishing a session
A user interacts with a user process; a user process interacts with a server process, via Oracle Net; a server process interacts with the instance; and the instance, via its background processes, interacts with the database
3/23
http://asghars.blogspot.com6
Configure and Manage the Oracle Network Oracle Net is a layered protocol: it runs on top of
whatever communications protocol is supported by your operating system
These protocols may include TCP, TCP with secure sockets, Windows Named Pipes (or NMP), and the newer Sockets Direct Protocol (or SDP) over Infiniband high-speed networks
For local connections where the user process is on the same machine as the server Oracle Net uses the Inter –Process Communication (or IPC) protocol
Oracle Net maps on to layers five, six, and seven: the session, presentation, and application layers of OSI model
4/23
http://asghars.blogspot.com7
Configure and Manage the Oracle Network Establishing a Session
When a user, through his user process, wishes to establish a session against an instance, he will issue a command something likeCONNECT SCOTT/TIGER@ORCL
The database user name (“SCOTT”), and password (“TIGER”) are separated by a “/” as a delimiter
The “@” symbol is followed by a connect string “ORCL”
The “@” symbol is an indication to the user process that a network connection is required to an instance on a remote machine
5/23
http://asghars.blogspot.com8
Configure and Manage the Oracle Network If the “@” and the connect string are omitted, then
the user process will assume that the instance you wish to connect to is running on the local machine, and that the always-available IPC protocol can be used
Local instance connection does not require a database listener; indeed, local connections do not require any configuration at all
The only information needed is to tell your user process which instance you want to connect to
You give the process this information through an environment variable
6/23
http://asghars.blogspot.com9
Configure and Manage the Oracle Network If your connect statement includes the connect string
“@orcl,” Oracle Net has to work out what is meant by “orcl”, this is calle name resolution
This means that the string has to be resolved into certain pieces of information: Protocol you want to use, IP address/Host name on which the database listener is
running, Port that the listener is monitoring for incoming
connection requests, and the Name of the instance /service
7/23
http://asghars.blogspot.com10
Configure and Manage the Oracle Network Methods of Name Resolution
Oracle provides four methods of name resolution: easy connect, local naming, directory naming, and external naming
Easy Connect It is limited to one protocol: TCP Easy Connect cannot be used with any of Oracle Net’s more
advanced capabilities such as load balancing or connect-time failover across different network routes
DBA find it very handy to use, but it is not a method of much use for your end users
You invoke it with a syntax such as this as your connect string:
8/23
http://asghars.blogspot.com11
Configure and Manage the Oracle Network connect scott/[email protected]:1522/orcl SQL*Plus will use TCP to go to port 1522 on the IP address to
which the hostname resolves Then if there is a listener running on that port and address, it
will ask the listener to spawn a server process against an instance that is part of the service called orcl
Local Naming With local naming the user supplies Oracle Net service alias for
the connect string, and the alias is resolved by a local file (tnsnames.ora) into the full network address (protocol, address, port, and service or instance name)
The tnsnames.ora file is a client-side Consider this example of a tnsnames.ora file:
9/23
http://asghars.blogspot.com12
Configure and Manage the Oracle Networkorcl = (DESCRIPTION =
(ADDRESS_LIST =(ADDRESS =
(PROTOCOL = TCP)
(HOST = pwr.financekpp.gov.pk)
(PORT = 1522))
)
(CONNECT_DATA = service_name = orcl)
)
) The alias orcl what your users will provide in their connect
statements Local naming supports all protocols and all the advanced
features of Oracle Net, but maintaining tnsnames.ora files on all your client machines can be an extremely time-consuming task
10/23
http://asghars.blogspot.com13
Configure and Manage the Oracle Network Directory Naming
Directory naming points the user toward an LDAP directory server to resolve aliases
Oracle provides an LDAP server (the Oracle Internet Directory) as part of the Oracle Application Server, but you do not have to use that—if you already have a Microsoft Active Directory
Directory naming supports all Oracle Net features External Naming
It is conceptually similar to directory naming, but it uses third-party naming services such as Sun’s Network Information Services (NIS+) or the Cell Directory Services (CDS)
11/23
http://asghars.blogspot.com14
Configure and Manage the Oracle Network Listener
When a client request reached the listener, the listener selects an appropriate service handler (a dispatcher or dedicated server) to service the client’s request and forwards the client’s request to it
The listener configuration is stored in a configuration file named listener.ora. Whose default location is the $ORACLE_HOME/network/admin directory
A listener spawn server processes against an instance In order to do this, it needs to know what instances are
available on the computer on which it is running A listener finds out about instances by the process of
“registration”
12/23
http://asghars.blogspot.com15
Configure and Manage the Oracle Network There are two methods for registering an instance
with a database: static and dynamic Static Registeration
For static registration, you hard-code a list of instances in the listener.ora file
If you have older databases (prior to 8i) that your listener must connect users to, you will have to register them statically
Also some applications may require static registration: typically management tools
To register an instance statically, add an appropriate entry to the listener.ora file:
13/23
http://asghars.blogspot.com16
Configure and Manage the Oracle Network SID_LIST_LIST2 = (SID_LIST = (
SID_DESC = (ORACLE_HOME =
/u01/oracle/app/product/11.2.0/db_1) (SID_NAME = orcl))
)
This entry configure the listener called LIST2 to accept connection requests for an instance called orcl
The directive ORACLE_HOME is only required if the database listener is not running from the same Oracle Home as the instance
This directive will let the listener find the executable file that it must run to launch a server process
14/23
http://asghars.blogspot.com17
Configure and Manage the Oracle Network Dynamic Registration
This is the preferred method by which an instance will register with a listener
Dynamic registration requires no configuration at all if your listener is running on the default port, 1521
The initialization parameter local_listener, tells the instance the network address that it should contact to find a listener with which to register
At instance startup time, the PMON process will use this parameter to locate a listener, and inform it of the instance’s name and the names of the service(s) that the instance is offering
15/23
http://asghars.blogspot.com18
Configure and Manage the Oracle Network The instance name is defined by the instance_name parameter, and the service_names parameter will have defaulted to this suffixed by the db_domain parameter
You will need to register your instance with the listener with “alter system register” if you have restarted the listener, or if you started the database instance before starting the listener
If your listener is not running on the default port on the address identified by the hostname, you must specify where the listener is by setting the parameter local_listener and reregistering
16/23
http://asghars.blogspot.com19
Configure and Manage the Oracle Network alter system set local_listener=list2;
alter system register;
You can start and stop listeners through Database Control, but there is also a command-line utility lsnrctl
lsnrctl start [listener name] The STATUS command provides basic status information
about a listenerlsnrctl status [listener name]
The SERVICES command provides detailed information about the services and instances registered with a listener and the service handlers allocated to each instance
lsnrctl services [listener name]
17/23
http://asghars.blogspot.com20
Configure and Manage the Oracle Network Net Manager
It is a stand-alone Java utility, shipped with all the Oracle client-side products
Use the net manager, to configure the clients to use the desired name resolution method
To launch the net manager run netmgr from an OS prompt
The net manager navigation tree has three branches:
18/23
http://asghars.blogspot.com21
Configure and Manage the Oracle Network Profile
It is used to set options that may apply to both the client and server sides of Oracle Net and can be used to influence the behavior of all Oracle Net connections
When you take the Profile branch you are in fact configuring a file called sqlnet.ora
Sqlnet.ora contains settings that apply to all connections and listeners, such as security rules and encryption
There are defaults for every sqlnet.ora directive—but you will usually configure it if only to select the name resolution method
19/23
http://asghars.blogspot.com22
Configure and Manage the Oracle Network Service Naming
It is used to configure client-side name resolution It edits the Local Naming tnsnames.ora file This file exists in your ORACLE_HOME/network/admin
directory Listeners
Listeners branch is used to configure database listeners
20/23
http://asghars.blogspot.com23
Configure and Manage the Oracle Network TNS Ping
To test a connect string, use the TNSPING utility
tnsping orcl This will accept a connect string, locate the Oracle
Net files, resolve the string, and send a message to the listener
If the listener is running and does know about the service requested, the test will return successfully
21/23
http://asghars.blogspot.com24
Configure and Manage the Oracle Network Database Links
Oracle Net can also be used for communications between databases
A user session against one database can execute SQL statements against another database
This is done through a database link Simple example of database link creation is: create database link prodscott connect to scott identified by tiger using 'prod';
22/23
http://asghars.blogspot.com25
Configure and Manage the Oracle Network This defines a database link from the current
database to a remote database identified by the connect string PROD
You can issue statement through a link as select * from emp@prodscott;
23/23
http://asghars.blogspot.com26
EXERCISE 5-1 Configure Oracle Net1. Create a directory to be used for the Oracle Net
configuration files, and set the TNS_ADMIN variable to point to this
2. Start the Net Manager. The top line of the Net Manager window will show the location of the Oracle Net files. If this is not the new directory, then the TNS_ADMIN variable has not been set correctly
3. Create a new listener: expand the Local branch of the navigation tree, highlight Listeners, and click the +
1/10
http://asghars.blogspot.com27
EXERCISE 5-1 Configure Oracle Net4. Enter a listener name, NEWLIST, and click OK
5. Click Add Address
6. For Address 1, choose TCP/IP as the protocol and enter 127.0.0.1 as the host, 2521 as the port
2/10
http://asghars.blogspot.com28
EXERCISE 5-1 Configure Oracle Net7. Create a new service name: highlight Service
Naming in the navigation tree, and click the +
8. Enter NEW as the net service name, and click Next
9. Select TCP/IP as the protocol, and click Next
10. Enter 127.0.0.1 as the host name and 2521 as the port and click Next
11. Enter SERV1 as the Service Name, and click Next. Click Finish
3/10
http://asghars.blogspot.com29
EXERCISE 5-1 Configure Oracle Net
12. Save the configuration by clicking File and Save Network Configuration. This will create the listener.ora and tnsnames.ora files in the TNS_ADMIN directory
4/10
http://asghars.blogspot.com30
EXERCISE 5-1 Configure Oracle Net13. Use an editor to check the two files
5/10
http://asghars.blogspot.com31
EXERCISE 5-1 Configure Oracle Net14. Start the listener with lsnrctl
6/10
http://asghars.blogspot.com32
EXERCISE 5-1 Configure Oracle Net15. From an operating system prompt, test the
connect string with tnsping new
16. Connect to your database using operating system authentication, bypassing any listener
7/10
http://asghars.blogspot.com33
EXERCISE 5-1 Configure Oracle Net17. Set the service_names and local_listener
parameters for the running instance and register the new service name with the new listener
8/10
http://asghars.blogspot.com34
EXERCISE 5-1 Configure Oracle Net18. From an operating system prompt, confirm that
the new service has registered with the new listener
9/10
http://asghars.blogspot.com35
EXERCISE 5-1 Configure Oracle Net19. Confirm that the new network environment is
functional by logging on
system/oracle@new
10/10
http://asghars.blogspot.com36
Use the Oracle Shared Server Architecture As more users log on to your instance, more server
processes get launched The database listener can launch as many processes
as required If you have a large number of concurrent
connection requests, your listener will have to queue them up
You can avoid this by running multiple listeners on different ports, and load-balancing between them
1/8
http://asghars.blogspot.com37
Use the Oracle Shared Server Architecture But your operating system may well have limits on
the number of processes that it can support, limits to do with context switches and with memory
A computer can only do one thing at once unless it is an SMP machine, in which case each CPU can only do one thing at once
The operating system simulates concurrent processing by using an algorithm, often referred to as a time slicing or time-sharing algorithm
Context switches are very expensive
2/8
http://asghars.blogspot.com38
Use the Oracle Shared Server Architecture As more users connect to the instance, the operating
system has to context-switch between more and more server processes
There may also be memory problems that occur as more sessions are established
The PGA is a block of memory associated with each server process, to maintain the state of the session and as a work area for operations such as sorting rows
This is why your system may begin to swap as more users log on
3/8
http://asghars.blogspot.com39
Use the Oracle Shared Server Architecture There comes a point, performance begins to
degrade because of operating system inefficiencies in managing context switches and paging
These are not Oracle’s problems, but to overcome them Oracle offers the option of the shared server architecture
Shared server is implemented by additional processes that are a part of the instance
There are two new process types: dispatchers and shared servers
4/8
http://asghars.blogspot.com40
Use the Oracle Shared Server Architecture The dispatchers run on a unique TCP port When a user process contacts a listener the listener
passes back the address of a dispatcher When a user process issues a SQL statement, it is sent to
the dispatcher The dispatcher puts all the statements it receives onto a
queue This queue is called the common queue, because all
dispatchers share it All the shared server processes monitor the common
queue
5/8
http://asghars.blogspot.com41
Use the Oracle Shared Server Architecture From then execution proceeds through the usual
parse-bind-execute cycle, but when it comes to the fetch phase the shared server puts the result set onto a response queue that is specific to the dispatcher that received the job
Each dispatcher monitors its own response queue, and whenever any results are put on it, the dispatcher will pick them up and fetch them back to the user process that originally issued the statement
The state of the session is maintained in SGA
6/8
http://asghars.blogspot.com42
Use the Oracle Shared Server Architecture The memory used in the SGA for each shared server
session is known as the user global area (UGA) and includes all of what would have been in a PGA with the exception of the session’s stack space
Shared server configuration needs two set dispatchers and shared_servers parameters
shared_servers controls the number of shared servers that will be launched at instance startup time
7/8
http://asghars.blogspot.com43
Use the Oracle Shared Server Architecture The dispatchers parameter controls how many
dispatcher processes to launch at instance startup time, and how they will behave
To enable the shared server architecture, adjust the two critical parameters as follows:
alter system set
dispatchers='(dispatchers=2)(protocol=tcp)';
alter system set shared_servers=20;
8/8
http://asghars.blogspot.com44
EXERCISE 5-2: Set Up a Shared Server Environment1. Continues from Exercise 5-1
2. Set the dispatchers and shared_servers parameters and register with the listener as follows
1/3
http://asghars.blogspot.com45
EXERCISE 5-2: Set Up a Shared Server Environment3. Confirm that the dispatchers and shared servers
have started by querying the view V$PROCESS. Look for processes named S000, S001, S002, S003, D000, and D001:
4. From an operating system prompt, confirm that the dispatchers have registered with the listener
2/3
http://asghars.blogspot.com46
EXERCISE 5-2: Set Up a Shared Server Environment
3/3