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

Oracle Database Administration for Microsoft SQL Server DBAs part 11 pot

10 407 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 130,14 KB

Nội dung

■ The flash recovery area is a valuable location for being able to flashback the database. The sizing of this area may need to change based on the size of the transactions and database, but it is a dynamic change that can be made as needed. The key to sizing this area is to have the disk space available. This will be the area where the backup files can be stored, and based on retention, should be estimated appropriately. You can also remove databases with the DBCA. The Delete a Database option (see Figure 4-2) takes care of removing the services and datafiles. CAUTION Even though the DBCA will ask “Are you sure?” when you choose to delete a database, without a backup of the database, the only parts that can be re-created are the structures. So what is created with the database? The redo logs and log groups, SYSTEM tablespace, SYSAUX tablespace, temporary tablespace, undo tablespace, and control files will be created. The catalog.sql and catproc.sql construct the data dictionary with the views, tables, and stored procedures. SYS, SYSTEM, and a couple more users are added as well. The job scheduler is set up with background processes, because it is the default setting for parameters to have job slave processes. The parameter JOB_QUEUE_PROCESSES in Oracle Database 11 g has a default of 1000, and the job coordinator starts only as many processes as requested. 82 Oracle Database Administration for Microsoft SQL Server DBAs Database Templates = model Database? Are the Oracle templates really like SQL Server’s model database? The templates are the basic building blocks for the database creation. They have defaults for the files, parameters, and some basic configuration. In that respect, they have the same kind of information that is stored in the model database. However, only one database is created for an Oracle server; there is no need for templates to be used over and over again to create the databases, as the model database is used in SQL Server. Duplicating Databases with Templates and Scripts Oracle template files can be used to duplicate and rebuild databases. You can use a template you saved to create another database in the same Oracle home or copy the template file to another server for use. This obviously makes it easy to duplicate a database without having to go through the setup and configure all the options. You can reuse previously defined values and make adjustments as needed. The database can be created easily, similar to using a response file, but without having to go through all of the steps. Database scripts provide another way to duplicate or re-create databases. Using a script is really the manual way to create the database. It has the advantage that you can take a database script from an older version, make a couple of modifications if you want to use any new features, and then use it to create the database in a new Oracle version. When you use a script, setting up the external operating system and Oracle environment is more critical than with the DBCA. This is because nothing is set up to take the defaults. All the environment variables are empty, and you need to make sure they are set up properly before you create the database. For scripts, a parameter file must be available with the parameters set for control files. This parameter file can be copied from another database and modified with the new database name and file directories. Also, all of the directories need to be created before running the script. Otherwise, the script will fail with the “ORA-27040: file create” error. The following code shows the command-line steps for manual database creation in a Windows environment. set ORACLE_SID=dba01 set ORACLE_HOME=d:\oracle\app\product\11.2 ## Create service ORADIM –NEW –SID dba01 –STARTMODE auto Instance created. sqlplus /nolog sqlplus> connect / as sysdba Connected to an idle instance sqlplus> startup nomount Chapter 4: Database Definitions and Setup 83 pfile='d:\oracle\app\product\11.2.\database\initdba01.ora' sqlplus> create database dba01; Database created. ## create tablespace for Temp, users >sqlplus> create temporary tablespace TEMP1 TEMPFILE 'e:\oracle\oradata\dba01\temp01.dbf' Tablespace created. sqlplus> alter database default temporary tablespace TEMP1; Database altered. ## Run scripts for dictionary views sqlplus> %ORACLE_HOME%\rdbms\admin\catalog.sql sqlplus> %ORACLE_HOME%\rdbms\admin\catproc.sql sqlplus> %ORACLE_HOME%\sqlplus\admin\pupbld.sql ## Create server parameter file sqlplus> create spfile from pfile; ## Shutdown and startup the database sqlplus> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. sqlplus> startup ORACLE instance started. Total System Global Area 535662592 bytes Fixed Size 1334380 bytes Variable Size 234881940 bytes Database Buffers 293601280 bytes Redo Buffers 5844992 bytes Database mounted. Database opened. sqlplus> The creation of the instance starts with the service on the Windows platform. When logging in to the database and doing a startup nomount, the background processes actually get started and services are running, so that the database can be created. You can use additional scripts to continue the configuration, including to create other tablespaces, set up the server parameter file, and then build the dictionary views, synonyms, and PL/SQL packages. 84 Oracle Database Administration for Microsoft SQL Server DBAs Creating the Listener A listener is needed on the database server in order for clients to connect to the database. The listener can be created via another creation assistant: the Net Configuration Assistant (NETCA), as shown in Figure 4-5. The listener can retain the default name of LISTENER, or be renamed, perhaps to indicate the Oracle version or database service that it is listening for, as shown in the example in Figure 4-6. Chapter 4: Database Definitions and Setup 85 Shutdown Options Several options are available for how the database is shut down: ■ Shutdown normal will not allow any new connections, but will wait until all current connections disconnect from the database. This is obviously the cleanest shutdown process, but can also take a long time if users do not disconnect from the database, and large transactions haven’t completed. ■ Shutdown immediate will not allow any new connections, but will not wait for users to disconnect. Any active transactions will be rolled backed. Long, uncommitted transactions still might take a while to roll back with this option, but there is no recovery needed on startup. ■ Shutdown transactional will wait for the currently running transactions to complete. There are no new connections allowed, and connected users that are inactive are disconnected. Current transactions are not rolled backed because of shutdown, and there is no recovery needed on startup. ■ Shutdown abort is a last resort. It will bring the database down fast, but it will abort the current transactions, and uncommitted transactions are not rolled back before shutting down. A media recovery on startup will be required to roll back the terminated transactions and clean up these connections. 86 Oracle Database Administration for Microsoft SQL Server DBAs FIGURE 4-5. Creating a listener with the Net Configuration Assistant FIGURE 4-6. Naming the listener One listener can listen for all of the databases on the server, so you do not need a listener for every database. However, depending on your upgrade plans or maintenance downtime considerations, it might be useful to have more than one listener. Each listener will need a different port number. The listener must be started before connections from other clients can be made. On Windows, the listener is a service, which can be started and stopped via the Administration panel. On both Windows and Linux, the lsnrctl utility can be used to script the startup and shutdown of the listener, as in the following example. ####TO START#### >lsnrctl start LISTENER LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 - Production on 07-FEB-2010 13:49:33 Copyright (c) 1991, 2007, Oracle. All rights reserved. Starting tnslsnr: please wait TNSLSNR for 32-bit Windows: Version 11.1.0.6.0 – Production System parameter file is d:\oracle\product\11.1.0\db_1\network\admin\listener.ora Log messages written to d:\oracle\tnslsnr\MMTEST\listener\alert\log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=MMTEST.US.demo.com)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=MMTEST.US.demo.com)(PORT=1521))) STATUS of the LISTENER Alias LISTENER Version TNSLSNR for 32-bit Windows: Version 11.1.0.6.0 – Production Start Date 07-FEB-2010 13:49:35 Uptime 0 days 0 hr. 0 min. 3 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File D:\oracle\product\11.1.0\db_1\network\admin\listener.ora Listener Log File D:\oracle\tnslsnr\MMTEST\listener\alert\log.xml Listening Endpoints Summary (DESCRIPTION=(ADDRESS= (PROTOCOL=tcp)(HOST=MMTEST.US.demo.com)(PORT=1521))) The listener supports no services The command completed successfully Chapter 4: Database Definitions and Setup 87 ####CHECK STATUS#### >lsnrctl status listener_name LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 – Production on 07-FEB-2010 13:50:00 Copyright (c) 1991, 2007, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=MMTEST.US.demo.com)(PORT=1521))) STATUS of the LISTENER Alias LISTENER Version TNSLSNR for 32-bit Windows: Version 11.1.0.6.0 – Production Start Date 07-FEB-2010 13:49:35 Uptime 0 days 0 hr. 0 min. 25 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File D:\oracle\product\11.1.0\db_1\network\admin\listener.ora Listener Log File D:\oracle\tnslsnr\MMTEST\listener\alert\log.xml Listening Endpoints Summary (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=MMTEST.US.demo.com)(PORT=1521))) Services Summary Service "+ASM" has 1 instance(s). Instance "+ASM", status READY, has 1 handler(s) for this service Service "MMDEV" has 1 instance(s). Instance "MMDEV", status READY, has 1 handler(s) for this service The command completed successfully ####TO STOP#### >lsnrctl stop listener_name LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 – Production on 07-FEB-2010 14:13:08 Copyright (c) 1991, 2007, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=MMTEST.US.demo.com)(PORT=1521))) The command completed successfully There is also a client piece for the listener, which we will look at in the next chapter. The database is now ready to use, but it might still need some user tablespaces. User objects should not be in the SYSTEM tablespaces or 88 Oracle Database Administration for Microsoft SQL Server DBAs owned be the SYSTEM schema. You might develop scripts to add some regular users, schemas, and tablespaces. Next, we’ll look at choosing a character set for your Oracle database. Choosing a Character Set An important consideration for your Oracle database is the character set it uses. Before just accepting the default character set, you should do some research about globalization and the options available, as well as the application requirements for the character set of the database. For SQL Server, collations are available at the server level and can be configured down to the column level of a table. The SQL Server collations are not only for international characters, but also affect whether the database is case-sensitive and the sort order. NLS Parameters In Oracle, the character set choice is governed by which languages the database needs to support, and separate parameters deal with sort order and case sensitivity: NLS_SORT and NLS_COMP. As of Oracle Database 10 g , the CI value appended to the NLS_SORT parameter setting will determine if the sort is case-sensitive. The NLS_SORT default value is BINARY, and with a case-insensitive sort setting, it is BINARY_CI. Here is a quick sort example using NLS_SORT, which shows the default behavior: sqlplus> select first_name, last_name from cust1 order by last_name; first_name last_name RANDY EASTWOOD Laura Eastwood danimal Johnson BO MEYERS henry johnson sqlplus> select first_name, last_name from cust1 order by nlssort(last_name,'NLS_SORT=BINARY_CI'); first_name last_name Laura Eastwood RANDY EASTWOOD henry johnson danimal Johnson BO MEYERS Chapter 4: Database Definitions and Setup 89 NLS_SORT can also be set at the server or session level, instead of including it in the sort of the query. The client and the database can even have different character set settings based on the NLS_LANGUAGE (NLS_LANG) parameter, which has three parts: the language, territory, and character set. Here are a few examples: NLS_LANG=AMERICAN_AMERICA.AL32UTF8 NLS_LANG=GERMAN_GERMANY.WE8ISO8859P1 NLS_LANG=FRENCH_CANADA.WE8ISO8859P1 The NLS (National Language Support) parameters are also modifiable at a session level, so that the sorting and language can be changed by altering the session. Here is a quick look at the NLS parameter list: SQL> select parameter from v$nls_parameters; PARAMETER NLS_CALENDAR NLS_CHARACTERSET NLS_COMP NLS_CURRENCY NLS_DATE_FORMAT NLS_DATE_LANGUAGE NLS_DUAL_CURRENCY NLS_ISO_CURRENCY NLS_LANGUAGE NLS_LENGTH_SEMANTICS NLS_NCHAR_CHARACTERSET NLS_NCHAR_CONV_EXCP NLS_NUMERIC_CHARACTERS NLS_SORT NLS_TERRITORY NLS_TIME_FORMAT NLS_TIMESTAMP_FORMAT NLS_TIMESTAMP_TZ_FORMAT NLS_TIME_TZ_FORMAT These parameters are useful for globalization and allow you to adjust sorting and languages. This is similar to collations on columns and databases with SQL Server. However, the Oracle database is created with the chosen character set. It is possible to change a database character set, but it isn’t always an easy process. 90 Oracle Database Administration for Microsoft SQL Server DBAs If different languages need to be supported in the database, the character set needs to be able to handle storing and retrieving the characters for the language. That is also why a Unicode character set, AL32UTF8, is normally selected for databases that must support international languages. There is also a national character setting for NCHAR, NVARCHAR2, and NCLOB. This recommended value is AL16UTF16. At this point, you might be thinking, “NLS this and that, sorting, case- sensitive with Unicode character sets—does this all really mean SQL_ Latin1_General_CPI_CI_AS?” An example might make things clearer. First, to handle international characters and support other client character sets, such as WE8ISO8859P1, the AL32UTF8 character set is recommended. Using AL32UTF8, the database will hold multibyte characters. Let’s look at the type definition of two columns: last_name varchar2(20 BYTE), last_name2 varchar2(20 CHAR) The last_name column will hold international characters, but it will hold only 20 bytes. So, if any characters are 2 or more bytes, the column will hold fewer than 20 characters. The last_name2 column will hold 20 characters, no matter how many bytes are involved. The NLS_LENGTH_ SEMANTICS parameter can be set to BYTE or CHAR for the database level, or the datatypes can be defined on the column level. For an example for sorting and case sensitivity, consider the following table, which has some columns for first name, last name, and an updated date. The character set for the database was created as AL32UTF8, and the NLS_LANG parameter was set to AMERICAN_AMERICA.UTF8 on the server side. SQL> select first_name, last_name, entered_date from mmalcher.example_sort; FIRST_NAME LAST_NAME ENTERED_D LAURA EASTWOOD 02-JAN-10 D'Animal Eastwood 17-JAN-10 Henry Johnson 23-JAN-10 RANDY JOHNSON 28-JAN-10 Bo Meyers 29-JAN-10 SQL> select customer_id,last_name,entered_date from example_sort where last_name='JOHNSON'; Chapter 4: Database Definitions and Setup 91 . processes as requested. 82 Oracle Database Administration for Microsoft SQL Server DBAs Database Templates = model Database? Are the Oracle templates really like SQL Server s model database? The templates. one database is created for an Oracle server; there is no need for templates to be used over and over again to create the databases, as the model database is used in SQL Server. Duplicating Databases with. tablespaces, set up the server parameter file, and then build the dictionary views, synonyms, and PL /SQL packages. 84 Oracle Database Administration for Microsoft SQL Server DBAs Creating the Listener A

Ngày đăng: 04/07/2014, 05:20

TỪ KHÓA LIÊN QUAN