© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. Kuhn, T. KyteExpert Oracle Database Architecturehttps://doi.org/10.1007/978-1-4842-7499-6_2

2. Architecture Overview

Darl Kuhn1   and Thomas Kyte2
(1)
Morrison, CO, USA
(2)
Denver, CO, USA
 

Oracle is designed to be a very portable database—it is available on every platform of relevance, from Windows to UNIX/Linux to cloud-based systems. However, the physical architecture of Oracle looks different on different operating systems. For example, on a UNIX/Linux operating system, you’ll see Oracle implemented as many different operating system processes, virtually a process per major function. On UNIX/Linux, this is the correct implementation, as it works on a multiprocess foundation. On Windows, however, this architecture would be inappropriate and would not work very well (it would be slow and nonscalable). On the Windows platform, Oracle is implemented as a single process with multiple threads. Even though the physical mechanisms used to implement Oracle from platform to platform vary, the architecture is sufficiently generalized that you can get a good understanding of how Oracle works on all platforms.

In this chapter, I present a broad picture of this architecture. We’ll take a look at the Oracle server and define some terms such as database, instance, container database, pluggable database, real application cluster (RAC) database, and sharded database. We’ll take a look at what happens when you “connect” to Oracle and, at a high level, how the server manages memory. In the subsequent three chapters, we’ll look in detail at the three major components of the Oracle architecture:
  • Chapter 3 covers files. Here, we’ll look at the five general categories of files that make up the database: parameter, data, temp, control, and redo log files. We’ll also cover other types of files, including trace, alert, dump (DMP), data pump, and simple flat files. We’ll look at the file area called the Fast Recovery Area (FRA), and we’ll also discuss the impact that Automatic Storage Management (ASM) has on file storage.

  • Chapter 4 covers the Oracle memory structures referred to as the System Global Area (SGA), Process Global Area (PGA), and User Global Area (UGA). We’ll examine the relationships between these structures, and we’ll also discuss the shared pool, large pool, Java pool, and various other SGA components.

  • Chapter 5 covers Oracle’s physical processes or threads. We’ll look at the three different types of processes that will be running on the database: server processes, background processes, and slave processes.

It was hard to decide which of these components to cover first. The processes use the SGA, so discussing the SGA before the processes might not make sense. On the other hand, when discussing the processes and what they do, I’ll need to make references to the SGA. These two components are closely tied: the files are acted on by the processes and won’t make sense without first understanding what the processes do.

What I’ll do, then, is define some terms and give a general overview of what Oracle looks like (if you were to draw it on a whiteboard). There will be two basic architectures to consider. One is the architecture the Oracle database employed exclusively from versions 6 through 11g (referred to now as single tenant in this book) and a new multitenant architecture (container database/pluggable database) available starting with Oracle 12c. Additionally, I’ll describe two variations of Oracle databases, namely, Oracle Real Application Clusters (RAC) and Oracle sharded databases. You’ll then be ready to get into some of the details.

Oracle Database Types

There are two terms that, when used in an Oracle context, seem to cause a great deal of confusion: database and instance . To be fair, part of the reason for this is that different database vendors use the same terms to mean different things. In Oracle terminology, a database is a collection of physical operating system files or disks. When using Oracle Automatic Storage Management (ASM), the database may not appear as individual, separate files in the operating system, but the definition remains the same.

In contrast, an instance is a set of Oracle background processes or threads and a shared memory area, which is memory that is shared across those threads or processes running on a single computer. This is the place for volatile, nonpersistent stuff, some of which gets flushed to disk. A database instance can exist without any disk storage whatsoever. It might not be the most useful thing in the world, but thinking about it that way definitely helps draw the line between the instance and the database.

The two terms, instance and database, are sometimes used interchangeably, but they embrace very different concepts, especially with the multitenant architecture and Oracle Real Application Clusters (RAC) architecture. In the earliest versions of Oracle, there was usually a one-to-one relationship between an instance and a database. This is probably why the confusion surrounding the terms arises. However, to be technically accurate, an instance refers to the processes and memory of Oracle. And a database refers to the physical files that hold data. A database may be accessible from many instances, but an instance will provide access to exactly one database (regardless of database type) at a time. This will become clearer in a moment. Let’s next look at the definition of a single-tenant database.

Single-Tenant (Non-container) Database

A single-tenant database or non-container database is a self-contained set of datafiles, control files, redo log files, parameter files, and so on that include all of the Oracle metadata (the definition of ALL_OBJECTS, for example), Oracle data, and Oracle code (such as the code for DBMS_OUTPUT), in addition to all of the application metadata, data, and code. This is the only type of database in Oracle releases prior to version 12c.

Figure 2-1 depicts the single-tenant database architecture. The database name is ORCL, and also the instance name is ORCL. The client initiates a connection to the ORCL instance by connecting to the database listener. The listener hands off the connection to a database server process. From that point on, the database server process handles any SQL requests that the client sends to view or manipulate data.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig1_HTML.jpg
Figure 2-1

Oracle’s single-tenant (non-container database) architecture

Figure 2-1 shows that you have a single database server (sometimes referred to as host, machine, vm, node, and so on). On the database server, you have one instance (memory structures, background processes, and other processes) and one database (physical files on disk). The memory structures interact with client (user) processes accessing and manipulating the data (datafiles on disk). The client connects to the listener process running on the database server. The listener then hands off the connection to a server process that handles the SQL processing requests from the client.

Separate from the database files are the Oracle installation software files (sometimes referred to as binaries). These are typically installed in a location on disk named ORACLE_HOME (with various components stored in subdirectories). Some examples of binary files would be oracle, sqlplus, rman, dbca, expdp, impdp, lsnrctl, and so on.

After the instance has been started, you can display its memory components (on UNIX/Linux) via the ipcs command:
$ ipcs
Here’s a partial snippet of the output:
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 42         oracle     600        8908800    104
0x00000000 43         oracle     600        1056964608 52
0x00000000 44         oracle     600        7868416    52
0x43f8ffbc 45         oracle     600        24576      52
To view system monitor background processes associated with the ORCL instance, you can issue the process status (on UNIX/Linux) command:
$ ps -ef | grep smon
oracle    7969     1  0 22:43 ?        00:00:00 ora_smon_ORCL
And we can see the datafiles associated with the ORCL database via the following query:
$ sqlplus / as sysdba
SQL> select name from v$datafile;
NAME
---------------------------------------------------------------------------
/opt/oracle/oradata/ORCL/ORCL/datafile/o1_mf_system_j480tkhg_.dbf
/opt/oracle/oradata/ORCL/ORCL/datafile/o1_mf_sysaux_j480vnpn_.dbf
/opt/oracle/oradata/ORCL/ORCL/datafile/o1_mf_undotbs1_j480wfwd_.dbf
/opt/oracle/oradata/ORCL/ORCL/datafile/o1_mf_users_j480wgz7_.dbf

To summarize, the prior example created a single-tenant (non-container) type database. This single-tenant type of database architecture has been deprecated by Oracle. Additionally, Oracle has stated that the single-tenant architecture is desupported starting with Oracle 21c. Having said that, this type of database is still widely used. Many legacy systems running on older versions of Oracle still use this architecture. Therefore, it’s important to be familiar with this type of database architecture.

Single-Tenant (Non-container) RAC Database

In the special case of Oracle Real Application Clusters (RAC), an Oracle option that allows it to function on many computers in a clustered environment, we may have many instances simultaneously mounting and opening this one database, which resides on a set of shared physical disks. In other words, a RAC database consists of one or more instances connected to one database. Multiple RAC instances run on different servers (nodes or hosts). All of the instances share the same database (files on disk). The RAC database is designed for high availability, performance, and scalability. The idea is that you can add more instances (nodes) as you need more CPU and memory processing power. This feature requires an extra license from Oracle to use. Figure 2-2 depicts the RAC architecture. This RAC database has two instances named ORCL1 and ORCL2. Both instances are connected to a single ORCL database.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig2_HTML.jpg
Figure 2-2

Oracle’s single-tenant (non-container database) architecture in a two-node RAC configuration

The client connects to a special Single Client Access Name (SCAN) RAC listener, which hands off the connection request to one of the database listeners (on node 1 in this example). The listener then connects the client request to a server process in the HR1 instance, which then handles any SQL processing initiated by the client. You can have one or more nodes in this configuration. Each instance uses the same physical ORCL database. The RAC software handles the complexity of multiple instances potentially simultaneously accessing the same blocks of data in the single set of database datafiles.

In addition to the Oracle home binaries, the RAC configuration requires the Grid Infrastructure software, which includes the Automatic Storage Management (ASM) software for managing the shared disks. The Grid software is typically installed in a location on disk named GRID_HOME (with various components stored in subdirectories). The Grid home software is separate from the Oracle home software.

To summarize, the database depicted in Figure 2-2 is a single-tenant, two-node RAC database. Again, the single-tenant type database has been deprecated by Oracle and will be desupported as of Oracle 21c.

Multitenant Container Database

Starting with Oracle 12c, Oracle introduced a new type of database, the multitenant container database and the associated pluggable databases. A multitenant container database (CDB) or root container database is a self-contained set of datafiles, control files, redo log files, parameter files, and so on that only include the Oracle metadata, Oracle data, and Oracle code. There are no application objects or code in these datafiles—only Oracle-supplied metadata and Oracle-supplied code objects. This database is self-contained in that it can be mounted and opened without any other supporting physical structures.

A pluggable database (PDB) is a set of datafiles only. It is not self-contained. A pluggable database needs a container database to be “plugged into” to be opened and accessible. These datafiles contain only metadata for application objects, application data, and code for those applications. There is no Oracle metadata or any Oracle code in these datafiles. There are no redo log files, control files, parameter files, and so on—only datafiles associated with a pluggable database. The pluggable database inherits these other types of files from the container database it is currently plugged into.

A pluggable database will be associated with a single container database at a time and is only indirectly associated with an instance; it will share the instance created to mount and open the container database. So, like a container database, a pluggable database can be associated with one or more instances at any point in time. The root container instance may be providing access to many (thousands) pluggable databases simultaneously. That is, a single instance may be providing services for many pluggable databases, but only one container database.

Figure 2-3 displays the architecture of a container database and associated pluggable databases. The container instance is named CDB, and the root container is also named CDB. There are two pluggable databases (PDB1 and PDB2) attached to this container database.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig3_HTML.jpg
Figure 2-3

A container database with two pluggable databases

As depicted in Figure 2-3, the client initiates a connection to the PDB1 pluggable database. The listener connects the client to a server process which processes SQL requests. In this configuration, the client is connected to the CDB instance and accessing the PDB1 pluggable database. The client has no visibility to any other pluggable databases within the container. In other words, the client can only access data within the pluggable database that the client is currently connected to (PDB1 in this example).

There is only one instance (CDB) associated with this container database. We can view the system monitor process of this instance as follows:
$ ps -ef | grep smon
oracle   19362     1  0 00:29 ?        00:00:00 ora_smon_CDB
We can view the datafiles associated with the root container database as well as the pluggable databases. First, connect to the root container:
$ sqlplus / as sysdba
And while connected to the root container, we can view all datafiles associated with the root container and both pluggable databases:
SQL> select name from v$datafile;
NAME
---------------------------------------------------------------------------
/opt/oracle/oradata/CDB/system01.dbf
/opt/oracle/oradata/CDB/sysaux01.dbf
/opt/oracle/oradata/CDB/undotbs01.dbf
/opt/oracle/oradata/CDB/pdbseed/system01.dbf
/opt/oracle/oradata/CDB/pdbseed/sysaux01.dbf
/opt/oracle/oradata/CDB/users01.dbf
/opt/oracle/oradata/CDB/pdbseed/undotbs01.dbf
/opt/oracle/oradata/CDB/PDB1/system01.dbf
/opt/oracle/oradata/CDB/PDB1/sysaux01.dbf
/opt/oracle/oradata/CDB/PDB1/undotbs01.dbf
/opt/oracle/oradata/CDB/PDB1/users01.dbf
/opt/oracle/oradata/CDB/PDB2/system01.dbf
/opt/oracle/oradata/CDB/PDB2/sysaux01.dbf
/opt/oracle/oradata/CDB/PDB2/undotbs01.dbf
/opt/oracle/oradata/CDB/PDB2/users01.dbf
To connect to the PDB1 database, I use the PDB1 service in my connection string (more on this later):
$ sqlplus system/foo@localhost:1521/PDB1
While connected to PDB1, there is no visibility to any other containers in the database. As far as the pluggable PDB1 database is concerned, there are no other databases it can see. For example, querying the name of the datafiles shows only the datafiles associated with the PDB1 pluggable database:
SQL> select name from v$datafile;
NAME
---------------------------------------------------------------------------
/opt/oracle/oradata/CDB/PDB1/system01.dbf
/opt/oracle/oradata/CDB/PDB1/sysaux01.dbf
/opt/oracle/oradata/CDB/PDB1/undotbs01.dbf
/opt/oracle/oradata/CDB/PDB1/users01.dbf

This means you could have one application and all its users and objects in PDB1, and you could have a completely different application using PDB2. There are no collisions of users and objects between these two databases. They are physically implemented as two stand-alone pluggable databases (within a container database).

Multiple pluggable databases, subordinate to the container database, can be open and accessible simultaneously—but will all share the single instance created to open the container database. A pluggable database—in order to be used, to be queried—must be associated with a container database. That container database will only have Oracle data and metadata in it—just the information Oracle needs to “run.” The pluggable databases have the “rest” of the database metadata and data.

So, for example, the container database would have the definition of the “SYS” user (the metadata for the SYS user) and the compiled code and source code for objects like DBMS_OUTPUT and UTL_FILE. A pluggable database, on the other hand, would have the definition of an application schema like SCOTT, all of the metadata describing the tables in the SCOTT schema, all of the PL/SQL source code for the SCOTT schema, all of the GRANTS granted to the SCOTT schema, and so on. In short, a pluggable database has everything that describes a set of application schemas—the metadata for the accounts, the metadata for the tables in those accounts, and the actual data for those tables. A pluggable database is self-contained with respect to the application accounts it contains, but it needs a container database to be “opened” and queried. Therefore, you can say that a pluggable database is not “self-contained,” it needs something else in order to be opened and used.

A pluggable database is not directly opened by an instance, but rather an Oracle instance must be started and a container database mounted and opened by that instance. Once the container instance is up and running, and the container database is opened, that container database may open multiple pluggable databases. Each of these pluggable databases acts as if it were a “stand-alone” database. That is, they appear to be self-contained, stand-alone “single-tenant” databases. But they all share the same container database and container instance.

Note

In Oracle 19c and above, you can have three customer-created pluggable databases in an Enterprise Edition database without any extra licensing required. With the multitenant license, you can have up to 4096 separate pluggable databases in a single container database.

When you start an Oracle instance, there are many processes associated with it (more on this in Chapter 5). Each instance is supported by about a hundred or so processes (varies by configuration). If you attempted to start up 50 single-tenant databases—where each database has an instance associated with it or its own instance—you would have upward of 5000 processes just to get the databases started! That is extremely taxing on the operating system, both to create that many processes and then to manage them.

Additionally, each instance would have its own SGA. Chapter 4 will cover what is in the SGA, but suffice it to say, there is a lot of duplication. Each SGA would have a cached copy of DBMS_OUTPUT in its shared pool, and each SGA would have a redo log buffer and many other duplicative data structures.

With pluggable databases, you can have the separation of application metadata, users, data, code, and so on, but avoid the redundant instances. That is, you can have a single instance with a single container database (the Oracle metadata, code, and data) that provides access to many pluggable databases, each hosting a separate application. That’s a massive reduction in server resource utilization. In general, the size of the single SGA you would allocate for these application pluggable databases will be smaller than the sum of the separate SGAs you would have to allocate otherwise.

From the perspective of a developer, a pluggable database is no different from a single-tenant database. The application connects to the database in exactly the same way it would connect to a single-tenant database in earlier releases. The differences lie in the underlying architecture—that of a single instance for many pluggable databases, and the resulting reduced resource utilization on the server and the ease of management for the DBA.

From a DBA perspective, there are many changes in the way a database is administered—positive changes. For example, if a DBA configured a container database for RAC, every pluggable database under that container would be RAC enabled. The same with Data Guard, RMAN backups, and so on. The DBA has one instance to configure and work with, instead of one instance per application as in the past.

Multitenant RAC Database

In a multitenant RAC database, you have one or more instances that are connected to a container database. Within the container database, you have one or more pluggable databases. Figure 2-4 shows a two-node RAC database connected to a container database named CDB that contains two pluggable databases (PDB1 and PDB2). There are two instances in this configuration (CDB1 and CDB2). The RAC container database accesses shared ASM disks that are visible from each node.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig4_HTML.jpg
Figure 2-4

A two-node RAC container database with two pluggable databases

In this example, the client initiates a connection to the PDB1 pluggable database. This connects to the RAC SCAN listener, which hands off the connection request to one of the database listeners (node 1 in this example). The listener connects the client to a server process in the CDB1 instance. In this configuration, the client is connected to the CDB1 instance and accessing the PDB1 pluggable database. The client has no visibility to the other pluggable databases (PDB2) within the container. In other words, the client can only access data within the pluggable database that the client is currently connected to (PDB1 in this example).

Sharded Database

Starting with Oracle 12.2, the sharded database feature is a logical database that is horizontally partitioned across a pool of physical databases that don’t share any hardware infrastructure. In other words, each database in the shard is hosted on a dedicated server with its own CPU, memory, and disk. The sharded database logically looks like one database to the end-user application, but under the covers, it consists of one or more physical databases.

Each database in the sharded database is referred to as a shard. The database shards can be single instance or multi-instance RAC databases. When creating a table, a column needs to be specified as the distribution key. The distribution key can be defined as consistent, hash, or list. Each sharded database environment uses a sharded catalog database. The sharded catalog supports tasks such as automated shard deployment, centralized management of the sharded database, and multi-shard queries. There are also shard directors which are listeners that handle connection routing based on the sharding key.

Figure 2-5 shows (at a high level) the basic architecture of a sharded database. The client initiates a connection to the global service associated with a sharded database. This connects the client to a connection pool. The request for data is routed to the appropriate instance based on the sharding key.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig5_HTML.jpg
Figure 2-5

A sharded database that contains three database shards

The major benefits of database sharding are as follows:
  • Linear scalability: You can add or remove shards as your business requirements dictate.

  • Fault tolerance: The database shard exists on independent hardware; therefore, an outage on one database shard does not impact other shards.

  • Geographic distribution of data: You might want to do this for legal reasons or privacy regulation reasons.

  • Rolling upgrades: Each shard can be independently upgraded.

  • Regional performance: Each shard can exist in a specific geographic region with its own hardware and storage configuration.

Each database shard is self-contained, meaning each shard will have its own SGA and background processes. So unlike RAC, where multiple instances share the same set of physical database files, sharding is multiple databases (each with its own instance) presented to the end user as one logical database.

The SGA and Background Processes

As seen in the previous sections in this book, each Oracle instance has a large chunk of memory called the SGA that it uses, for example, to do the following:
  • Maintain many internal data structures that all processes need access to.

  • Cache data from disk; buffer redo data before writing it to disk.

  • Hold parsed SQL plans.

  • And so on.

Oracle has a set of processes that are “attached” to this SGA, and the mechanism by which they attach differs by operating system. In a UNIX/Linux environment, the processes will physically attach to a large shared memory segment, a chunk of memory allocated in the OS that may be accessed by many processes concurrently (generally using shmget() and shmat()). Under Windows, these processes simply use the C call, malloc(), to allocate the memory, since they are really threads in one big process and hence share the same virtual memory space.

Oracle also has a set of files that the database processes or threads read and write (and Oracle processes are the only ones allowed to read or write these files). In a single-tenant architecture, these files hold all of our table data, indexes, temporary space, redo logs, PL/SQL code, and so on. In a multitenant architecture, the container database will hold all of the Oracle-related metadata, data, and code; our application data will be separately contained in a pluggable database.

If you were to start up Oracle on a UNIX/Linux–based system and execute a ps command, you’d see that many physical processes are running, with various names. For example, if you wanted to view the system monitor process, you would execute the following:
$ ps -ef | grep smon
oracle   19362     1  0 00:29 ?        00:00:00 ora_smon_CDB

I cover these processes in Chapter 5, so just be aware for now that they are commonly referred to as the Oracle background processes. They are persistent processes that make up the instance, and you’ll see them from the time you start the instance until you shut it down.

It is interesting to note that these are processes, not individual programs. There is only one Oracle binary executable on UNIX/Linux; it has many “personalities,” depending on what it was told to do when it starts up. The same binary executable that was run to start the smon was also used to start the checkpoint background process. There is only one binary executable program, named simply oracle. It is just executed many times with different names.

Connecting to Oracle

In this section, we’ll take a look at the mechanics behind the two most common ways to have requests serviced by an Oracle server: dedicated server and shared server connections. We’ll see what happens on the client and the server in order to establish connections, so we can log in and actually do work in the database. Lastly, we’ll take a brief look at how to establish TCP/IP connections; TCP/IP is the primary networking protocol used to connect over the network to Oracle. And we’ll look at how the listener process on our server, which is responsible for establishing the physical connection to the server, works differently in the cases of dedicated and shared server connections.

Dedicated Server

If we were to log in to the database using a dedicated server, we would see a new process (or a thread on some other operating systems) get created just to service us. For example:
$ sqlplus system/foo@localhost:1521/PDB1
Now using the process status command, let’s view the dedicated server process:
$ ps -ef | grep $ORACLE_SID
Here’s a partial listing of the output showing only the dedicated server process:
oracle   24443     1  0 02:03 ?        00:00:00 oracleCDB (LOCAL=NO)
When we log out, the extra process/thread will go away. Figure 2-6 depicts the dedicated server configuration.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig6_HTML.jpg
Figure 2-6

Typical dedicated server configuration

As noted, typically Oracle will create a new process for me when I log in. This is commonly referred to as the dedicated server configuration, since a server process will be dedicated to me for the life of my session. For each session, a new dedicated server will appear in a one-to-one mapping. My client process (whatever program is trying to connect to the database) will be in direct communication with this dedicated server over some networking conduit, such as a TCP/IP socket. It is this server process that will receive my SQL and execute it for me. It will read datafiles if necessary, and it will look in the database’s cache for my data. It will perform my update statements. It will run my PL/SQL code. Its only goal is to respond to the SQL calls I submit to it.

Shared Server

Oracle can also accept connections in a manner called a shared server, in which you wouldn’t see an additional thread created or a new UNIX/Linux process appear for each user connection.

Note

In older versions of Oracle, a shared server was known as a multithreaded server or MTS. That legacy name is not in use anymore.

In a shared server, Oracle uses a pool of shared processes for a large community of users. Shared servers are simply a connection pooling mechanism. Instead of having 10,000 dedicated servers (that’s a lot of processes or threads) for 10,000 database sessions, a shared server lets us have a small percentage of these processes or threads, which are (as the name implies) shared by all sessions. This allows Oracle to connect many more users to the instance than would otherwise be possible. Our machine might crumble under the load of managing 10,000 processes, but managing 100 or 1000 processes is doable. In shared server mode, the shared processes are generally started up with the database and appear in the ps list.

A big difference between shared and dedicated server connections is that the client process connected to the database never talks directly to a shared server, as it would to a dedicated server. It can’t talk to a shared server because that process is, in fact, shared. In order to share these processes, we need another mechanism through which to “talk.” Oracle employs a process (or set of processes) called a dispatcher for this purpose. The client process will talk to a dispatcher process over the network. The dispatcher process will put the client’s request into the request queue in the SGA (one of the many things the SGA is used for). The first shared server that is not busy will pick up this request and process it (e.g., the request could be UPDATE T SET X = X+5 WHERE Y = 2). Upon completion of this command, the shared server will place the response in the invoking dispatcher’s response queue. The dispatcher process monitors this queue and, upon seeing a result, will transmit it to the client. Conceptually, the flow of a shared server request looks like Figure 2-7.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig7_HTML.jpg
Figure 2-7

Steps in a shared server request

As shown in Figure 2-7, the client connection will send a request to the dispatcher. The dispatcher will first place this request onto the request queue in the SGA (1). The first available shared server will dequeue this request (2) and process it. When the shared server completes, the response (return codes, data, and so on) is placed into the response queue (3), subsequently picked up by the dispatcher (4), and transmitted back to the client.

As far as the developer is concerned, there is conceptually no difference between a shared server connection and a dedicated server connection. Architecturally, they are quite different, but that’s not apparent to an application.

Now that you understand what dedicated server and shared server connections are, you may have the following questions:
  • How do I get connected in the first place?

  • What would start this dedicated server?

  • How might I get in touch with a dispatcher?

The answers depend on your specific platform, but the sections that follow outline the process in general terms.

Mechanics of Connecting over TCP/IP

We’ll investigate the most common networking case: a network-based connection request over TCP/IP. In this case, the client is situated on one machine and the server resides on another, with the two connected on a TCP/IP network. It all starts with the client. The client makes a request using the Oracle client software (a set of provided application program interfaces, or APIs) to connect to a database. The client could be a SQL*Plus on your laptop, an application using a JDBC connection, TOAD, SQL Developer, and so on.

From the client side, when you connect to an Oracle instance, you need to provide a connection string. The connection string contains the information that allows your client software to locate and connect to the remote database instance over the network. The connection string consists of the following information:
  • Username: This is sometimes called the schema name or database user account.

  • Password: The password assigned to the username.

  • Hostname (or IP address): The host (server) that the database is running on.

  • Port: The port that the database listener is listening on. The default port is 1521.

  • Service name: You can conceptually think of a service name as a synonym for the database instance you want to connect to. The service name is oftentimes the instance name or the pluggable database name that you’re connecting to. More technically, a service name represents groups of applications with common attributes, service-level thresholds, and priorities. The number of instances offering the service is transparent to the application, and each database instance may register with the listener as willing to provide many services. So, services are mapped to physical database instances and allow the DBA to associate certain thresholds and priorities with them.

If you’re using a SQL*Plus client to connect to an Oracle instance, you can specify all of the prior information on the command line (this is referred to as the easy connect method). The easy connect method of connecting has this basic syntax:
database_host[:port][/[service_name]
For example, here I connect as the user scott, with a password of tiger, the hostname is localhost, the listener port is 1521, and the pluggable database is ORCL:
$ sqlplus scott/tiger@localhost:1521/ORCL
Starting with Oracle 19c, the easy connect syntax is significantly enhanced and renamed as easy connect plus . This enhanced connection syntax enables easier use of wallets, TLS connections, load balancing, connection timeouts, and so on. This is useful when accessing a service in Oracle’s cloud infrastructure (OCI) which may require TLS for secure communication and wallet information. Listed next is the easy connect plus syntax (this should all go on one line, but doesn’t fit neatly on this page):
[[protocol:]//]host1{,host2}[:port1]{,host2:port2}[/[service_name]
[:server_type][/instance_name]][?parameter_name=value{&parameter_name=value}]
For example, using the easy connect plus syntax to connect to a database in Oracle’s cloud infrastructure specifying the required SSL transport information (this rather lengthy connection string should go on one line, but does not fit nicely on this page):
$ sqlplus scott/tiger@tcps://adb.us-phoenix-1.oraclecloud.com:1522/gjsogz09yzhnqz4_db202102062120_high.adb.oraclecloud.com?ssl_server_cert_dn
="CN=adwc.uscom-east-1.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US"
While the prior easy connection methods work fine, it’s usually easier to manage the connection information by placing the service connection details in a file, and then reference the entries in the file when connecting to the instance. This is especially true if you have more than one database in your environment. In Oracle, the tnsnames.ora file is designated to hold this database connection information. This plain text configuration file is commonly found in the $ORACLE_HOME/network/admin directory ($ORACLE_HOME represents the full path to your Oracle installation directory). For example, I have two entries in the following tnsnames.ora file , one for the local database on my laptop:
ORCL=
 (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORCL)
    )
  )
And here is the entry for the connection to a database in Oracle’s cloud:
OCLD = (description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=sogz09yzhnqz4_db202102062120_high.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com,OU=Oracle BMCS US,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
Tip

TNS stands for Transparent Network Substrate and is “foundation” software built into the Oracle client that handles remote connections, allowing for peer-to-peer communication.

To use a tnsnames.ora file , you use the name of the entry you placed in the file. The client software (SQL*Plus in this example) looks by default in the directory $ORACLE_HOME/network/admin for the tnsnames.ora file for the connection details associated with the ORCL entry, and uses that information to connect me to my pluggable database:
$ sqlplus scott/tiger@ORCL
And listed next is what the connection to a database in Oracle’s cloud looks like now:
$ sqlplus scott/tiger@OCLD

The strings (ORCL or OCLD in these prior examples) could have been resolved in other ways. For example, it could have been resolved using a naming service provided by the Lightweight Directory Access Protocol (LDAP) server, similar in purpose to DNS for hostname resolution. However, the use of the tnsnames.ora file is common in most small to medium installations (as measured by the number of hosts that need to connect to the database) where the number of copies of such a configuration file is manageable.

Now that the client software knows where to connect to, it will open a TCP/IP socket connection to the server with the specified hostname and port. The connection to the instance on my laptop uses a hostname of localhost and a port of 1521 (the default port and can be configured on other ports). If the DBA (me) for our server has installed and configured Oracle Net, and has the listener listening on port 1521 for connection requests, this connection may be accepted. In a network environment, we will be running a process called the TNS listener on our server. This listener process is what will get us physically connected to our database. When it receives the inbound connection request, it inspects the request and, using its own configuration files, either rejects the request (because there is no such service, e.g., or perhaps our IP address has been disallowed connections to this host) or accepts it and goes about getting us connected.

If we are making a dedicated server connection, the listener process will create a dedicated server for us. On UNIX/Linux, this is achieved via fork() and exec() system calls (the only way to create a new process after initialization in UNIX/Linux is via fork()). The new dedicated server process inherits the connection established by the listener, and we are now physically connected to the database. On Windows, the listener process requests the database process to create a new thread for a connection. Once this thread is created, the client is “redirected” to it, and we are physically connected. Diagrammatically in UNIX/Linux, it would look as shown in Figure 2-8.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig8_HTML.jpg
Figure 2-8

The listener process and dedicated server connections

However, the listener will behave differently if we are making a shared server connection request. This listener process knows the dispatcher(s) we have running in the instance. As connection requests are received, the listener will choose a dispatcher process from the pool of available dispatchers. The listener will either send back to the client the connection information describing how the client can connect to the dispatcher process or, if possible, hand off the connection to the dispatcher process (this is OS and database version dependent, but the net effect is the same). When the listener sends back the connection information, it is done because the listener is running on a well-known hostname and port on that host, but the dispatchers also accept connections on randomly assigned ports on that server. The listener is made aware of these random port assignments by the dispatcher and will pick a dispatcher for us. The client then disconnects from the listener and connects directly to the dispatcher. We now have a physical connection to the database. Figure 2-9 illustrates this process.
../images/319655_4_En_2_Chapter/319655_4_En_2_Fig9_HTML.jpg
Figure 2-9

The listener process and shared server connections

From the client’s perspective, it doesn’t care or know if it’s making a dedicated server or shared server connection. The end result should be a successful connection to the database instance so that the client can interact with the database.

Summary

This completes our overview of the Oracle architecture. In this chapter, we defined the terms database, instance, container database, pluggable database, real application cluster (RAC) database, and sharded database. It’s especially important to understand Oracle’s multitenant architecture as this is the recommended Oracle architecture going forward. The use of non-CDB databases will be desupported by Oracle at some point in the future.

We also saw how to connect to the database through either a dedicated server connection or a shared server connection. It’s worth noting that an Oracle instance may use both connection types simultaneously. In fact, an Oracle database always supports dedicated server connections—even when configured for a shared server.

Now you’re ready to take a more in-depth look at the files that comprise the database and the processes behind the server—what they do and how they interact with each other. You’re also ready to look inside the SGA to see what it contains and what its purpose is. You’ll start in the next chapter by looking at the types of files Oracle uses to manage the data, and the role of each file type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.18.4