Since there is one Oracle database server for an Oracle instance, creating an Oracle database requires a good bit of configuration and planning.. Users are added only to the Oracle datab
Trang 1A new role with the select permissions could be created for each of the represented DBA roles, which would limit full access to the database based
on responsibility Even if there is only one DBA, creating a different user with some of the basic permissions for a DBA would be better than always logging in as SYSDBA
Summary
In this chapter, we first looked at some database terminology used by the different platforms You saw that the SQL Server database is more similar to the Oracle schema than to the Oracle database Since there is one Oracle database server for an Oracle instance, creating an Oracle database requires
a good bit of configuration and planning
Several assistants are available to create a database, upgrade a database, create a listener, create scripts and templates for the database, and set up the OEM The assistants provide an interface to be able to walk through the different steps, and allow for configuration and customizations along the way
Database scripts and templates can be used to re-create the same
database or to clone the database in another environment The scripts can also be modified to create a new database with similar characteristics The DBCA is a good tool for creating a database for a new Oracle version and taking the defaults to see what some of the new default parameters and configurations might be This could help in planning upgrades and
acceptance of new features
Security is another important topic when it comes to databases, and setting up permissions for least privilege is a database standard Users are added only to the Oracle database server, and then granted permissions to create objects in their schemas or have access to other schema objects There are some system roles for just the DBAs to use with caution
Access to the database can be handled in several different ways Also, determining who has permissions to create objects and manipulate data can
be based on application security and other security policies and standards
In discussing the creation assistants in this chapter, we have already started to look at some of the Oracle tools In the next chapter, we’ll
continue to explore the tools that are provided to aid DBAs in an Oracle environment
102 Oracle Database Administration for Microsoft SQL Server DBAs
Trang 2DBA Tools
Trang 3I n the previous chapters, we’ve covered installing Oracle andcreating the database The next chapters will move on to specific
Oracle database administration tasks Here, we will take a look at the tools available for performing these tasks
What do I mean by “tool”? It’s true that even a simple SQL statement that is saved to be reused can be considered a tool And, yes, we could be writing Perl and shell scripts to manage everything But we’ll focus on some
of the Oracle-provided tools that make the job a little easier, and some good checks and verification steps to do when using these tools Note that tools from third-party vendors are available, and although they are not included
in this discussion, some are also quite useful for DBAs
Overview of Tools for Typical
Database Tasks
Table 5-1 shows the main tools in SQL Server and Oracle for performing some common DBA tasks
104 Oracle Database Administration for Microsoft SQL Server DBAs
Get an overview of
objects and database
activity
SQL Server Management Studio
Oracle Enterprise Manager
Run queries SQL Server Management
Studio, Query Analyzer
SQL Developer, SQL*Plus, SQL Worksheet
Trace sessions Profiler Oracle Enterprise
Manager, v$ views Back up databases Maintenance Plans, SQL
Server Management Studio
Oracle Recovery Manager, Oracle Enterprise Manager Monitor SQL Server Management
Studio
Oracle Enterprise Manager, v$ views Schedule SQL Server Agent, SQL
Server Management Studio
Oracle Scheduler, Oracle Enterprise Manager
TABLE 5-1. DBA Tools for Common Tasks
Trang 4You can see from the table that both SQL Server and Oracle provide a
main tool for database administration: SQL Server Management Studio and
Oracle Enterprise Manager (OEM) Let’s start with a look at OEM
Oracle Enterprise Manager
OEM is similar to SQL Server Management Studio in that it gives you a look
at the server information, error logs, scheduled tasks, and object information
OEM also provides some operating system information and performance
statistics OEM offers an easy view into a database and provides the ability
to manage the database in a GUI
NOTE
Managing multiple databases in an enterprise
environment is better left to the Grid Control,
rather than the single instance of the Database
Control However, the Database Control for a
single database is a good starting point for
understanding the templates and setup for
monitoring
OEM Navigation
OEM has come a long way since it was first introduced With the improvements
in OEM, there have been many changes to where things appear within the
tool Even from OEM 11g R1 to R2, a few categories have been rearranged
Some of these changes come directly from recommendations by users,
based on how they use features So change is good, but explaining where
to find different options and administration tasks is more difficult, since it
depends on the version However, although a tool may be in a different
place in the various versions, its header or description will be very similar
The first page that appears after logon provides some basic information
about the system being up and available, any new alerts in the error log, the server name and listener, and if using ASM, the ASM instance information
The tabs and categories changed from Oracle Database 10g to 11g, but you can still navigate from this home page to the areas to manage the server and perform administration tasks
Trang 5The tabs do a good job of describing the areas that are available:
■ Performance The Performance tab has some graphs that show the
active sessions, CPU utilization, and throughput statistics It has links
to drill down into the top sessions, currently running SQL, and a view to check if there is any blocking These areas will allow for some tuning of queries and the current activity
■ Availability The Availability tab has the backup and recovery tasks.
We will look at these options and settings in the next chapter
■ Server The Server tab contains tasks such as scheduling jobs,
setting up security, configuring parameters, and managing storage and statistics This area is probably the closest to the information in properties for a SQL Server instance, as well as the database properties that are seen in SQL Server Management Studio
■ Schema The Schema tab provides a view into the objects in the
schemas The tables, indexes, views, packages, procedures, triggers, materialized views, defined types, and other objects are available to view by schema After drilling down to an object, such as a table, the object can be edited or new objects of that type can be created The Schema tab is similar to the Object Explorer for SQL Server Management Studio, but it also offers the functionality to walk through the tasks, step by step Additionally, you can view the SQL statements to perform the tasks, which can be executed in other tools
■ Data Movement As the name suggests, the Data Movement tab
has steps for exporting and importing data There is also a Streams category, which is for the setup and management of replication
■ Software and Support The Software and Support tab includes details
on the host configuration and the Oracle Inventory, including the version of the installed Oracle software There is a section for patching, with a way to stage and apply patches The Real Application Testing option allows for replay of the database activity to test a patch rollout, upgrade, or new deployment of configurations
106 Oracle Database Administration for Microsoft SQL Server DBAs
Trang 6In SQL Server, after installation of an instance, you launch SQL Server
Management Studio to verify and adjust settings, create users, and configure the instance for the needed databases The options and configurations available
in properties of the SQL Server instance correspond to the properties that are
available in the Server tab of OEM, as shown in Figure 5-1 After creating the
database, the Server tab of OEM is a good place to start to add users, create user tablespaces, and verify the parameter settings Most of the server setup and
configurations are under the Server tab, and by exploring the categories, you
can learn how to navigate through the OEM to perform the needed tasks So,
let’s take a closer look at the Server tab
Storage Management
Under the Storage category, the Tablespaces section will list the system
tablespaces that have been created: SYSTEM, SYSAUX, TEMP, UNDO, and
FIGURE 5-1. OEM Server tab
Trang 7probably USER as well You can adjust the defaults for sizing the tablespaces and add new tablespaces, for an application or for a schema Having
different tablespaces helps to organize the objects in the database This organization used to be mainly by tables and indexes, but now it can be more about usage and how and when the tablespaces are being accessed You can size the tablespaces based on initial estimates when you create them, and then use OEM to watch their growth and see if more disk is needed From the Control Files section under Storage, you can back up the control file, which is part of a backup strategy, as discussed in the next chapter The last change number is here with the database ID, which is important information about the database, particularly if you need to recover the database
Redo logs can be managed from here as well The Redo Log Groups section shows the current log file Here, you can add groups or add
members to the groups
NOTE
It is good practice to name redo logs with an
extension other than log, even though that is
the Oracle default Use something like rdo or
.ldf to make sure that these are treated like
critical database files, rather than output logs
Database Configuration
Under the Database Configuration category, the Initialization Parameters section lists the database parameters You can verify and adjust these
parameters as needed You can also modify the way that the parameters are listed, so that they are divided by basic, dynamic, or categories (such as memory) to give a more meaningful grouping of the parameters—the whole listing of all the parameters can be overwhelming
The View Database Feature Usage section shows the installed components After the database is up and running, it will show which components are actually being used This is useful information for patching and testing the areas in use If some installed components are not being used, you may want
to consider disabling those components
The Memory Advisors section is the place to go to view how memory is being allocated and managed It shows statistics about the memory Obviously, viewing this section after there is load on the database will provide more valuable information than looking at it immediately after database startup
108 Oracle Database Administration for Microsoft SQL Server DBAs
Trang 8Oracle Scheduler
The Oracle Scheduler category provides information similar to what you
find in the SQL Server Agent and Job Activity Monitor in SQL Server
Management Studio
The Jobs section lists all of the jobs that run against the database You
can view and edit the job description and properties The jobs can also be
run from here, and you can view the history of the job and the schedule
The Automated Maintenance Tasks section lists tasks such as statistics
gathering and possibly backups This is different from how these tasks are
handled in SQL Server, which has the Maintenance Plans feature for setting
up backups and statistics gathering This feature is found under Management,
rather than with the jobs and schedules
Statistics and Resource Management
The Statistics Management category offers a view into the workload repository
These are statistics that are collected for sessions and processes running
against the database The repository pulls together the information to help
assess the database performance, with top wait events, top SQL sessions,
cache hit ratios, and several other statistics
SQL Server 2008 introduced a new Resource Governor, under the
Management folder In Oracle, Resource Manager has been around for
a few versions The Resource Manager category on the Server tab has
sections for setting up consumer groups and plans
Security
The Security category provides access to security-related areas Under
Users, all of the system users are listed, and the list might be longer than
expected, depending on the components and examples installed Many of
the users might be locked and expired, which is the default security for the
components You can activate the user accounts you need and change their
passwords You can also create new users, either as a copy of an existing
user or as a completely new user
When creating users that will be allowed to create tables and indexes,
keep in mind that they will need a quota on a tablespace—just setting a
default tablespace will not be enough Even with the permissions to create
Trang 9a table or index, without access to a tablespace, users will receive an error when they try to create the object:
SQL> create table example1
(object_id number,
object_desc varchar2(20));
create table example1
*
ERROR at line 1:
ORA-01950: no privileges on tablespace 'USERS'
Figure 5-2 shows an example of a USER tablespace quota being set for a new user The quota can be a specific value or be set to unlimited You can also edit an existing account to set the quota
Even though the UNDO and TEMP tablespaces are listed as options here, you cannot grant a quota on these tablespaces, as they are used for transactions and available to all of the users If you try, you will get an “ORA-30041: Cannot grant quota on the tablespace” error You can grant quotas on the SYSTEMand SYSAUX tablespaces, but this is not recommended, because those areas should be used for system objects
110 Oracle Database Administration for Microsoft SQL Server DBAs
FIGURE 5-2. Setting a USER tablespace quota
Trang 10Enterprise Manager Configuration
One other area to look at under the Server tab is Enterprise Manager
Administration The agent and dbconsole process were created with the
creation of the database Here, you can configure notifications, set
thresholds for monitoring, and set blackouts
Figure 5-3 shows the Administrators section, which lists the system
administrators who can log in to OEM to perform management tasks A new administrator account can be created outside the system accounts, with
fewer privileges, to allow administrators to manage templates, blackouts,
and notifications (a good practice to follow for a secure implementation)
The other sections show setup information for OEM The Management
Pack Access section lists some of the database packs which are options and
may require additional licensing
This was just a brief overview of some of the areas of OEM to get you
started with this tool Next, we’ll look at SQL*Plus, a tool for managing
database objects
When Do You Need Quotas?
You do not need to set tablespace quotas for users if they will just be
performing transactions on that table—selecting, inserting, updating,
and deleting However, if the schema owner had a set quota of 2GB
and a user attempted to insert 3GB of data, that user might receive an
“exceeded quota” error on the transaction
Quotas are just needed to create tables or indexes in tablespaces
Procedures and functions do not need tablespaces, so a user that will
be creating these objects might not have quotas on tablespaces
There is a system privilege of unlimited tablespace, which grants
a user unlimited access to all of the tablespaces, including system
tablespaces So you can see why it’s a good idea to just grant access to
the specific tablespaces, instead of opening up the system tablespace
for some random object from a user