1. Trang chủ
  2. » Công Nghệ Thông Tin

OCA /OCP Oracle Database 11g A ll-in-One Exam Guide- P14 potx

10 511 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Oca/Ocp Oracle Database 11g All-in-One Exam Guide
Trường học Standard University
Chuyên ngành Database Management
Thể loại Sách
Năm xuất bản 2023
Thành phố New York
Định dạng
Số trang 10
Dung lượng 204,83 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

After the service creation, the script launches SQL*Plus and runs the SQL script ocp11g.sql which will control the creation of the database: set verify off PROMPT specify a password for

Trang 1

database controlfile At this stage, the controlfile does not exist; this parameter will tell the instance where to create it Some of the other parameters are self-explanatory and can be easily related back to the options taken when going through the steps of the exercise, but eventually you must refer to the Oracle Documentation Library (the volume you need is titled “Reference”) and read up on all of them All! Those

necessary for examination purposes will be described at the appropriate point

EXAM TIP What is the only instance parameter for which there is no default?

It is DB_NAME A parameter file must exist with at least this one parameter,

or you cannot start an instance The DB_NAME can be up to eight characters long, letters and digits only, beginning with a letter

The Database Creation Shell Script

This is the file the DBCA executes to launch the database creation process It is a batch file on Windows, and a shell script on Linux A Windows example:

mkdir D:\oracle\app

mkdir D:\oracle\app\admin\ocp11g\adump

mkdir D:\oracle\app\admin\ocp11g\dpdump

mkdir D:\oracle\app\admin\ocp11g\pfile

mkdir D:\oracle\app\cfgtoollogs\dbca\ocp11g

mkdir D:\oracle\app\flash_recovery_area

mkdir D:\oracle\app\oradata\ocp11g

mkdir D:\oracle\app\product\11.1.0\db_3\database

set ORACLE_SID=ocp11g

set PATH=%ORACLE_HOME%\bin;%PATH%

D:\oracle\app\product\11.1.0\db_3\bin\oradim.exe -new -sid OCP11G

-startmode manual -spfile

D:\oracle\app\product\11.1.0\db_3\bin\oradim.exe -edit -sid OCP11G

-startmode auto -srvcstart system

D:\oracle\app\product\11.1.0\db_3\bin\sqlplus /nolog

@D:\oracle\app\admin\db11g\scripts\ocp11g.sql

First, the script creates a few directories in the Oracle Base Then it sets the

ORACLE_SID environment variable (more of this later) and prepends the ORACLE_ HOME/bin directory to the search path

The two commands that use oradim.exe will not appear on a Linux system On Windows, an Oracle instance runs as a Windows service This service must be created The oradim.exe utility is run twice The first time will define a new service in the Windows registry, with the system identifier OCP11G, and put the service on manual start The -spfile switch refers to the type of initialization parameter file to be used The second use of oradim.exe edits the service, to set it to start automatically whenever Windows starts Figure 2-6 shows the resulting service defined in the registry To see this, use the regedit.exe registry editor (or some similar tool)

to navigate to the key

HKEY_LOCAL_MACHINE/SYSTEM/currentControlSet/Services/OracleServiceOCP11G Each database instance that can run on a Windows machine will be a service, named after the name of the instance (in this case, OCP11G) that was provided in Exercise 2-4, Step 7

Trang 2

After the service creation, the script launches SQL*Plus and runs the SQL script

ocp11g.sql which will control the creation of the database:

set verify off

PROMPT specify a password for sys as parameter 1;

DEFINE sysPassword = &1

PROMPT specify a password for system as parameter 2;

DEFINE systemPassword = &2

PROMPT specify a password for sysman as parameter 3;

DEFINE sysmanPassword = &3

PROMPT specify a password for dbsnmp as parameter 4;

DEFINE dbsnmpPassword = &4

host D:\oracle\app\product\11.1.0\db_3\bin\orapwd.exe

file=D:\oracle\app\product\11.1.0\db_3\database\PWDocp11g.ora

password=&&sysPassword force=y

@D:\oracle\app\admin\ocp11g\scripts\CreateDB.sql

@D:\oracle\app\admin\ocp11g\scripts\CreateDBFiles.sql

@D:\oracle\app\admin\ocp11g\scripts\CreateDBCatalog.sql

@D:\oracle\app\admin\ocp11g\scripts\emRepository.sql

@D:\oracle\app\admin\ocp11g\scripts\postDBCreation.sql

At the top of the script, there are prompts for passwords for four critical accounts

These will be provided by the password entered in Exercise 2-4, Step 9

Then, using host to spawn an operating system shell, the script runs the orapwd

.exe utility (just called orapwd on Linux.) This will create an external password file

for the database The name of the file must be

%ORACLE_HOME%\database\PWD<db_name>.ora

on Windows, or

Figure 2-6 The Windows service defining an Oracle instance

Trang 3

on Linux, where <db_name> is the name of the database This is the name provided

for the global database name in Exercise 2-4, Step 7, but without any domain suffix Usually, this is the same as the instance name—but they are not the same thing The script then calls CreateDB.sql, which will actually create the database

The CREATE DATABASE Command

This is an example of the CreateDB.sql script:

connect "SYS"/"&&sysPassword" as SYSDBA

set echo on

spool D:\oracle\app\admin\ocp11g\scripts\CreateDB.log

startup nomount pfile="D:\oracle\app\admin\ocp11g\scripts\init.ora";

CREATE DATABASE "ocp11g"

MAXINSTANCES 8

MAXLOGHISTORY 1

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

DATAFILE 'D:\oracle\app\oradata\ocp11g\system01.dbf'

SIZE 300M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED

EXTENT MANAGEMENT LOCAL

SYSAUX DATAFILE 'D:\oracle\app\oradata\ocp11g\sysaux01.dbf'

SIZE 120M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED

SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE

'D:\oracle\app\oradata\ocp11g\temp01.dbf' SIZE 20M REUSE

AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED

SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE

'D:\oracle\app\oradata\ocp11g\undotbs01.dbf' SIZE 200M REUSE

AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED

CHARACTER SET WE8MSWIN1252

NATIONAL CHARACTER SET AL16UTF16

LOGFILE GROUP 1 ('D:\oracle\app\oradata\ocp11g\redo01.log') SIZE 51200K, GROUP 2 ('D:\oracle\app\oradata\ocp11g\redo02.log') SIZE 51200K,

GROUP 3 ('D:\oracle\app\oradata\ocp11g\redo03.log') SIZE 51200K

USER SYS IDENTIFIED BY "&&sysPassword"

USER SYSTEM IDENTIFIED BY "&&systemPassword";

spool off

The script connects to the instance, using the syntax for password file authentication (this is fully described in Chapter 3) Let’s consider the script line by line

The echo and spool commands cause SQL*Plus to write out a log of everything that happens next

The STARTUP NOMOUNT command builds the instance in memory, using the static parameter file we saw earlier The significance of “NOMOUNT” will be dealt with in Chapter 3; for now, let it suffice that it is necessary, as there is no database to mount and open After this completes, there will be an instance running with an SGA and the background processes The SGA will have been sized according to the parameters

in the nominated init.ora file

The CREATE DATABASE command, which continues to the semicolon at the end

of the file, is followed by the database name (which is ocp11g) The first section of the command sets some overall limits for the database These can all be changed subsequently, but if they are clearly inappropriate, it is a good idea to change them now, before creation

Trang 4

TIP With the current release, some of these limits (such as the number of

datafiles) are only soft limits, and therefore of little significance

Datafile specifications are provided for the SYSTEM, SYSAUX, and UNDO

tablespaces Tempfile specifications for a TEMPORARY tablespace are also provided

The database character set used for storing data dictionary data and table columns

of type VARCHAR2, CHAR, and CLOB is specified followed by the national character

set (which is used for columns of type NVARCHAR2, NCHAR, and NCLOB) It is

possible to change the character set after creation with SQL*Plus Choice and use of

character sets, and other aspects of globalization, are covered in detail in Chapter 26

TIP Until version 9i of the database, there was no supported means for

changing the database character set after creation: it was therefore vital to

get this right With 9i and later, it is possible to change it afterward, but this

is not an operation to embark on lightly Get it right now!

The logfile clause specifies three log file groups, each consisting of one member

This is an example of the DBCA defaults perhaps not doing a perfect job It would be

better practice to multiplex the redo log: to create at least two members for each

group Not a problem—this can be fixed later (in Chapter 14) The online redo log

will always require substantial tuning; the defaults are applicable to virtually no

production systems

Finally, SYS and SYSTEM passwords are initialized, and spooling to the log is

switched off

This one file with the CREATE DATABASE command will create a database After

its successful execution, you will have an instance running in memory, and a database

consisting of a controlfile and copies as specified by the CONTROL_FILES initialization

parameter, and the datafiles and redo logs specified in the CREATE DATABASE

command A data dictionary will have been generated in the SYSTEM tablespace But

although the database has been created, it is unusable The remaining scripts called by

ocp11g.sql make the database usable The CREATE DATABASE command has many

options, all of which have defaults For example, if you do not specify a datafile for

the SYSTEM or SYSAUX tablespace, one will be created anyway If you do not specify a

character set, there is a default, which will depend on the operating system configuration

(it may not be a very helpful default—commonly, it is US7ASCII, which is inadequate

for many applications) There are also defaults for the online redo logfiles There are

no defaults for the TEMP and UNDO tablespaces; if these are not specified, the

database will be created without them Not a problem—they can be added later

TIP The CREATE DATABASE command can be extremely long and

complicated—but there are defaults for everything You can create a

database from a SQL*Plus prompt with two words: CREATE DATABASE

Trang 5

Post-Creation Scripts

The other SQL scripts called by ocp11g.sql to complete the database creation will depend on the options chosen when going through the DBCA In this example, as all options except for Enterprise Manager Database control were deselected, there are only four:

• CreateDBfiles.sql This is of minor significance It creates a small

tablespace, USERS, to be used as the default location for any objects created

by users

• CreateDBCatalog.sql This is vital It runs a set of scripts in the

$ORACLE_HOME/rdbms/admin directory that construct views on the data dictionary and create many PL/SQL packages It is these views and packages that make it possible to manage an Oracle database

• emRepository.sql This runs the script to create the objects needed by

Enterprise Manager Database Control It is run because this was selected in Exercise 2-4, Step 8

• postDBCreation.sql This generates a server parameter file from the

init.ora file (more of this in Chapter 3), unlocks the DBSNMP and SYSMAN accounts used by Enterprise Manager, and runs the Enterprise Manager configuration Assistant (which is emca.bat on Windows, emca

on Linux) to configure Database Control for the new database

The DBCA’s Other Functions

The opening screen of the DBCA gives you five options:

• Create a database

• Configure database options

• Delete a database

• Manage templates

• Configure automatic storage management

“Configure Database Options” helps you change the configuration of a database you have already created In the preceding exercise, you deselected all the options: this was to make the creation as quick and simple as possible

TIP By deselecting all the options, particularly those for “standard database

components,” creation time is reduced dramatically

If you decide subsequently to install some optional features, such as Java or OLAP, running the DBCA again is the simplest way to do it An alternative method is to run the scripts to install the options by hand, but these are not always fully documented and it is possible to make mistakes—the DBCA is better

Trang 6

The Delete A Database radio button will prompt you for which database you wish

to delete, and then give you one more chance to back out before it deletes all the files

that make up the database and (for a Windows system) invokes oradim.exe to

delete the instance’s service from the Windows registry as well

TIP Behind the scenes, Delete A Database invokes the SQL*Plus command

DROP DATABASE There is some protection for this command: the database

cannot be open at the time; it must be in mount mode

Manage Templates allows you to store database creation options for later use

Remember that in the exercise, you chose to create a “Custom” database A custom

database is not preconfigured—you chose it in order to see all the possibilities as you

worked your way through the DBCA But apart from “Custom,” there were options for

“Data Warehouse” and “General Purpose or Transaction Processing.” If you choose

either of these, the DBCA suggests different defaults with which to create a database

These defaults will be partly optimized for decision support systems (DSS, the data

warehouse option) or for online transaction processing systems (OLTP, the

transaction processing option) These templates do not create a database from the

beginning; they expand a set of compressed datafiles and modify these The final

question when you created your database gave you the possibility of saving it as a

template—i.e., not to create it at all, but to save the definition for future use The

DBCA will let you manage templates, either the supplied ones or new templates you

create yourself, by creating, copying, modifying, or deleting them Templates can be

extremely useful if you are in a position where you are frequently creating and

re-creating databases that are very similar

Finally, the Configure Automatic Storage Management option launches a wizard

that will create an ASM instance An ASM instance does not open a database; it

manages a pool of disks, used for database storage This is covered in Chapter 20

Two-Minute Drill

Identify the Tools for Administering an Oracle Database

• Installation: the OUI

• Database creation and upgrade: DBCA, DBUA

• For issuing ad hoc SQL: SQL*Plus, SQL Developer

• Backup: RMAN, Oracle Secure Backup

• Network administration: Oracle Net Manager, Oracle Net Configuration

Assistant

• Data load and unload utilities: Data Pump, SQL*Loader

• Management: Oracle Enterprise Manager, Database Control, and Grid Control

Trang 7

Plan an Oracle Database Installation

• Hardware requirements

• Disk space

• Main memory

• Swap space

• Temporary space

• A graphics terminal

• Operating system requirements

• Certified version

• Necessary packages

• Kernel settings

• OFA: an appropriate directory for the Oracle Base

Install the Oracle Software by Using

the Oracle Universal Installer (OUI)

• Use a suitable operating system account

• Set necessary environment variables (Linux, Unix)

• Provide access to the root account (Linux, Unix)

• Make either an interactive or silent install

Create a Database by Using the Database

Configuration Assistant

• A database can be created with the DBCA or from the SQL*Plus command line

• The DBCA can create a database from a saved template

• The DBCA and SQL*Plus commands can delete a database

• An instance must be created before the database can be created

• Any options not selected at creation time can be added later

Self Test

1 Which of these tools is not usually installed with the Oracle Universal Installer? (Choose the best answer.)

A The Oracle Universal Installer itself

B SQL*Plus

C SQL Developer

D Oracle Enterprise Manager Grid Control

Trang 8

2 Which tools can be used to create a database? (Choose three correct answers.)

A Database Configuration Assistant

B Database Upgrade Assistant

C SQL*Plus

D Oracle Universal Installer

E Oracle Enterprise Manager Database Control

3 Oracle provides the ability to back up the entire environment, not just the

Oracle Database What tool can do this? (Choose the best answer.)

A Recovery Manager

B Oracle Secure Backup

C User-managed backups, carried out with operating system commands

4 What statement best describes the relationship between the Oracle Base and

the Oracle Home? (Choose the best answer.)

A The Oracle Base exists inside the Oracle Home

B The Oracle Base can contain Oracle Homes for different products

C One Oracle Base is required for each product, but versions of the product

can exist in their own Oracle Homes within their Oracle Base

D The Oracle Base is created when you run the orainstRoot.sh script,

and contains a pointer to the Oracle Home

5 What does Optimal Flexible Architecture (OFA) describe? (Choose the best

answer.)

A A directory structure

B Distributed database systems

C Multitier processing architecture

D OFA encompasses all the above

6 What environment variable must be set on Linux before running the Oracle

Universal Installer? (Choose the best answer.)

B ORACLE_BASE

C ORACLE_SID

D DISPLAY

7 If the OUI detects that a prerequisite has not been met, what can you do?

(Choose the best answer.)

A You must cancel the installation, fix the problem, and launch OUI again

B A silent install will fail; an interactive install will continue

C Instruct the OUI to continue (at your own risk)

D The options will depend on how far into the installation the OUI is when

the problem is detected

Trang 9

8 What type of devices can the OUI install an Oracle Home onto? (Choose one

or more correct answers.)

A Regular file systems

B Clustered file systems

C Raw devices

D ASM disk groups

9 Which command-line switch can be used to prevent the OUI from stopping when prerequisite tests fail? (Choose the best answer.)

A -silent

B -record

10 When does an OUI inventory get created? (Choose the best answer.)

A Every time a new Oracle Home is created

B Every time a new Oracle Base is created

C Before the first run of the OUI

D During the first run of the OUI

11 To create a database, in what mode must the instance be? (Choose the best answer.)

A Not started

B Started in NOMOUNT mode

C Started in MOUNT mode

D Started in OPEN mode

12 The SYSAUX tablespace is mandatory What will happen if you attempt to

issue a CREATE DATABASE command that does not specify a datafile for the SYSAUX tablespace? (Choose the best answer.)

A The command will fail

B The command will succeed, but the database will be inoperable until the SYSAUX tablespace is created

C A default SYSAUX tablespace and datafile will be created

D The SYSAUX objects will be created in the SYSTEM tablespace

13 Is it necessary to have a database listener created before creating a database?

(Choose the best answer.)

A No

B Yes

C It depends on whether the database is created with the DBCA or SQL*Plus

D It depends on whether the Database Control option is selected in the DBCA

Trang 10

14 Several actions are necessary to create a database Place these in the correct

order:

1 Create the data dictionary views.

2 Create the parameter file.

3 Create the password file.

4 Issue the CREATE DATABASE command.

5 Issue the STARTUP command.

(Choose the best answer.)

A 2, 3, 5, 4, 1

B 3, 5, 2, 4, 1

C 5, 3, 4, 2, 1

D 2, 3, 1, 5, 4

15 What instance parameter cannot be changed after database creation? (Choose

the best answer.)

A All instance parameters can be changed after database creation

B All instance parameters can be changed after database creation, if it is

done while the instance is in MOUNT mode

C CONTROL_FILES

D DB_BLOCK_SIZE

16 What files are created by the CREATE DATABASE command? (Choose one or

more correct answers.)

A The controlfile

B The dynamic parameter file

C The online redo log files

D The password file

E The static parameter file

F The SYSAUX tablespace datafile

G The SYSTEM tablespace datafile

17 What will happen if you do not run the CATALOG.SQL and CATPROC.SQL

scripts after creating a database? (Choose the best answer.)

A It will not be possible to open the database

B It will not be possible to create any user tables

C It will not be possible to use PL/SQL

D It will not be possible to query the data dictionary views

E It will not be possible to connect as any users other than SYS and SYSTEM

Ngày đăng: 06/07/2014, 13:20

TỪ KHÓA LIÊN QUAN