Professional Documents
Culture Documents
C H A P T E R 3
ORACLE NETWORKING:
CONFIGURING BASIC
NET8/SQL*NET
COMPONENTS
CHAPTER OBJECTIVES
In this chapter, you will learn about:
✔ Setting Up Networking Configuration Files Page 58
✔ Managing the Oracle Listener Page 67
✔ Configuring the Multi-Threaded Server Page 76
N ow that your database is running, the next step involves setting up the basic
Oracle networking components. This additional step makes the database
available to users—such as those you will create in Chapter 10, “Privileges and
Resource Groups” over a network. The topic of Oracle networking involves many
different components and many different implementations. This chapter focuses
on basic networking components, including the dedicated server configuration
and multi-threaded server configuration using the TCP/IP protocol.
57
ch03.qxd 10/30/2000 2:49 PM Page 58
SETTING UP NETWORK
CONFIGURATION FILES
LAB OBJECTIVES
In this lab, you will:
✔ Manually Configure the tnsnames.ora File
✔ Manually Configure the listener.ora File
There are two possible configurations for the server process. In the dedicated server
configuration, one server process is started for each client connection to the data-
base. This server process is then dedicated to serving only that connection’s
request. In the multi-threaded server configuration, shared servers perform most of
the same tasks as the dedicated server. The main difference is that, where a dedi-
cated server only supports one client, a shared server supports one or more
clients. The ability to support multiple client connections can be useful if the
number of requests made by each client connection is low. Therefore, a dedicated
server configuration would be useful for operations such as a batch load of data
into the database, whereas a multi-threaded server configuration would be more
appropriate for supporting many clients, each of which periodically performs
transactions on the database that affect small amounts of data.
• tnsnames.ora
• listener.ora
ch03.qxd 10/30/2000 2:49 PM Page 60
Note that there are several other configuration files that are used, depending on
LAB your Oracle networking needs. For example, the sqlnet.ora file is used for config-
3.1 uring logging and tracing for database connection problems, and setting Oracle
Advanced Security parameters, among others. For the simple network configura-
tion in theses exercises, you will work with only the tnsnames.ora and listener.ora
configuration files.
These files can be found in a location known as the TNS_ADMIN directory. The
location of this directory depends on the version of the Oracle Server that is
installed. For versions 7.x and 8.1.x, the TNS_ADMIN directory is usually at
ORACLE_HOME\network\admin; for version 8.0.x, it is usually at ORACLE_
HOME\net80\admin. Occasionally, you will find an installation that uses an
environment variable named TNS_ADMIN to point to the location of the network
configuration files. If a TNS_ADMIN environment variable is used, the DBA must
make sure that the configuration files are moved to the new TNS_ADMIN
location.
The listener.ora file simply contains configuration information for the Oracle lis-
tener. The tnsnames.ora file is used in defining TNS service names. “TNS,” which
stands for Transparent Network Substrate, serves as a single, common interface to
most industry-standard networking protocols. TNS service names are resolved in
the tnsnames.ora file, which contains information on where to locate particular
databases. For example, you might define a TNS service name called DEV. In
tnsnames.ora, the configuration information for DEV may indicate that the lis-
tener for this database is located at Port 1521 on IP address 111.222.333.444 (or
the name of the machine at that address) and listens for connection requests to a
database called “dev”. Note that in these exercises, the tnsnames.ora file is con-
figured on the database server. For many client or front-end environments, there
is usually a tnsnames.ora file to support connections to the database. Oracle is
slowly moving away from using these files that support TNS service names, and
moving towards the use of the Oracle Names Server. For more information on the
Oracle Names Server, see the Oracle document “Net8 Administrator’s Guide.”
In these exercises, you will set up two TNS service names. The first will allow you
to connect to your own database through Net8. The second is optional, and will
allow you to connect to a second, remote database.
ch03.qxd 10/30/2000 2:49 PM Page 61
If you have access to a database other than your own, you can configure connec-
tivity to it by performing the following steps on the “example01” TNS service
name in the above template:
Once you have entered configuration information for this optional TNS service
name into tnsnames.ora, you can open SQL*Plus and attempt to connect to the
database it represents using the following syntax:
CONNECT <username>/<password>@<TNSservicename>
In the next exercise, you will configure and start the Oracle listener for your own
database. You will configure a TNS service name for the database that you created
in Chapter 2.
In these exercises, you will configure the listener for your own database. The
listener.ora file, which is the configuration file for the listener, is kept in the
TNS_ADMIN directory. It contains information such as the name of the listener,
ch03.qxd 10/30/2000 2:49 PM Page 63
####################################
# FILENAME: listener.ora #
# LAST MODIFIED: March 24, 2000 #
####################################
LISTENER =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = production)
(PORT = 1521)
)
)
STARTUP_WAIT_TIME_LISTENER = 0
CONNECT_TIMEOUT_LISTENER = 10
LOG_DIRECTORY_LISTENER = e:\Oracle\Ora81\network\log
LOG_FILE_LISTENER = listener
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = db00)
(ORACLE_HOME = e:\Oracle\Ora81)
)
)
b) Using the steps outlined above for configuring the “example01” TNS service
name, configure the “example00” TNS service name to locate the database you
created in Chapter 2. Show the final version of the tnsnames.ora file.
Answer:The final version of your tnsnames.ora file will look similar to the following:
ch03.qxd 10/30/2000 2:49 PM Page 65
4) The tnsnames.ora file is the Instance configuration file read by the Oracle
Instance upon startup to help it decide, for example, how much memory to
allocate to the Shared Pool.
a) _____ True
b) _____ False
LAB 3.2
LAB OBJECTIVES
After this lab, you will be able to:
✔ Start and Stop the Listener
✔ Issue Other Listener Commands
✔ Perform a Loopback Test
To indicate to Listener Control what you want to do, provide an argument to the
lsnrctl command. At the command line in your operating system (in NT this will
be in an MS-DOS window), issue the following command:
lsnrctl help
C:\>lsnrctl help
“lsnrctl help” produces a list of all arguments that can be used with the Listener
Control utility. The exercises throughout the remainder of this chapter will refer
back to this list of arguments.
For remote users to be able to connect to your database, the listener for your data-
base needs to be running. The listener listens on a specific port—by default, Port
1521—for database connection requests. When it receives a request, it either redi-
rects it to a dispatcher process or to a new dedicated server process. Note that it is
possible to have a free dedicated server process waiting for a new request. You may
wish to read more about these “pre-spawned dedicated server processes” in the
Oracle documentation.
Start the listener by issuing the following command at the operating system com-
mand line:
lsnrctl start
C:\>lsnrctl start
Listening on:
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rocky)(PORT=1521)))
You should see the phrase “The command completed successfully” as one of the
last lines. If you do not, make sure you’ve edited the listener.ora file correctly and
have entered the lsnrctl command correctly. Don’t go on to the other exercises in
this chapter until this is working properly.
lsnrctl stop
b) What is the response you get after issuing this command? Did
your listener stop properly? How can you tell?
ch03.qxd 10/30/2000 2:49 PM Page 70
As you saw when you issued the command “lsnrctl help,” there are many other
arguments that can be used with lsnrctl. You will try some of these in the follow-
ing exercises.
LAB
First, verify that the listener is running. To check this, issue the following com-
3.2 mand:
lsnrctl status
Next, consider the “show” argument. This argument displays additional informa-
tion about the configuration of the listener; it requires a parameter to specify
which element of the configuration you want to see. For example, to see infor-
mation about the log status (which shows whether the listener will log informa-
tion about its activities to the listener log file), you issue the command: lsnrctl
show log_status. To view the list of all the lsnrctl show parameters, issue
the following command:
lsnrctl show
C:\>lsnrctl show
LAB
b) Retrieve information about the listener with the lsnrctl status 3.2
command.What does the “Alias” line signify?
Now that your listener is running, you can perform a loopback test to make sure
that it can indeed service connection requests to your database. A loopback test is
performed by starting SQL*Plus and connecting to the database, via the listener,
using the TNS service name you configured for the “example00” entry in the
tnsnames.ora file template (Exercise 3.1). In that exercise, the service name was
configured as “db00”.
Before performing the loopback test, verify that the listener is running. Next, start
SQL*Plus and connect to your database as the user SYSTEM using the TNS service
name you configured for example00 in the tnsnames.ora template. If your test
was unsuccessful, review the previous exercises to make sure that your
tnsnames.ora and listener.ora file are configured correctly and that your listener
started without error.
TNSPING
C:\>tnsping db00 5
Attempting to contact
(ADDRESS=(PROTOCOL=TCP)(Host=127.0.0.1)(Port=1521))
OK (20 msec)
OK (20 msec)
OK (40 msec)
OK (20 msec)
OK (30 msec)
a) Based on the information in your listener.ora file, find the location of your lis-
tener log file.
ch03.qxd 10/30/2000 2:49 PM Page 73
C:\>lsnrctl stop
Connecting to
(ADDRESS=(PROTOCOL=TCP)(HOST=rocky)(PORT=1521))
The command completed successfully
You can tell that there were no problems in shutting down the listener because the
message “The command completed successfully” appeared in the
final message line.
3.2.2 ANSWERS
a) What is the full command for finding the name of the listener’s log file?
Answer:The command for finding the name of the listener’s log file is:
b) Retrieve information about the listener with the lsnrctl status command.What
does the “Alias” line signify?
Answer:The “Alias” line represents the name of the listener. Remember that you can set
up more than one listener on a machine. If there are multiple listeners, they must be
named differently. Note that if a listener has a name other than the default
ch03.qxd 10/30/2000 2:49 PM Page 74
(LISTENER), then you must include the name of the listener when you issue lsnrctl com-
mands. For example, if you configure your listener to have the name LSNR_DB00, then
you would issue the following command to start the listener: lsnrctl start
lsnr_db00. It is rare to find more than one listener running on a machine, but a
senior level DBA may use this configuration for load balancing or to ensure connectivity.
LAB
3.2 3.2.3 ANSWERS
2) To get help for the Listener Control utility, you simply issue the command:
lsnrctl
a) _____ True
b) _____ False
3) Issuing the lsnrctl show command will display the values of all the listener
configuration parameters.
a) _____ True
b) _____ False
LAB 3.3
When the database is configured to allow connections via shared servers, there are
at least two additional background processes that start with the Instance. The first
is the shared server itself, which is named Snnn. Since more than one shared
ch03.qxd 10/30/2000 2:49 PM Page 77
Shared servers work in conjunction with another background process, called the
dispatcher, which gets started with the Instance in this configuration. The dis-
patcher process issues requests and receives responses on behalf of the shared
server processes, and is named Dnnn. An Instance running with two dispatchers
will have two additional background processes called D000 and D001.
To allow multi-threaded server connections, the init.ora file must contain the fol-
lowing parameters:
Perform a shutdown immediate on your database. If your init.ora file already con-
tains these parameters, then you will edit them as described next. If it does not
contain these parameters, then you will need to add them. Set the values of these
parameters to the following:
ch03.qxd 10/30/2000 2:49 PM Page 78
mts_dispatchers=”tcp,2”
mts_max_dispatchers=10
mts_servers=2
mts_max_servers=10
You will now be able to see information about the shared servers and dispatchers.
LAB Remember that these two components are background processes to the Instance.
3.3 In most environments, you can issue a command to see the processes running in
the operating system. For example, in some types of UNIX, the dispatcher
processes can be seen with the following command:
Issue the query from Question a) and confirm that the dispatcher has been shut
down.
3.3.1 ANSWERS
a) Connect to the database as the user SYSTEM and describe the V$DISPATCHER
view.Write a query to find the name of the dispatchers.
Answer: To “find the name of the running dispatchers” issue the query shown below.
You’ll see here that there are two dispatcher processes: D000 and D001.These corre-
late to the two dispatchers that were specified to start with the Instance per the line
in the init.ora file: mts_dispatchers=”tcp,2”.
NAME
----
D000
D001
b) Choose one of the running dispatchers from the result of the query in Question
a).Write the SQL statement to shut it down, then execute the statement.
Answer: Your statement should look similar to this.
1) What are the two additional background processes that get started in a multi-
threaded server configuration?
a) _____ Listener and dispatcher
b) _____ Dispatcher and tnsnames.ora
c) _____ Shared server and dispatcher
d) _____ Shared sever and listener
3) Issuing the command lsnrctl show will display the values of all the listener
configuration parameters.
a) _____ True
b) _____ False
Quiz answers appear in Appendix A, Lab 3.3.
ch03.qxd 10/30/2000 2:49 PM Page 81
CHAPTER 3