Tải bản đầy đủ (.pdf) (10 trang)

OCA /OCP Oracle Database 11g A ll-in-One Exam Guide- P12 ppsx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (362.9 KB, 10 trang )

OCA/OCP Oracle Database 11g All-in-One Exam Guide
66
of the directory into which the file was unzipped, viewed from a command
window.
Note the presence of the readme.html file. This contains the product release
notes—open it in a browser, and read them.
3. Confirm success of your installation by running the sqldeveloper.exe
executable file, either from the command prompt or by double-clicking it in
Windows Explorer.
Oracle Enterprise Manager
The version of Oracle Enterprise Manager relevant to the OCP examination is Database
Control. This is a tool for managing one database (which can be a RAC database),
whereas Grid Control can manage many databases (and more). Database Control is
installed into the Oracle Home. It consists of a Java process that monitors a port for
incoming connection requests. If there are several database instances running off the
same Oracle Home, each instance will be accessible through Database Control on a
different port.
Database Control connects to the database on behalf of the user. It has built-in
monitoring capability and will display real-time information regarding alert conditions,
activity, and resource usage. It also gives access to many wizards that can make
database management and tuning tasks feasible for novice DBAs, and quick to carry
out for experienced DBAs.
Starting and stopping the Database Control process is described in Chapter 3;
using it for management tasks is demonstrated in most subsequent chapters.
TIP Oracle Enterprise Manager can be a very useful tool, but never use it
without understanding what it is doing. Many DBAs like to work from the
SQL*Plus or SQL Developer command line to understand exactly how
to do something, and then use Enterprise Manager to make doing it easy.
It is also a nice tool for checking syntax for a command you’ve forgotten.
Chapter 2: Installing and Creating a Database
67


PART I
Other Administration Tools
There are a number of other utilities that will be used in the course of this book. In
many cases, there are both graphical and command-line interfaces. All of these are
installed into the Oracle Home.
Oracle Net Manager, Oracle Net Configuration Assistant
These are two Java graphical tools for configuring the Oracle networking environment.
There is considerable overlap in their functionality, but each does have some capability
lacking in the other. Most network administration tasks can also be done through
Database Control, and all can be done by editing configuration files by hand.
Historically, manual editing of the Oracle Net configuration files could be an
extremely dodgy business: many DBAs believed that the files were very sensitive to
trifling variations in format such as use of white spaces, abbreviations, and case. For
this reason alone, the graphical tools have always been popular. Recent releases of
Oracle Net appear to be less sensitive to such issues, but the graphical tools are still
useful for preventing silly syntax errors.
Data Loading and Unloading Utilities
The classical utilities for transferring data between Oracle databases are the Export and
Import tools. Export runs queries against a database to extract object definitions and data,
and writes them out to an operating system file as a set of DDL and DML commands.
Import reads the file and executes the DDL and DML statements to create the objects and
enter the data into them. These utilities were very useful for transferring data between
databases, because the transfer could go across operating systems and Oracle versions, but
because they work through regular user sessions (they are client-server tools), they were
not always suitable for large-scale operations. Export files can only be read by Import.
The replacement for Export and Import is Data Pump, introduced with release 10g.
Functionally, Data Pump is very similar: it extracts data from one database, writes it out
to a file, and inserts it into another database (possibly a different version, on a different
platform). But the implementation is completely different. Data Pump uses background
processes, not server sessions, to read and write data. This makes it much faster.

Launching, controlling, and monitoring Data Pump jobs is done through client-server
sessions, but the job itself all happens within the instance. Export and Import are still
supported, but Data Pump is the preferred utility. Data Pump–generated files can only
be read by Data Pump: there is no compatibility with Export and Import.
SQL*Loader is a tool for loading large amounts of data into an Oracle database
from operating system files. These files can be laid out in a number of formats. There
are restrictions on the formats SQL*Loader can use, but it is a pretty versatile tool and
can be configured to parse many file layouts. Typical usage is the regular upload of data
into an Oracle database from a third-party feeder system: the third-party database will
write the data out in an agreed format, and SQL*Loader will then load it.
EXAM TIP Data Pump can read only files generated by Data Pump, but
SQL*Loader can read files generated by any third-party product, so long
as the file is formatted in a way that can be parsed.
OCA/OCP Oracle Database 11g All-in-One Exam Guide
68
Data Pump and SQL*Loader are described in Chapter 23. Both utilities have
command-line interfaces and a graphical interface through Database Control.
TIP Export and Import will be useful for a long time to come. Data Pump is
available only for releases 10g and 11g, so whenever it is necessary to transfer
data to or from 9i and earlier databases, the older utilities will still be needed.
It is well worth getting familiar with them.
Backup Utilities
It is possible to back up an Oracle database using operating system utilities. Operating
system backups (known as user-managed backups) are fully supported, and there are
circumstances when they may be the best option. But the preferred tool is RMAN, the
Recovery Manager. RMAN backups are known as server-managed backups. RMAN is
introduced and used for simple backup and restore operations in Chapters 15–17.
RMAN server-managed backups have capabilities that user-managed backups
cannot provide. These include incremental backups, where only the changed blocks of
a datafile are backed up; block-level restore and recovery, where if the damage to a file

is only to a small part of the file, just that part can be repaired; the application of an
incremental backup to full backup, to roll it forward; and validating the datafiles to
detect corruptions before end users hit them.
TIP The degree of knowledge of backup and recovery techniques tested by
the OCP examinations may not be adequate for a DBA to be considered fully
competent. Remember that the OCP curriculum is only an introduction to
database administration. Backup is a critical task and will require further study.
The Oracle Secure Backup facility lets the DBA manage backup of the entire
environment: Oracle Application Servers, remote clients, and operating system files,
as well as the database. It is developed by Oracle in conjunction with operating
system and hardware vendors.
Plan an Oracle Database Installation
Before running OUI, it is necessary to confirm adequate hardware and operating
system resources, to make a decision about where to install the software, and to
consider setting some environment variables.
Choice of Operating System
Some people become almost religiously attached to their favorite operating system.
Try to avoid this. All operating systems have good and bad points: none are suitable
for all applications. In general, Oracle Corporation supports all the mainstream
platforms, including
• Linux on Intel and AMD
Chapter 2: Installing and Creating a Database
69
PART I
• Microsoft Windows on Intel and AMD
• Solaris on SPARC
• AIX on POWER
• HPUX on PA-RISC
These platforms are probably the most common, but there are many others. Some
operating systems are available in both 32-bit and 64-bit versions to support different

popular machine architectures. Usually, Oracle ports the database to both. When
selecting an operating system, the choice should be informed by many factors, including
• Cost
• Ease of use
• Choice of hardware
• Available skills
• Scalability
• Fault tolerance
• Performance
There are other factors, and not only technical ones. Corporate standards will be
particularly important.
Linux deserves a special mention. Oracle Corporation has made a huge
commitment to Linux, and Linux is used as the development platform for many
products (including database release 11g). Linux comes in several distributions. The
most popular for Oracle servers are Red Hat and SUSE, but do not ignore the Oracle
distribution: Enterprise Linux. This is very well packaged and fully supported by
Oracle Corporation. This means you can have one support line for the entire server
technology stack.
Hardware and Operating System Resources
Determining the necessary hardware resources for an Oracle database server requires
knowledge of the anticipated data volumes and transaction workload. There are sizing
guides available on MetaLink. The minimum hardware requirements for a usable
system are
• 1GB RAM
• 1.5GB swap space
• 400MB in the TEMP location
• 1.5GB–3.5GB for the Oracle Home
• 1.5GB for the demonstration seed database
• 2.4GB for the flash recovery area
• A single 1GHz CPU

OCA/OCP Oracle Database 11g All-in-One Exam Guide
70
The wide range in space for the Oracle Home is because of platform variations.
Around 2.5GB is typical for the Windows NTFS file system, 3.5GB for the Linux ext3 file
system. The flash recovery area is optional. Even if defined, there is no check made as to
whether the space is actually available. Machines of a lower specification than that just
given can be used for learning or development but would not be suitable for anything
else. The TEMP location is a directory specified by the TEMP environment variable.
The server operating system must be checked for compliance with the Oracle
certified platforms, bearing in mind these issues:
• That some operating systems come in 32-bit and 64-bit versions
• Correct version and patch level
• Required packages
• Kernel parameters
These prerequisite factors will be checked by the OUI.
Exercise 2-2: Confirm Available Hardware Resources In this exercise,
you will check what resources are available, first for Windows and second for Linux.
Windows:
1. Right-click My Computer, and bring up the Properties dialog box. Note the
amount of RAM. This should be at least 512MB, preferable 1GB.
2. Choose the Advanced tab, and then in the Performance section click the
SETTINGS button.
3. In the Performance Options dialog box select the Advanced tab. Note the
virtual memory setting. This should be at least one and a half times the
memory reported in Step 1.
4. Open a command window, and find the location of your temporary data
directory with this command:
C:\> echo %TEMP%
This will return something like
C:\ Temp

Check that there is at least 400MB free space on the file system returned (in
this example, it is drive C:).
5. Identify a file system with 5GB free space for the Oracle Home and a database.
This must be a local disk, not on a file server. If you want to stage the
installation media (you probably do), that will need another 1.5GB, which
can be on a file server.
Linux:
1. From an operating system prompt, run free to show main memory and
swap space, which should ideally both be at least 1GB. These are the values
in the total column. In the illustration that follows, they are both about 2GB.
Chapter 2: Installing and Creating a Database
71
PART I
2. Run df -h to show the free space in each mounted file system. Confirm that
there is a file system with 5GB free for the Oracle Home and the database.
Confirm that there is 400MB free in /tmp if it exists as a separate file system;
if there is no specific file system for /tmp (as is the case in the illustration),
you can assume that it is in the root file system. In the illustration, there is
23GB free in the root file system.
3. Use rpm to check that all required packages are installed, at the correct (or
later) version. In the illustration, the sysstat package is being checked.
4. Use sysctl to check that all the required kernel settings have been made—
you may need to have root privilege to do this. In the illustration, the IP port
range is being checked.
Optimal Flexible Architecture
The Oracle Home will need a file system into which it can be installed. Oracle
Corporation has designed OFA, the Optimal Flexible Architecture, as a file system
directory structure that should make maintaining multiple versions of multiple Oracle
products straightforward. The heart of OFA is two environment variables: ORACLE_
BASE and ORACLE_HOME. The ORACLE_BASE directory is one directory on the

server, beneath which all the Oracle software (all products, all versions) should be
installed. Each version of each product will then have its own ORACLE_HOME,
beneath the ORACLE_BASE. This structure should ensure that many databases can be
created and upgraded without ever ending up with files in inappropriate locations.
The Linux and Unix OFA standard for ORACLE_BASE is that it should be a
directory named according the template /pm/h/u, where p is a string constant such
as u, m is a numeric constant such as 01, h is a standard directory name such as app,
and u is the operating system account that will own all the Oracle software, such as
oracle.
The Windows OFA standard for ORACLE_BASE is \oracle\app off the root of
any suitable drive letter.
OCA/OCP Oracle Database 11g All-in-One Exam Guide
72
The OFA standard for the database ORACLE_HOME is $ORACLE_BASE/product/v/
db_n, where product is the constant product, v is the release number of the product
such as 11.1.0, and db_n is a name derived by the installer based on which product
it is, such as db for database, and an incrementing number for each installation of
that product, such as 1.
Typical Linux values for ORACLE_BASE and ORACLE_HOME are
/u01/app/oracle
/u01/app/oracle/product/11.1.0/db_1
and typical Windows values are
D:\oracle\app
D:\oracle\app\product\11.1.0\db_1
The OFA location for the database itself is ORACLE_BASE/q/d, where q is the string
oradata and d is the name of the database. A Linux example for a database called
orcl is
/u01/app/oracle/oradata/orcl
Within the database directory, the controlfile copies, online redo logfiles, and
datafiles should be named as follows:

File Type Name Variable Examples
Controlfile controlnn.ctl nn is a unique number control01.ctl, control02.ctl
Redo logfiles redonn.log nn is the online redo
logfile group number
redo01.log, redo02.log
Datafiles tablespacenamenn.dbf the datafile’s
tablespace name and
a number
system01.dbf, system02.dbf
TIP OFA does not specify the naming convention for multiplexed online
redo logfiles. Many DBAs suffix the OFA name with a letter to differentiate
members in the same group: redo01a.log, redo01b.log.
Environment Variables
One significant difference between Windows and Unix operating systems is in the
way in which environment variables are set. Within the Unix family, there are further
variations depending on the shell being used. On Windows operating systems, there
is the registry: Unix has no equivalent of this.
The Oracle database makes use of several environment variables, some of which
can be set before even running the OUI. The OUI will prompt for them, using the
preset values as defaults. On Linux, the one variable that must be set before the
installer can run is DISPLAY.
Chapter 2: Installing and Creating a Database
73
PART I
Variables in Windows
Variables can be set at various levels with various degrees of persistence on a Windows
system, ranging from permanent, system-wide variables set in the Windows registry to
variables set interactively within a command shell. As a general rule, variables set at a
higher level (such as within the registry) can be overruled at a lower level (such as
within a shell).

The highest level for variables is in the registry. The OUI creates a key in the registry,
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
and defines variables for each installed Oracle product beneath this. Figure 2-2 earlier
shows the variables set for the ORACLE key, and then those set one level down, in the
key KEY_OraDb11g_home1.
At the ORACLE level, the variable inst_loc defines the location of the OUI
inventory, described previously. Beneath this level there are keys for each installed
product. In the example shown, there are two products installed: JInitiator (which is
Oracle’s client-side JVM for running the Forms viewing applet—two versions have
been installed on the system) and Database 11g. In the key KEY_OraDb11g_home1
there are a number of variables, two of the more significant being the ORACLE_BASE
and the ORACLE_HOME. Others specify the locations of various components and
the options Windows should use for automatic startup and shutdown of a database
instance called ORCL.
TIP There is no easy way to query the value of a Windows registry variable,
other than by looking at the registry with a tool such as the regedit.exe
registry editing tool. For this reason, many DBAs like to set variables at the
session level, from where they can be easily retrieved and used. Figure 2-4
shows an example of doing this.
Figure 2-4 Setting and using Windows environment variables
OCA/OCP Oracle Database 11g All-in-One Exam Guide
74
The commands for setting up the environment in the manner desired would
usually be specified in a batch file that could be invoked from the command line
or as a login script.
Variables in Linux
The syntax for setting and reading environment variables varies from one shell to
another. The examples that follow are for the bash shell, because that is possibly the
most widely used Linux shell.
Linux environment variables are always session specific. They must all be set up

for each session—there is no equivalent of the Windows registry setting up variables
with a scope that can include all sessions. To simulate setting what might be thought
of as “global” variables applying to all sessions by all users, set them in the /etc/
profile file, which is executed at each logon.
Figure 2-5 shows examples of setting and using bash shell environment variables.
Note that in Figure 2-5 two more variables are being set on Linux than in Figure 2-4
on Windows. The LD_LIBRARY_PATH variable should include all dynamically linked
libraries that may be needed, and the DISPLAY must be set to point to the terminal on
which the user is working.
EXAM WATCH If the DISPLAY variable is not set appropriately, OUI will not
be able to open any windows and will throw an error.
Install the Oracle Software by Using
the Oracle Universal Installer (OUI)
To run the OUI for the first time, log on to the server machine as an operating system
user with permission to read the installation media (or the directory to which it has
been staged) and to write to the directory chosen for the ORACLE_BASE. Then launch
the OUI by running
setup.exe (Windows)
runInstaller.sh (Linux)
Figure 2-5
Setting and using
environment
variables in the
bash shell
Chapter 2: Installing and Creating a Database
75
PART I
To bypass the prerequisite checks (not advised, but may be useful), add a switch:
runinstaller -ignoreSysPrereqs
It is possible to do an unmanaged installation known as a silent install. This will

be necessary if there is no graphics device, and is very convenient if you are performing
many identical installs on identical machines. Also, it becomes possible to embed an
Oracle installation within the routine for deploying a packaged application. A silent
install requires a response file, which includes answers to all the prompts that would
usually be manually given. The syntax for running the OUI in this way is
runInstaller -silent -responsefile responsefilename
The response file can be created manually (there are examples in the /response
directory on the installation media), or it can be recorded by OUI during an
interactive install:
runInstaller -record -destinationFile responsefilename
Before doing a silent install, the inventory pointer file (/etc/oraInst.loc on
Linux) must have been created, or OUI will not be able to locate (or create if
necessary) the inventory.
Exercise 2-3: Install the Oracle Home In this exercise, install an Oracle
Home on Linux using the OUI.
1. Log on to Linux as a user who is a member of the dba group. In the following
example, the operating system user is db11g. Confirm the username and
group membership with the id command, as in this illustration:
2. Switch to the root user with su and create an OFA-compliant directory for the
Oracle Base with the mkdir command. In the example, this is /u02/app/
db11g. Change the ownership and access modes of the directory such that
the db11g user has full control of it with the chown and chmod commands,
as in the preceding illustration, and exit back to the Oracle user.

×