Introduction To Oracle Net Services
Introduction To Oracle Net Services
Page 1 of 212
1.2 Connectivity
Oracle Net, a component of Oracle Net Services, enables a network session from a client application to an Oracle Database server. Once a network session is established, Oracle Net acts as the data courier for both the client application and the database server. It is responsible for establishing and maintaining the connection between the client application and database server, as well as exchanging messages between them. Oracle Net is able to perform these jobs because it is located on each computer in the network.
Specifically, Oracle Net is comprised of the Oracle Net foundation layer, which establishes and maintains connections, and Oracle protocol support, which maps the foundation layer's technology to industry-standard protocols.
Page 2 of 212
HTTP provides the language that enables Web browsers and application Web servers to communicate. Application Web Server An application Web server manages data for a Web site, controls access to that data, and responds to requests from Web browsers. The application on the Web server communicates with the database and performs the job requested by the Web server. Web Client Connections through Java Application Web Server An application Web server can host Java applications and servlets. Web browsers make a connection request by communicating through HTTP to an application Web server. The application Web server sends the request to an application or a servlet, which in turn uses a JDBC OCI or a JDBC Thin driver to process the request. The driver then uses Oracle Net to communicate with an Oracle Database server that also is configured with Oracle Net.Oracle Net Services offer a number of manageability features that enable you to easily configure and manage networking components. These features are described in the following topics: Location Transparency Centralized Configuration and Management Quick Installation and Configuration Location Transparency A company can have several databases, each representing a specific type of service for various client applications. For example, a company may have three databases, which it uses for sales, human resources, and marketing applications. Each database is represented by one or more services. A service is identified by a service name, for example, sales.us.acme.com. A client uses this service name to identify the database it needs to access. The information about the database service and its location in the network is transparent to the client because the information needed for a connection is stored in a repository. For example, a company has three databases that clients can access. Each database has a distinct service name: sales.us.acme.com, hr.us.acme.com, and mktg.us.acme.com. 1. The client uses the repository to find the information it needs for sales.us.acme.com. 2. Once the client has the information it needs, it connects to the database. The repository is represented by one or more naming methods. Oracle Net Services offer several types of naming methods that support localized configuration on each client or centralized configuration that can be accessed by all clients in the network. Easy-to-use graphical user interfaces enable you to manage data stored in the naming methods. Centralized Configuration and Management To manage large networking environments, administrators have to be able to easily access a centralized repository to specify and modify the network configuration. For this reason, the Oracle Net Services configuration can be stored in a LDAP-compliant directory server. Support of LDAP-compliant directory servers provides a centralized vehicle for managing and configuring a distributed Oracle network. The directory can act as a central repository for
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 3 of 212
all information on database network components, user and corporate policies, and user authentication and security, thus replacing client-side and server-side localized configuration files. All computers on the heterogeneous network can refer to the directory for information. Quick Installation and Configuration Oracle Net Services install quickly and easily. Networking elements for the Oracle Database server and clients are preconfigured for most environments. Information about an Oracle Database service is populated in one or more naming methods. As a result, clients and servers are ready to immediately connect when installed, giving users the benefits of distributed computing.
Page 4 of 212
LSNRCTL> START [listener_name] Where listener_name is the name of the listener defined in the listener.ora file. It is not necessary to identify the listener if you are using the default, named LISTENER.A status message indicating that the listener has started successfully displays. 2. Start the database: a. Start SQL*Plus without connecting to the database: sqlplus /nolog b. Connect to the database as SYSDBA: SQL> CONNECT username as sysdba For example, SYSTEM is a SYSDBA user. You will be prompted to enter a password. Note: For simplicity in demonstrating this feature, this example does not perform the password management techniques that a deployed system normally uses. In a production environment, follow the Oracle Database password management guidelines, and disable any sample accounts. c. Enter the STARTUP command, specifying the database name and full path of the parameter file: SQL> STARTUP database_name pfile=file If you do not specify the PFILE option, the Oracle database uses the standard initialization parameter file located in the $ORACLE_HOME/dbs directory on UNIX platforms, and %ORACLE_HOME%\database directory on Windows. If you do not specify a database name, then the database uses the value of the DB_NAME parameter specified in the initialization parameter file. 3. Confirm that database service registration with the listener has completed. From the Listener Control utility, enter: LSNRCTL> SERVICES [listener_name] The SERVICES command lists the services supported by the database, along with at lease one available service handler. Task 3: Configure the Client for Connection to a Database Once network connectivity has been verified, you can use easy connect naming to connect to the database. NOTE: Oracle Database 11g does not support the use of Oracle Names. Neither Oracle Database 11g clients nor Oracle Databases can use Oracle Names, including by LDAP proxy, to resolve naming. Oracle8i and Oracle9i clients can still use Oracle Names to resolve naming for an Oracle Database 11g database; however, customers are strongly recommended to migrate to LDAP to take advantage of the new features of Oracle Database 11g. The easy connect naming method can eliminate the need for service name lookup in the tnsnames.ora files for TCP/IP environments. This naming method provides out-of-the-box TCP/IP connectivity to databases. It extends the functionality of the host naming method by enabling clients to connect to a database server with an optional port and service name in addition to the host name of the database. CONNECT username/password@host[:port][/service_name][:server][/instance_name] Note: In Oracle Call Interface documentation, server is referred to as connect_type. If you have performed Oracle Database server install in Typical mode, the default service name used by the oracle instance is ORCL, and the following easy connect syntax can be used to connect to that instance: CONNECT username@host/ORCL Enter password: password
Page 5 of 212
(CONNECT_DATA= (SERVICE_NAME=sales.us.acme.com))) A successful test results in the following message: Connecting...Test successful. If the test fails, it can be because the: Default username (scott) and password (tiger) are not valid Protocol address information does not match the listener information The listener is not running Destination database service is down
Task 4: Connect to the Database from the client computer, connect to the database server as follows. 1. Start SQL*Plus: sqlplus 2. Connect to the database as follows: CONNECT username@net_service_name Enter password: password Where username and password are the database user and password, and net_service_name is the net service name.
The sales and finance databases are each identified by a service name, sales.us.acme.com and finance.us.acme.com. The service name is specified by the SERVICE_NAMES initialization parameter in the server parameter file. The service name defaults to the global database name, a name comprising the database name (DB_NAME initialization parameter) and domain name (DB_DOMAIN initialization parameter). In the case of sales.us.acme.com, sales is the database name and us.acme.com is the domain name. Note: You can change the value of SERVICE_NAMES parameter ynamically with the SQL statement ALTER SYSTEM when the database is running. Database Instances A database has at least one instance. An instance is comprised of a memory area called the System Global Area (SGA) and Oracle background processes. The memory and processes of an instance efficiently manage the associated database's data and serve the database users. Like services, instances are identified by an instance
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 6 of 212
name, sales and finance in this example. The instance name is specified by the INSTANCE_NAME initialization parameter. The instance name defaults to the Oracle System Identifier (SID) of the database instance. Some hardware architectures allow multiple computers to share access to data, software, or peripheral devices. Oracle Real Application Clusters can take advantage of such architecture by running multiple instances on different computers that share a single physical database. Figure - One service for each database
Service Accessibility To connect to a database service, clients use a connect descriptor that provides the location of the database and the name of the database service. The following example shows a connect descriptor that enables clients to connect to a database service called sales.us.acme.com. (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us.acme.com))) Protocol Address The address portion of the connect descriptor is the protocol address of the listener. To connect to a database service, clients first contact a listener process that typically resides on the database server. The listener receives incoming client connection requests and hands these requests to the database server. After the connection is established, the client and database server communicate directly. Much like a business address, the listener is configured to accept requests from clients at a protocol address. This address defines the protocol the listener is listening on and any other protocol specific information. For example, the listener could be configured to listen at the following protocol address: (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))) The preceding example shows a TCP/IP protocol address that specifies the host of the listener and a port number. Clients configured with this same protocol address can send connection requests to this listener. Connect Data The connect descriptor also specifies the database service name with which clients seek to establish a connection. The listener knows which services for which it can handle connection requests, because a n Oracle database dynamically registers this information with the listener. This process of registration is called service registration. Registration also provides the listener with information about the database instances and the service handlers available for each instance. Service handlers act as connection points to an Oracle database server. A service handler can be a dispatcher or a dedicated server. Instance Name If connecting to a specific instance of the database is required, clients can also specify the INSTANCE_NAME of a particular instance in the connect descriptor. This feature can be useful if you have an Oracle Real Application Clusters configuration. For example, the following connect descriptor specifies an instance name of sales1 that is associated with sales.us.acme.com. (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) (CONNECT_DATA=
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 7 of 212
(SERVICE_NAME=sales.us.acme.com) (INSTANCE_NAME=sales1))) Service Handlers Alternatively, clients that always want to use a particular service handler type can use a connect descriptor that specifies the service handler type. In the following example, a connect descriptor is configured to use a dispatcher for a shared server configuration, as indicated by (SERVER=shared). (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us.acme.com) (SERVER=shared))) If you want the client to use a dedicated server, you can specify (SERVER=dedicated) in place of (SERVER=shared). If the SERVER parameter is not set, shared server configuration is assumed. However, the client will use a dedicated server if no dispatchers are available. If database resident connection pooling is enabled on the server, then you can specify (SERVER=pooled) to get a connection from the pool. If database resident connection pooling is not enabled on the server, then the client request is rejected. When the listener receives the client request; it selects one of the service handlers that were previously registered. Depending on the type of handler selected, the communication protocol used, and the operating system of the database server, the listener performs one of the following actions: Hands the connect request directly off to a dispatcher. Sends a redirect message back to the client with the location of the dispatcher or dedicated server process. The client then connects directly to the dispatcher or dedicated server process. Spawns a dedicated server process and passes the client connection to the dedicated server process.
After the listener has completed the connection operation for the client, the client communicates with the Oracle database without the listener's involvement. The listener resumes listening for incoming network sessions.
Page 8 of 212
The client load balancing feature enables clients to randomize connection requests among the listeners. Oracle Net progresses through the list of protocol addresses in a random sequence, balancing the load on the various listeners. Without client load balancing, Oracle Net progresses through the list of protocol addresses sequentially until one succeeds. Connection Load Balancing The connection load balancing feature improves connection performance by balancing the number of active connections among multiple dispatchers. In a single-instance environment, the listener selects the least loaded dispatcher to handle the incoming client requests. In an Oracle Real Application Clusters environment, connection load balancing also has the capability to balance the number of active connections among multiple instances. Due to dynamic service registration, a listener is always aware of all instances and dispatchers regardless of their location. Depending on the load information, a listener decides which instance and, if shared server is configured, to which dispatcher to send the incoming client request. In a shared server configuration, a listener selects a dispatcher in the following order: 1. Least-loaded node 2. Least-loaded instance 3. Least-loaded dispatcher for that instance In a dedicated server configuration, a listener selects an instance in the following order: 1. Least loaded node 2. Least loaded instance If a database service has multiple instances on multiple nodes, the listener chooses the least loaded instance on the least loaded node. If shared server is configured, then the least loaded dispatcher of the selected instance is chosen. Oracle Net Configuration Files:
www.wilshiresoft.com [email protected]
Page 9 of 212
The listener brokers client requests, handing off the requests to the Oracle database server. Every time a client requests a network session with a database server, a listener receives the initial request. Each listener is configured with one or more protocol addresses that specify its listening endpoints. Clients configured with a protocol address can send connection requests to the listener. Once a client request has reached the listener, the listener selects an appropriate service handler to service the client's request and forwards the client's request to it. The listener determines if a database service and its service handlers are available through service registration. During service registration, the PMON processan instance background processprovides the listener with information about the following: Names of the database services provided by the database Name of the instance associated with the services and its current and maximum load Service handlers (dispatchers and dedicated servers) available for the instance, including their type, protocol addresses, and current and maximum load. This information enables the listener to direct a client's request appropriately. Figure shows instances registering information with listeners. Note that it does not represent all the information that can be registered. Figure - Service Registration
Optionally, listening endpointsport numberscan be dynamically registered with the listener. For example, with Oracle XML DB, HTTP, FTP, and WebDAV listening endpoints are registered with the listener. If the listener is not running when an instance starts, PMON is not able to register the service information. PMON attempts to connect to the listener periodically, however, it may take up to 60 seconds before PMON registers with the listener after it has been started. To initiate service registration immediately after the listener is started; use the SQL statement ALTER SYSTEM REGISTER. This is especially useful in high-availability configurations. If a listener receives an incoming request before the respective instance has been registered, the listener rejects the request.
www.wilshiresoft.com [email protected]
Page 10 of 212
If an instance is in restricted mode, then PMON instructs the listener to block all connections to the instance. Clients attempting to connect receive one of the following errors: ORA-12526: TNS:listener: all appropriate instances are in restricted mode ORA-12527: TNS:listener: all appropriate instances are in restricted mode or blocking new connections ORA-12528: TNS:listener: all appropriate instances are blocking new connections
1. The database registers information about the services, instances, and service handlers with the listener. 2. The client makes an initial connection with the listener. 3. The listener parses the client request and forwards it to the service handler for the database service requested. Listener Architecture:
www.wilshiresoft.com [email protected]
Page 11 of 212
www.wilshiresoft.com [email protected]
Page 12 of 212
The connect identifier converts into the following connect descriptor: (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=host)(PORT=port))
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 13 of 212
(CONNECT_DATA= (SERVICE_NAME=service_name) (SERVER=server) (INSTANCE_NAME=instance_name))) For example, the following connect strings connect the client to database service sales.us.acme.com with a listening endpoint of 1521 on databa se server sales-server. CONNECT scott@sales-server:1521/sales.us.acme.com CONNECT scott@//sales-server/sales.us.acme.com CONNECT scott@//sales-server.us.acme.com/sales.us.acme.com After each of the preceding connect strings, you must enter a password to connect to the database service. These connect strings convert into the following connect descriptor: (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us.acme.com))) For URL or JDBC connections, prefix the connect identifier with a double-slash (//). For example: scott@[//]nineva] Enter password: password For SQL connections, preceding the connect identifier with a double-slash (//) is optional. For example: SQL> CONNECT scott@nineva Enter password: password or SQL> CONNECT scott@//nineva Enter password: password Easy Connect Naming Method Examples This section includes various examples of easy connect naming syntax and how each string converts into a connect descriptor.Host only, where the host name is nineva: nineva This connect string converts into the following connect descriptor: (DESCRIPTION= (CONNECT_DATA= (SERVICE_NAME=nineva.us.acme.com)) (ADDRESS= (PROTOCOL=TCP) (HOST=130.35.45.131) (PORT=1521))) Host and port, where the host name is nineva and the port number is 3456: nineva:3456 This connect string converts into the following connect descriptor: (DESCRIPTION= (CONNECT_DATA= (SERVICE_NAME=nineva.us.oracle.com)) (ADDRESS= (PROTOCOL=TCP) (HOST=130.35.45.131) (PORT=3456))) Host and service name, where the host name is nineva and the service name is wanda:
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 14 of 212
nineva/wanda This connect string converts into the following connect descriptor: (DESCRIPTION= (CONNECT_DATA= (SERVICE_NAME=wanda)) (ADDRESS= (PROTOCOL=TCP) (HOST=130.35.45.131) (PORT=1521))) Host, service name and server, and instance name where the host name is nineva, the service name is wanda, the server is dedicated, and the instance name is inst1: nineva/wanda:dedicated/inst1 This connect string converts into the following connect descriptor: (DESCRIPTION= (CONNECT_DATA= (SERVICE_NAME=wanda) (INSTANCE_NAME=inst1) (SERVER=dedicated)) (ADDRESS= (PROTOCOL=TCP) (HOST=130.35.45.131) (PORT=1521))) Host and instance name, where the host name is nineva and the instance name is inst1: nineva//inst1 This connect string converts into the following connect descriptor: (DESCRIPTION= (CONNECT_DATA= (SERVICE_NAME=nineva.us.oracle.com) (INSTANCE_NAME=inst1)) (ADDRESS= (PROTOCOL=TCP) (HOST=130.35.45.131) (PORT=1521)))
For large or complex environments where advanced features, such as connection pooling, external procedure calls, or Heterogeneous Services, which require additional connect information, are desired, easy connect naming is not suitable. In these cases, another naming method is recommended. Easy connect naming is automatically configured at installation. Prior to using it, you may want to ensure that EZCONNECT is specified by the NAMES.DIRECTORY_PATH parameter in the sqlnet.ora file. This parameter specifies the order of naming methods Oracle Net can use to resolve connect identifiers to connect descriptors.
Page 15 of 212
sales= (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=sales.us.acme.com))) In this example, the net service name sales is mapped to the connect descriptor contained in DESCRIPTION. DESCRIPTION contains the protocol address and identifies the destination database service.
www.wilshiresoft.com [email protected]
Page 16 of 212
www.wilshiresoft.com [email protected]
Page 17 of 212
Example - shows a sample listener.ora file. The LISTENER entry defines the listening protocol address for a listener named LISTENER, and the SID_LIST_LISTENER entry provides information about the services statically supported by the listener LISTENER. Example - Example listener.ora File LISTENER= (DESCRIPTION= (ADDRESS_LIST= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521)) (ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))) SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (SID_NAME=plsextproc) (ORACLE_HOME=/oracle10g) (PROGRAM=extproc))) If you are using the IPC protocol, you can improve performance by specifying the maximum number of concurrent IPC connection requests to match your expected connection requests. In listener.ora for example, you can specify the value as in the following exa mple: listener_name=(description=(address=(protocol=ipc)(key=listener0)(queuesize=50)))
Page 18 of 212
manually remove it from the listener.ora file prior to modifying it. If the unencrypted password is not removed, you will be unable to successfully set an encrypted password. To set a new encrypted password with the CHANGE_PASSWORD command, issue the following commands from the Listener Control utility: LSNRCTL> CHANGE_PASSWORD Old password: old_password New password: new_secure_password Reenter new password: new_secure_password Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tpc)(HOST=sales-server)(PORT=1521))) Password changed for LISTENER The command completed successfully LSNRCTL> SAVE_CONFIG Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sales-server)(PORT=1521))) Saved LISTENER configuration parameters. Listener Parameter File Old Parameter File /oracle/network/admin/listener.ora
/oracle/network/admin/listener.bak
The command completed successfully Bold denotes user input. The password is not displayed when entered. To modify an encrypted password with the CHANGE_PASSWORD command: LSNRCTL> SET PASSWORD Password: password The command completed successfully LSNRCTL> CHANGE_PASSWORD Old password: old_password New password: new_secure_password Reenter new password: new_secure_password Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tpc)(HOST=sales-server)(PORT=1521))) Password changed for LISTENER The command completed successfully LSNRCTL> SAVE_CONFIG Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sales-server)(PORT=1521))) Saved LISTENER configuration parameters. Listener Parameter File Old Parameter File /oracle/network/admin/listener.ora
/oracle/network/admin/listener.bak
Page 19 of 212
DISPATCHERS="(PROTOCOL=tcp)(LISTENER=listener_alias)" listener_alias is then resolved to the listener protocol addresses through a naming method, such as a tnsnames.ora file on the database server.For example, if the listener is configured to listen on port 1421 rather than port 1521, you can set the LOCAL_LISTENER parameter in the initialization parameter file as follows: LOCAL_LISTENER=listener1 Using the same listener example, you can set the LISTENER attribute as follows: DISPATCHERS="(PROTOCOL=tcp)(LISTENER=listener1)" You can then resolve listener1 in the local tnsnames.ora as follows: listener1= (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1421))) Notes: To dynamically update the LOCAL_LISTENER parameter, use the SQL statement ALTER SYSTEM: ALTER SYSTEM SET LOCAL_LISTENER='listener_alias' If you set the parameter to null with the statement that follows, then the default local address of TCP/IP, port 1521 is assumed. ALTER SYSTEM SET LOCAL_LISTENER='' The LISTENER attribute overrides the LOCAL_LISTENER parameter. As a result, the SQL statement ALTER SYSTEM SET LOCAL_LISTENER does not affect the setting of this attribute.
Note: You can configure the listener to start automatically whenever the computer it is running on is restarted. Using the Listener Control Utility to Start or Stop a Listener To stop a listener from the command line, enter: lsnrctl STOP [listener_name] Where listener_name is the name of the listener defined in the listener.ora file. It is not necessary to identify the listener if you are using the default listener, named LISTENER. To start the listener from the command line, enter: lsnrctl START [listener_name] where listener_name is the name of the listener defined in the listener.ora file. It is not necessary to identify the listener if you are using the default listener, named LISTENER.
www.wilshiresoft.com [email protected]
Page 20 of 212
3.4.2 Using the Listener Control Utility to Determine the Listener Status
The STATUS command provides basic status information about a listener, including a summary of listener configuration settings, the listening protocol addresses, and a summary of services registered with the listener.To show the status the listener from the command line, enter: lsnrctl STATUS [listener_name] Where listener_name is the name of the listener defined in the listener.ora file. It is not necessary to identify the listener if you are using the default listener, named LISTENER.
www.wilshiresoft.com [email protected]
Page 21 of 212
The following distributed transaction executed by scott updates the local sales database, the remote hq database, and the remote maint database: UPDATE [email protected] SET loc = 'REDWOOD SHORES' WHERE deptno = 10; UPDATE scott.emp SET deptno = 11 WHERE deptno = 10; UPDATE [email protected] SET room = 1225 WHERE room = 1163; COMMIT; Note: If all statements of a transaction reference only a single remote node, then the transaction is remote, not distributed. There are two types of permissible operations in distributed transactions: DML and DDL Transactions The following are the DML and DDL operations supported in a distributed transaction: CREATE TABLE AS SELECT DELETE INSERT (default and direct load) LOCK TABLE
Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
www.wilshiresoft.com [email protected]
Page 22 of 212
You can execute DML and DDL statements in parallel and INSERT direct load statements serially, but note the following restrictions: All remote operations must be SELECT statements. These statements must not be clauses in another distributed transaction. If the table referenced in the table_expression_clause of an INSERT, UPDATE, or DELETE statement is remote, then execution is serial rather than parallel. You cannot perform remote operations after issuing parallel DML/DDL or direct load INSERT. If the transaction begins using XA or OCI, it executes serially. No loopback operations can be performed on the transaction originating the parallel operation. For example, you cannot reference a remote object that is actually a synonym for a local object. If you perform a distributed operation other than a SELECT in the transaction, no DML is parallelized.
Transaction Control Statements The following are the supported transaction control statements: COMMIT ROLLBACK SAVEPOINT
www.wilshiresoft.com [email protected]
Page 23 of 212
Database links are either private or public. If they are private, then only the user who created the link has access; if they are public, then all database users have access. One principal difference among database links is the way that connections to a remote database occur. Users access a remote database through the following types of links: What Are Shared Database Links? A shared database link is a link between a local server process and the remote database. The link is shared because multiple client processes can use the same link simultaneously. When a local database is connected to a remote database through a database link, either database can run in dedicated or shared server mode. The following table illustrates the possibilities: Local Database Mode Dedicated Dedicated Shared server Shared server Remote Database Mode Dedicated Shared server Dedicated Shared server
A shared database link can exist in any of these four configurations. Shared links differ from standard database links in the following ways: Different users accessing the same schema object through a database link can share a network connection. When a user needs to establish a connection to a remote server from a particular server process, the process can reuse connections already established to the remote server. The reuse of the connection can occur if the connection was established on the same server process with the same database link, possibly in a different session. In a non-shared database link, a connection is not shared across multiple sessions. When you use a shared database link in a shared server configuration, a network connection is established
Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
www.wilshiresoft.com [email protected]
Page 24 of 212
directly out of the shared server process in the local server. For a non-shared database link on a local shared server, this connection would have been established through the local dispatcher, requiring context switches for the local dispatcher, and requiring data to go through the dispatcher.
The name of a database is formed by starting at the leaf of the tree and following a path to the root. For example, the mfg database is in division3 of the acme_tools branch of the com domain. The global database name for mfg is created by concatenating the nodes in the tree as follows: mfg.division3.acme_tools.com While several databases can share an individual name, each database must have a unique global database name. For example, the network domains us.americas.acme_auto.com and uk.europe.acme_auto.com each contain a sales database. The global database naming system distinguishes the sales database in the americas division from the sales database in the europe division as follows: sales.us.americas.acme_auto.com sales.uk.europe.acme_auto.com Names for Database Links Typically, a database link has the same name as the global database name of the remote database that it references. For example, if the global database name of a database is sales.us.oracle.com, then the database link is also called sales.us.oracle.com. When you set the initialization parameter GLOBAL_NAMES to TRUE, the database ensures that the name of the database link is the same as the global database name of the remote database. For example, if the global database name for hq is hq.acme.com, and GLOBAL_NAMES is TRUE, then the link name must be called hq.acme.com. Note that the database checks the domain part of the global database name as stored in the data dictionary, not the DB_DOMAIN setting in the initialization parameter file.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 25 of 212
If you set the initialization parameter GLOBAL_NAMES to FALSE, then you are not required to use global naming. You can then name the database link whatever you want. For example, you can name a database link to hq.acme.com as foo. Note: Oracle recommends that you use global naming because many useful features, including Replication, require global naming. After you have enabled global naming, database links are essentially transparent to users of a distributed database because the name of a database link is the same as the global name of the database to which the link points. For example, the following statement creates a database link in the local database to remote database sales: CREATE PUBLIC DATABASE LINK sales.division3.acme.com USING 'sales1';
Determining the type of database links to employ in a distributed database depends on the specific requirements of the applications using the system. Consider these features when making your choice:
www.wilshiresoft.com [email protected]
Page 26 of 212
Database Link Privileges ---------------------------------------CREATE DATABASE LINK CREATE PUBLIC DATABASE LINK CREATE SESSION
www.wilshiresoft.com [email protected]
Page 27 of 212
www.wilshiresoft.com [email protected]
Page 28 of 212
Note: For many distributed applications, you do not want a user to have privileges in a remote database. One simple way to achieve this result is to create a procedure that contains a fixed user or current user database link within it. In this way, the user accessing the procedure temporarily assumes someone else's privileges. Creating a Connected User Database Link to create a connected user database link, omit the CONNECT TO clause. The following syntax creates a connected user database link, where dblink is the name of the link and net_service_name is an optional connect string: CREATE [SHARED] [PUBLIC] DATABASE LINK dblink ... [USING net_service_name']; For example, to create a connected user database link, use the following syntax: CREATE DATABASE LINK sales.division3.acme.com USING 'sales'; Creating a Current User Database Link to create a current user database link, use the CONNECT TO CURRENT_USER clause in the link creation statement. Current user links are only available through the Oracle Advanced Security option. The following syntax creates a current user database link, where dblink is the name of the link and net_service_name is an optional connect string: CREATE [SHARED] [PUBLIC] DATABASE LINK dblink CONNECT TO CURRENT_USER [USING 'net_service_name']; For example, to create a connected user database link to the sales database, you might use the following syntax: CREATE DATABASE LINK sales CONNECT TO CURRENT_USER USING 'sales'; Note: To use a current user database link, the current user must be a global user on both databases involved in the link.
4.4.4. Using Connection Qualifiers to Specify Service Names within Link Names
In some situations, you may want to have several database links of the same type (for example, public) that point to the same remote database, yet establish connections to the remote database using different communication pathways. Some cases in which this strategy is useful are: A remote database is part of an Oracle Real Application Clusters configuration, so you define several public database links at your local node so that connections can be established to specific instances of the remote database. Some clients connect to the Oracle Database server using TCP/IP while others use DECNET. To facilitate such functionality, the database lets you create a database link with an optional service name in the database link name. When creating a database link, a service name is specified as the trailing portion of the database link name, separated by an @ sign, as in @sales. This string is called a connection qualifier. For example, assume that remote database hq.acme.com is managed in a Oracle Real Application Clusters environment. The hq database has two instances named hq_1 and hq_2. The local database can contain the following public database links to define pathways to the remote instances of the hq database: CREATE PUBLIC DATABASE LINK hq.acme.com@hq_1 USING 'string_to_hq_1'; CREATE PUBLIC DATABASE LINK hq.acme.com@hq_2 USING 'string_to_hq_2'; CREATE PUBLIC DATABASE LINK hq.acme.com USING 'string_to_hq'; Notice in the first two examples that a service name is simply a part of the database link name. The text of the service name does not necessarily indicate how a connection is to be established; this information is specified in the service name of the USING clause. Also notice that in the third example, a service name is not specified as part of the link name. In this case, just as when a service name is specified as part of the link name, the instance is determined by the USING string. To use a service name to specify a particular instance, include the service name at the end of the global object name: SELECT * FROM [email protected]@hq_1 Note that in this example, there are two @ symbols.
www.wilshiresoft.com [email protected]
Page 29 of 212
If you want to close a link, issue the following statement, where linkname refers to the name of the link: ALTER SESSION CLOSE DATABASE LINK linkname; Note that this statement only closes the links that are active in your current session.
Page 30 of 212
DBL1.US.ORACLE.COM SALES.US.ORACLE.COM INST2.US.ORACLE.COM RMAN2.US.ORACLE.COM 4 rows selected. 3. Drop the desired link using the DROP PUBLIC DATABASE LINK statement. For example, enter: DROP PUBLIC DATABASE LINK sales.us.oracle.com;
www.wilshiresoft.com [email protected]
Page 31 of 212
www.wilshiresoft.com [email protected]
Page 32 of 212
Before you use one of these methods, be sure to read the descriptions of the available parameters. Note: The import job attributes, LOG_USER and PRIV_USER, are always set to the importing user regardless of what their values were during the export operation. For example, if you perform an export as user scott, but then import as user system, any jobs in the dump file set will be created with LOG_USER and PRIV_USER = SYSTEM. To work around this restriction, you must export and import the job as the job owner.
Command-Line Entries You can specify all valid parameters and their values from the command line using the following syntax (you will then be prompted for a username and password): exp PARAMETER=value or exp PARAMETER=(value1,value2,...,valuen) The number of parameters cannot exceed the maximum length of a command line on the system. Note that the examples could use imp to invoke Import rather than exp to invoke Export.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 33 of 212
Parameter Files The information in this section applies to both Export and Import, but the examples show use of the Export command, exp.You can specify all valid parameters and their values in a parameter file. Storing the parameters in a file allows them to be easily modified or reused, and is the recommended method for invoking Export. If you use different parameters for different databases, you can have multiple parameter files.Create the parameter file using any flat file text editor. The command-line option PARFILE=filename tells Export to read the parameters from the specified file rather than from the command line. For example:The syntax for parameter file specifica tions is one of the following: PARAMETER=value PARAMETER=(value) PARAMETER=(value1, value2, ...) The following example shows a partial parameter file listing: FULL=y FILE=dba.dmp GRANTS=y INDEXES=y CONSISTENT=y Note: The maximum size of the parameter file may be limited by the operating system. The name of the parameter file is subject to the file-naming conventions of the operating system. You can add comments to the parameter file by preceding them with the pound (#) sign. Export ignores all characters to the right of the pound (#) sign. You can specify a parameter file at the same time that you are entering parameters on the command line. In fact, you can specify the same parameter in both places. The position of the PARFILE parameter and other parameters on the command line determines which parameters take precedence. For example, assume the parameter file params.dat contains the parameter INDEXES=y and Export is invoked with the following line: exp PARFILE=params.dat INDEXES=n In this case, because INDEXES=n occurs after PARFILE=params.dat, INDEXES=n overrides the value of the INDEXES parameter in the parameter file. Interactive Mode If you prefer to be prompted for the value of each parameter, you can simply specify either exp or imp at the command line. You will be prompted for a username and password. Commonly used parameters are then displayed. You can accept the default value, if one is provided, or enter a different value. The command-line interactive method does not provide prompts for all functionality and is provided only for backward compatibility. If you want to use an interactive interface, Oracle recommends that you use the Oracle Enterprise Manager Export or Import Wizard.
For example, if beth is a privileged user exporting in table mode, Export assumes that all tables are in the beth schema until another schema is specified. Only a privileged user (someone with the EXP_FULL_DATABASE role) can export tables in another user's schema.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 34 of 212
The following restrictions apply when you process data with the Export and Import utilities:
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 35 of 212
When a type definition has evolved and then data referencing that evolved type is exported, the type definition on the import system must have evolved in the same manner. The table compression attribute of tables and partitions is preserved during export and import. However, the import process does not use the direct path API, hence the data will not be stored in the compressed format when imported.
Note: When tables are manually created before data is imported, the CREATE TABLE statement in the export dump file will fail because the table already exists. To avoid this failure and continue loading data into the table, set the Import parameter IGNORE=y. Otherwise, no data will be loaded into the table because of the table creation error.
Page 36 of 212
row might fail the referential integrity constraint if the manager's row has not yet been imported. When such an error occurs, Import generates an error message, bypasses the failed row, and continues importing other rows in the table. You can disable constraints manually to avoid this. Referential constraints between tables can also cause problems. For example, if the emp table appears before the dept table in the export file, but a referentia l check exists from the emp table into the dept table, some of the rows from the emp table may not be imported due to a referential constraint violation. To prevent errors like these, you should disable referential integrity constraints when importing data into existing tables.
www.wilshiresoft.com [email protected]
Data Pump
Page 37 of 212
6. Data Pump
Oracle Data Pump technology enables very high-speed movement of data and metadata from one data base to another.
The Data Pump clients, expdp and impdp, invoke the Data Pump Export utility and Data Pump Import utility, respectively. They provide a user interface that closely resembles the original Export (exp) and Import (imp) utilities. Note: Dump files generated by the Data Pump Export utility are not compatible with dump files generated by the original Export utility. Therefore, files generated by the original Export (exp) utility cannot be imported with the Data Pump Import (impdp) utility. In most cases, Oracle recommends that you use the Data Pump Export and Import utilities. They provide enhanced data movement performance in comparison to the original Export and Import utilities. The expdp and impdp clients use the procedures provided in the DBMS_DATAPUMP PL/SQL package to execute export and import commands, using the parameters entered at the command-line. These parameters enable the exporting and importing of data and metadata for a complete database or for subsets of a database.When metadata is moved, Data Pump uses functionality provided by the DBMS_METADATA PL/SQL package. The DBMS_METADATA package provides a centralized facility for the extraction, manipulation, and resubmission of dictionary metadata. The DBMS_DATAPUMP and DBMS_METADATA PL/SQL packages can be used independently of the Data Pump clients. Note: All Data Pump Export and Import processing, including the reading and writing of dump files, is done on the system (server) selected by the specified database connect string. This means that, for non-privileged users, the database administrator (DBA) must create directory objects for the Data Pump files that are read and written on that server file system. For privileged users, a default directory object is available. Note: Data Pump Export and Import are not supported on physical or logical standby databases except for initial table instantiation on a logical standby.
Note: Data Pump will not load tables with disabled unique indexes. If the data needs to be loaded into the table, the indexes must be either dropped or reenabled. Note: There are a few situations in which Data Pump will not be able to load data into a table using either direct path or external tables. This occurs when there are conflicting table attributes. For example, a conflict occurs if a table contains a column of datatype LONG (which requires the direct path access method) but also has a condition
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Data Pump
Page 38 of 212
that prevents use of direct path access. In such cases, an ORA-39242 error message is generated. To work around this, prior to import, create the table with a LOB column instead of a LONG column. You can then perform the import and use the TABLE_EXISTS_ACTION parameter with a value of either APPEND or TRUNCATE.
When an export operation uses data file copying, the corresponding import job always also uses data file copying. During the ensuing import operation, you will be loading both the data files and the export dump file. When data is moved by using data file copying, the character sets must be identical on both the source and target databases. Therefore, in addition to copying the data, you may need to prepare it by using the Recovery Manager (RMAN) CONVERT command to perform some data conversions. You can generally do this at either the source or target database.
www.wilshiresoft.com [email protected]
Data Pump
Page 39 of 212
The table contains one or more columns of type BFILE or opaque, or an object type containing opaque columns. The table contains encrypted columns. The table contains a column of an evolved type that needs upgrading. The table contains a column of type LONG or LONG RAW that is not last. The Data Pump command for the specified table used the QUERY, SAMPLE, or REMAP_DATA parameter.
Unsupported Link Types The database link type, Current User, is not supported for use with Data Pump Export or Import:
The master table is created in the schema of the current user performing the export or import operation. Therefore, that user must have the CREATE TABLE system privilege and a sufficient tablespace quota for creation of the master table. The name of the master table is the same as the name of the job that created it. Therefore, you cannot explicitly give a Data Pump job the same name as a preexisting table or view. For all operations, the information in the master table is used to restart a job. The master table is either retained or dropped, depending on the circumstances, as follows:
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Data Pump
Page 40 of 212
Upon successful job completion, the master table is dropped. If a job is stopped using the STOP_JOB interactive command, the master table is retained for use in restarting the job. If a job is killed using the KILL_JOB interactive command, the master table is dropped and the job cannot be restarted. If a job terminates unexpectedly, the master table is retained. You can delete it if you do not intend to restart the job. If a job stops before it starts running (that is, before any database objects have been copied), the master table is dropped.
www.wilshiresoft.com [email protected]
Data Pump
Page 41 of 212
Job status can be displayed on request in interactive-command mode. The information displayed can include the job description and state, a description of the current operation or item being processed, files being written, and a cumulative status. An alternative way to determine job status or to get other information about Data Pump jobs, would be to query the DBA_DATAPUMP_JOBS, USER_DATAPUMP_JOBS, or DBA_DATAPUMP_SESSIONS views.
An understanding of how Data Pump allocates and handles these files will help you to use Export and Import to their fullest advantage.
www.wilshiresoft.com [email protected]
Data Pump The reason that a directory object is required is to ensure data security and integrity. For example:
Page 42 of 212
If you were allowed to specify a directory path location for an input file, you might be able to read data that the server has access to, but to which you should not. If you were allowed to specify a directory path location for an output file, the server might overwrite a file that you might not normally have privileges to delete.
On UNIX and Windows NT systems, a default directory object, DATA_PUMP_DIR, is created at database creation or whenever the database dictionary is upgraded. By default, it is available only to privileged users. If you are not a privileged user, before you can run Data Pump Export or Data Pump Import, a directory object must be created by a database administrator (DBA) or by any user with the CREATE ANY DIRECTORY privilege. After a directory is created, the user creating the directory object needs to grant READ or WRITE permission on the directory to other users. For example, to allow the Oracle database to read and write files on behalf of user hr in the directory named by dpump_dir1, the DBA must execute the following command: SQL> GRANT READ, WRITE ON DIRECTORY dpump_dir1 TO hr; Note that READ or WRITE permission to a directory object only means that the Oracle database will read or write that file on your behalf. You are not given direct access to those files outside of the Oracle database unless you have the appropriate operating system privileges. Similarly, the Oracle database requires permission from the operating system to read and write files in the directories. Data Pump Export and Import use the following order of precedence to determine a file's location: 1. If a directory object is specified as part of the file specification, then the location specified by that directory object is used. (The directory object must be separated from the filename by a colon.) 2. If a directory object is not specified for a file, then the directory object named by the DIRECTORY parameter is used. 3. If a directory object is not specified, and if no directory object was named by the DIRECTORY parameter, then the value of the environment variable, DATA_PUMP_DIR, is used. This environment variable is defined using operating system commands on the client system where the Data Pump Export and Import utilities are run. The value assigned to this client-based environment variable must be the name of a server-based directory object, which must first be created on the server system by a DBA. For example, the following SQL statement creates a directory object on the server system. The name of the directory object is DUMP_FILES1, and it is located at '/usr/apps/dumpfiles1'. SQL> CREATE DIRECTORY DUMP_FILES1 AS '/usr/apps/dumpfiles1'; Then, a user on a UNIX-based client system using csh can assign the value DUMP_FILES1 to the environment variable DATA_PUMP_DIR. The DIRECTORY parameter can then be omitted from the command line. The dump file employees.dmp, as well as the log file export.log, will be written to '/usr/apps/dumpfiles1'. %setenv DATA_PUMP_DIR DUMP_FILES1 %expdp hr TABLES=employees DUMPFILE=employees.dmp 4. If none of the previous three conditions yields a directory object and you are a privileged user, then Data Pump attemp ts to use the value of the default server-based directory object, DATA_PUMP_DIR. This directory object is automatically created at database creation or when the database dictionary is upgraded. You can use the following SQL query to see the path definition for DATA_PUMP_DIR: SQL> SELECT directory_name, directory_path FROM dba_directories 2 WHERE directory_name=DATA_PUMP_DIR; If you are not a privileged user, access to the DATA_PUMP_DIR directory object must have previously been granted to you by a DBA. Do not confuse the default DATA_PUMP_DIR directory object with the client-based environment variable of the same name.
www.wilshiresoft.com [email protected]
Data Pump
Page 43 of 212
www.wilshiresoft.com [email protected]
Data Pump 11.1, the remote database must be either version 10.2 or 11.1.
Page 44 of 212
Data Pump
Page 45 of 212
A schema export is specified using the SCHEMAS parameter. This is the default export mode. If you have the EXP_FULL_DATABASE role, then you can specify a list of schemas and optionally include the schema definitions themselves, as well as system privilege grants to those schemas. If you do not have the EXP_FULL_DATABASE role, you can export only your own schema. The SYS schema cannot be used as a source schema for export jobs. Cross-schema references are not exported unless the referenced schema is also specified in the list of schemas to be exported. For example, a trigger defined on a table within one of the specified schemas, but that resides in a schema not explicitly specified, is not exported. This is also true for external type definitions upon which tables in the specified schemas depend. In such a case, it is expected that the type definitions already exist in the target instance at import time. Table Mode A table mode export is specified using the TABLES parameter. In table mode, only a specified set of tables, partitions, and their dependent objects are unloaded. If you specify the TRANSPORTABLE=ALWAYS parameter in conjunction with the TABLES parameter, then only object metadata is unloaded. To move the actual data, you copy the data files to the target database. This results in quicker export times. If you are moving data files between versions or platforms, the data files may need to be processed by Oracle Recovery Manager (RMAN). You must have the EXP_FULL_DATABASE role to specify tables that are not in your own schema. All specified tables must reside in a single schema. Note that type definitions for columns are not exported in table mode. It is expected that the type definitions already exist in the target instance at import time. Also, as in schema exports, cross-schema references are not exported. Tablespace Mode A tablespace export is specified using the TABLESPACES parameter. In tablespace mode, only the tables contained in a specified set of tablespaces are unloaded. If a table is unloaded, its dependent objects are also unloaded. Both object metadata and data are unloaded. In tablespace mode, if any part of a table resides in the specified set, then that table and all of its dependent objects are exported. Privileged users get all tables. Nonprivileged users get only the tables in their own schemas. Transportable Tablespace Mode A transportable tablespace export is specified using the TRANSPORT_TABLESPACES parameter. In transportable tablespace mode, only the metadata for the tables (and their dependent objects) within a specified set of tablespaces is exported. The tablespace datafiles are copied in a separate operation. Then, a transportable tablespace import is performed to import the dump file containing the metadata and to specify the datafiles to use. Transportable tablespace mode requires that the specified tables be completely self-contained. That is, all storage segments of all tables (and their indexes) defined within the tablespace set must also be contained within the set. If there are self-containment violations, Export identifies all of the problems without actually performing the export. Transportable tablespace exports cannot be restarted once stopped. Also, they cannot have a degree of parallelism greater than 1.Encrypted columns are not supported in transportable tablespace mode. Note: You cannot export transportable tablespaces and then import them into a database at a lower release level. The target database must be at the same or higher release level as the source database.
Data Pump Production With the Partitioning, Data Mining and Real Application Testing options
Page 46 of 212
The local Export client connects to the database instance identified by the connect descriptor inst1 (a simple net service name, usually defined in a tnsnames.ora file), to export the data on that instance. Do not confuse invoking the Export utility using a connect identifier with an export operation specifying the Export NETWORK_LINK command-line parameter. When you perform an export and use the NETWORK_LINK parameter, the export is initiated over a database link. Whereas, when you start an export operation and specify a connect identifier, the local Export client connects to the database instance identified by the command-line connect string, retrieves the data to be exported from the database instance identified by the database link, and writes the data to a dump file set on the connected database instance. Data Pump Export provides much greater data and metadata filtering capability than was provided by the original Export utility.
www.wilshiresoft.com [email protected]
Data Pump
Page 47 of 212
parameter file interface. Interactive-command mode is also enabled when you attach to an executing or stopped job.
Note: When you import a dump file that was created by a full-mode export, the import operation attempts to copy the password for the SYS account from the source database. This sometimes fails (for example, if the password is in a shared password file). If it does fail, then after the import completes, you must set the password for the SYS account at the target database to a password of your choice. Note: Jobs (created by the Oracle Database job scheduler) are always imported to the schema of the importing user. After an import, if you query the DBA_JOBS view you will see that LOG_USER and PRIV_USER values are set to the importing user, regardless of how they were set on the export platform. To work around this, you must perform both the export and the import as the job owner. Full Import Mode A full import is specified using the FULL parameter. In full import mode, the entire content of the source (dump file set or another database) is loa ded into the target database. This is the default for file-based imports. You must have the IMP_FULL_DATABASE role if the source is another database. Cross-schema references are not imported for non-privileged users. For example, a trigger defined on a table within the importing user's schema, but residing in another user's schema, is not imported. The IMP_FULL_DATABASE role is required on the target database and the EXP_FULL_DATABASE role is required on the source database if the NETWORK_LINK parameter is used for a full import. Schema Mode A schema import is specified using the SCHEMAS parameter. In a schema import, only objects owned by the specified schemas are loaded. The source can be a full, table, tablespace, or schema-mode export dump file set or another database. If you have the IMP_FULL_DATABASE role, then a list of schemas can be specified and the schemas themselves (including system privilege grants) are created in the database in addition to the objects contained within those schemas. Cross-schema references are not imported for non-privileged users unless the other schema is remapped to the current schema. For example, a trigger defined on a table within the importing user's schema, but residing in another user's schema, is not imported. Table Mode A table-mode import is specified using the TABLES parameter. In table mode, only the specified set of tables, partitions, and their dependent objects are loaded. The source can be a full, schema, tablespace, or table-mode export dump file set or another database. You must have the IMP_FULL_DATABASE role to specify tables that are not in your own schema. You can use the transportable option during a table-mode import by specifying the TRANPORTABLE=ALWAYS parameter in conjunction with the TABLES parameter. Note that this requires use of the NETWORK_LINK parameter, as well. Tablespace Mode A tablespace-mode import is specified using the TABLESPACES parameter. In tablespace mode, all objects contained within the specified set of tablespaces are loaded, along with the dependent objects. The source can be a
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Data Pump
Page 48 of 212
full, schema, tablespace, or table-mode export dump file set or another database. For unprivileged users, objects not remapped to the current schema will not be processed.
Transportable Tablespace Mode A transportable tablespace import is specified using the TRANSPORT_TABLESPACES parameter. In transportable tablespace mode, the metadata from a transportable tablespace export dump file set or from another database is loaded. The datafiles, specified by the TRANSPORT_DATAFILES parameter, must be made available from the source system for use in the target database, typically by copying them over to the target system. Encrypted columns are not supported in transportable tablespace mode. This mode requires the IMP_FULL_DATABASE role. Note: You cannot export transportable tablespaces and then import them into a database at a lower release level. The target database must be at the same or higher release level as the source database. Network Considerations You can specify a connect identifier in the connect string when you invoke the Data Pump Import utility. This identifier can specify a database instance that is different from the current instance identified by the current Oracle System ID (SID). The connect identifier can be an Oracle*Net connect descriptor or a name that maps to a connect descriptor. This requires an active listener (to start the listener, enter lsnrctl start) that can be located using the connect descriptor. The following example invokes Import for user hr, using the connect descriptor named inst1: > impdp hr DIRECTORY=dpump_dir1 DUMPFILE=hr.dmp TABLES=employees Import: Release 11.1.0.6.0 - Production on Monday, 27 August, 2007 12:25:57 Copyright (c) 2003, 2007, Oracle. Password: password@inst1 Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 Production The local Import client connects to the database instance identified by the connect descriptor inst1 (a simple net service name, usually defined in a tnsnames.ora file), to import the data from the dump file set to that database. Do not confuse invoking the Import utility using a connect identifier with an import operation specifying the Import NETWORK_LINK command-line parameter, which initiates an import using a database link. In this case, the local Import client connects to the database instance identified by the command-line connect string, retrieves the data to be imported from the database instance identified by the database link, and writes the data to the connected database instance. There is no dump file set involved. Data Pump Import provides much greater data and metadata filtering capability than was provided by the original Import utility. All rights reserved.
www.wilshiresoft.com [email protected]
Page 49 of 212
As a backup administrator, you may also be asked to perform other duties that are related to backup and recovery: Data preservation, which involves creating a database copy for long-term storage Data transfer, which involves moving data from one database or one host to another The purpose of this manual is to explain how to perform the preceding tasks.
Page 50 of 212
Page 51 of 212
You repair a datafile with only a small number of corrupt data blocks without taking it offline or restoring it from backup. You use the RECOVER command to perform block media recovery. Unused block compression In unused block compression, RMAN can skip data blocks that have never been used and, in some cases, used blocks that are currently unused. Binary compression A binary compression mechanism integrated into Oracle Database reduces the size of backups. Encrypted backups RMAN uses backup encryption capabilities integrated into Oracle Data base to store backup sets in an encrypted format. To create encrypted backups on disk, the database must use the Advanced Security Option. To create encrypted backups directly on tape, RMAN must use the Oracle Secure Backup SBT interface, but does not require the Advanced Security Option. Whether you use RMAN or user-managed methods, you can supplement physical backups with logical backups of schema objects made with Data Pump Export utility. You can later use Data Pump Import to re-create data after restore and recovery. Table summarizes the features of the different backup techniques.
Page 52 of 212
point-in-time recovery. In general, flashback features are more efficient and less disruptive than media recovery in most situations in which they apply.
Page 53 of 212
the flashback logs can only be stored there. Flashback logging is not enabled by default. Space used for flashback logs is managed automatically by the database and balanced against space required for other files in the flash recovery area. Oracle Database also supports restore points in conjunction with Flashback Database and backup and recovery. A restore point is an alias corresponding to an SCN. You can create a restore point at any time if you anticipate needing to return part or all of a database to its contents at that time. A guaranteed restore point ensures that you can use Flashback Database to return a database to the time of the restore point.
www.wilshiresoft.com [email protected]
Page 54 of 212
ORDER BY t.NAME; 2. Obtain the filenames of the current control files by querying the V$CONTROLFILE view. For example, issue the following query: SELECT NAME FROM V$CONTROLFILE; Note that you only need to back up one copy of a multiplexed control file. 3. If you plan to take a control file backup with the ALTER DATABASE BACKUP CONTROLFILE TO 'filename' statement, then save a list of all datafiles and online redo log files with the control file backup. Because the current database structure may not match the database structure at the time a given control file backup was created, saving a list of files recorded in the backup control file can aid the recovery procedure.
www.wilshiresoft.com [email protected]
Page 55 of 212
The following sample output shows that the tools and users tablespaces currently have ACTIVE status: TB_NAME DF# DF_NAME STATUS ---------------------TOOLS USERS ---------- -------------------------------7 8 /oracle/oradata/trgt/tools01.dbf /oracle/oradata/trgt/users01.dbf -----ACTIVE ACTIVE
In the STATUS column, NOT ACTIVE indicates that the file is not currently in backup mode (that is, you have not executed the ALTER TABLESPACE ... BEGIN BACKUP or ALTER DATABASE BEGIN BACKUP statement), whereas ACTIVE indicates that the file is currently in backup mode.
Page 56 of 212
Assume that a table is in tablespace Primary and its index is in tablespace Index. Taking tablespace Index offline while leaving tablespace Primary online can cause errors when DML is issued against the indexed tables located in Primary. The problem only manifests when the access method chosen by the optimizer needs to access the indexes in the Index tablespace. To back up offline tablespaces: 1. Before beginning a backup of a tablespace, identify the tablespace's datafiles by querying the DBA_DATA_FILES view. For example, assume that you want to back up the users tablespace. Enter the following statement in SQL*Plus: SELECT TABLESPACE_NAME, FILE_NAME FROM SYS.DBA_DATA_FILES WHERE TABLESPACE_NAME = 'USERS';
TABLESPACE_NAME ------------------------------USERS
FILE_NAME -------------------------------/oracle/oradata/trgt/users01.dbf
In this example, /oracle/oradata/trgt/users01.dbf is a fully specified filename corresponding to the datafile in the users tablespace. 2. Take the tablespace offline using normal priority if possible because it guarantees that you ca n subsequently bring the tablespace online without having to recover it. For example: SQL> ALTER TABLESPACE users OFFLINE NORMAL; 3. Back up the offline datafiles. For example: % cp /oracle/oradata/trgt/users01.dbf /d2/users01_'date "+%m_%d_%y"'.dbf 4. Bring the tablespace online. For example: ALTER TABLESPACE users ONLINE; Note: If you took the tablespace offline using temporary or immediate priority, then you cannot bring the tablespace online unless you perform tablespace recovery. 5. Archive the unarchived redo logs so that the redo required to recover the tablespace backup is archived. For example, enter: ALTER SYSTEM ARCHIVE LOG CURRENT;
www.wilshiresoft.com [email protected]
Page 57 of 212
1. Before beginning a backup of a tablespace, identify all of the datafiles in the tablespace with the DBA_DATA_FILES data dictionary view. For example, assume that you want to back up the users tablespace. Enter the following: SELECT TABLESPACE_NAME, FILE_NAME FROM WHERE SYS.DBA_DATA_FILES TABLESPACE_NAME = 'USERS'; FILE_NAME -------------------/oracle/oradata/trgt/users01.dbf /oracle/oradata/trgt/users02.dbf
2. Mark the beginning of the online tablespace backup. For example, the following statement marks the start of an online backup for the tablespace users: SQL> ALTER TABLESPACE users BEGIN BACKUP; Caution: If you do not use BEGIN BACKUP to mark the beginning of an online tablespace backup and wait for this statement to complete before starting your copies of online tablespaces, then the datafile copies produced are not usable for subsequent recovery operations. Attempting to recover such a backup is risky and can return errors that result in inconsistent data. For example, the attempted recovery operation can issue a fuzzy file warning, and can lead to an inconsistent database that you cannot open. 3. Back up the online datafiles of the online tablespace with operating system commands. For example, Linux and UNIX users might enter: % cp /oracle/oradata/trgt/users01.dbf /d2/users01_'date "+%m_%d_%y"'.dbf % cp /oracle/oradata/trgt/users02.dbf /d2/users02_'date "+%m_%d_%y"'.dbf 4. After backing up the datafiles of the online tablespace, run the SQL statement ALTER TABLESPACE with the END BACKUP option. For example, the following statement ends the online backup of the tablespace users: SQL> ALTER TABLESPACE users END BACKUP; 5. Archive the unarchived redo logs so that the redo required to recover the tablespace backup is archived. For example, enter: SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; Caution: If you fail to take the tablespace out of backup mode, then Oracle Database continues to write copies of data blocks in this tablespace to the online redo logs, causing performance problems. Also, you receive an ORA01149 error if you try to shut down the database with the tablespaces still in backup mode.
User Managed Database Backups % cp $ORACLE_HOME/oradata/trgt/*.dbf /disk2/backup/ 3. Take the tablespaces out of backup mode as in the following example: SQL> ALTER TABLESPACE users END BACKUP; SQL> ALTER TABLESPACE tools END BACKUP; SQL> ALTER TABLESPACE indx END BACKUP;
Page 58 of 212
Again, it you are handling all datafiles at once you can use the ALTER DATABASE command instead of ALTER TABLESPACE: SQL> ALTER DATABASE END BACKUP; 4. Archive the online redo logs so that the redo required to recover the tablespace backups will be available for later media recovery. For example, enter: SQL> ALTER SYSTEM ARCHIVE LOG CURRENT; Backing up Online Tablespaces Serially You can place all tablespaces requiring online backups in backup mode one at a time. Oracle recommends the serial backup option because it minimizes the time between ALTER TABLESPACE ... BEGIN/END BACKUP statements. During online backups, more redo information is generated for the tablespace because whole data blocks are copied into the redo log. To back up online tablespaces serially: 1. Prepare a tablespace for online backup. For example, to put tablespace users in backup mode enter the following: SQL> ALTER TABLESPACE users BEGIN BACKUP; In this case you probably do not want to use ALTER DATABASE BEGIN BACKUP to put all tablespaces in backup mode simultaneously, because of the unnecessary volume of redo log information generated for tablespaces in online mode. 2. Back up the datafiles in the tablespace. For example, enter: % cp /oracle/oradata/trgt/users01.dbf /d2/users01_'date "+%m_%d_%y"'.dbf 3. Take the tablespace out of backup mode. For example, enter: SQL> ALTER TABLESPACE users END BACKUP; 4. Repeat this procedure for each remaining tablespace. 5. Archive the unarchived redo logs so that the redo required to recover the tablespace backups is archived. For example, enter: SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
Page 59 of 212
2. Runs the ALTER DATABASE END BACKUP statement 3. Runs ALTER DATABASE OPEN, allowing the system to come up automatically An automated crash recovery script containing ALTER DATABASE END BACKUP is especially useful in the following situations: All nodes in an Oracle Real Application Clusters (Oracle RAC) configuration fail. One node fails in a cold failover cluster (that is, a cluster that is not a RAC configuration in which the secondary node must mount and recover the database when the first node fails). Alternatively, you can take the following manual measures after the system fails with tablespaces in backup mode: Recover the database and avoid issuing END BACKUP statements altogether. Mount the database, then run ALTER TABLESPACE ... END BACKUP for each tablespace still in backup mode. Ending Backup Mode with the ALTER DATABASE END BACKUP Statement you can run the ALTER DATABASE END BACKUP statement when you have multiple tablespaces still in backup mode. The primary purpose of this command is to allow a crash recovery script to restart a failed system without DBA intervention. You can also perform the following procedure manually. To take tablespaces out of backup mode simultaneously: 1. Mount but do not open the database. For example, enter: SQL> STARTUP MOUNT 2. If performing this procedure manually (that is, not as part of a crash recovery script), query the V$BACKUP view to list the datafiles of the tablespaces that were being backed up before the database was restarted: SQL> SELECT * FROM V$BACKUP WHERE STATUS = 'ACTIVE'; FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- --------12 ACTIVE 13 ACTIVE 20 ACTIVE 3 rows selected. 3. Issue the ALTER DATABASE END BACKUP statement to take all datafiles currently in backup mode out of backup mode. For example, enter: SQL> ALTER DATABASE END BACKUP; You can use this statement only when the database is mounted but not open. If the database is open, then use ALTER TABLESPACE ... END BACKUP or ALTER DATABASE DATAFILE ... END BACKUP for each affected tablespace or datafile. Caution: Do not use ALTER DATABASE END BACKUP if you have restored any of the affected files from a backup. Ending Backup Mode with the SQL*Plus RECOVER Command: The ALTER DATABASE END BACKUP statement is not the only way to respond to a failed online backup: you can also run the SQL*Plus RECOVER command. This method is useful when you are not sure whether someone has restored a backup, because if someone has indeed restored a backup, then the RECOVER command brings the backup up to date. Only run the ALTER DATABASE END BACKUP or ALTER TABLESPACE ... END BACKUP statement if you are sure that the files are current. Note: The RECOVER command method is slow because the database must scan redo generated from the beginning of the online backup. To take tablespaces out of backup mode with the RECOVER command:
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
User Managed Database Backups 1. Mount the database. For example, enter: SQL> STARTUP MOUNT 2. Recover the database as normal. For example, enter: SQL> RECOVER DATABASE 3. Use the V$BACKUP view to confirm that there are no active datafiles: SQL> SELECT * FROM V$BACKUP WHERE STATUS = 'ACTIVE'; FILE# STATUS CHANGE# TIME
Page 60 of 212
3. Back up the online datafiles of the read-only tablespace with operating system commands. You do not have to take the tablespace offline or put the tablespace in backup mode because users are automatically prevented from making changes to the read-only tablespace. For example: % cp $ORACLE_HOME/oradata/trgt/history*.dbf /disk2/backup/ Note: When restoring a backup of a read-only tablespace, take the tablespace offline, restore the datafiles, and then bring the tablespace online. A backup of a read-only tablespace is still usable if the read-only tablespace is made read/write after the backup, but the restored backup will require recovery. 4. Optionally, export the metadata in the read-only tablespace. By using the transportable tablespace feature, you can quickly restore the datafiles and import the metadata in case of media failure or user error. For example, export the metadata for tablespace history as follows: % expdp DIRECTORY=dpump_dir1 DUMPFILE=hs.dmp TRANSPORT_TABLESPACES=history > LOGFILE=tts.log
www.wilshiresoft.com [email protected]
Page 61 of 212
www.wilshiresoft.com [email protected]
Recovery Manager(RMAN)
Page 62 of 212
www.wilshiresoft.com [email protected]
Recovery Manager(RMAN)
Page 63 of 212
You can connect to a database with command-line options or by using the CONNECT TARGET command. The following example starts RMAN and then connects to a target database through Oracle Net (note that AS SYSDBA is not specified because it is implied). RMAN prompts for a password. % rman RMAN> CONNECT TARGET SYS@prod target database Password: password connected to target database: PROD (DBID=39525561) The following variation starts RMAN and then connects to a target database by using operating system authentication: % rman RMAN> CONNECT TARGET / connected to target database: PROD (DBID=39525561) To quit the RMAN client, enter EXIT at the RMAN prompt: RMAN> EXIT
connectStringSpec::= ['] [userid] [/ [password]] [@net_service_name] ['] The following example appends the output from an RMAN session to a text file at /tmp/msglog.log % rman TARGET / LOG /tmp/msglog.log APPEND
www.wilshiresoft.com [email protected]
Recovery Manager(RMAN)
Page 64 of 212
www.wilshiresoft.com [email protected]
Recovery Manager(RMAN)
Page 65 of 212
If you specify BACKUP INCREMENTAL, then RMAN creates an incremental backup of a database. Incremental backups capture block-level changes to a database made after a previous incremental backup. Incremental backups are generally smaller and faster to make than full database backups. Recovery with incremental backups is faster than using redo logs alone. The starting point for an incremental backup strategy is a level 0 incremental backup, which backs up all blocks in the database. An incremental backup at level 0 is identical in content to a full backup, but unlike a full backup the level 0 backup is considered a part of the incremental backup strategy. A level 1 incremental backup contains only blocks changed after a previous incremental backup. If no level 0 backup exists in either the current or parent database incarnation when you run a level 1 backup, then RMAN makes a level 0 backup automatically. Note: You cannot make incremental backups when a NOARCHIVELOG database is open, although you can make incremental backups when the database is mounted after a consistent shutdown. A level 1 backup can be a cumulative incremental backup, which includes all blocks changed since the most recent level 0 backup, or a differential incremental backup, which includes only blocks changed since the most recent incremental backup. Incremental backups are differential by default. When restoring incremental backups, RMAN uses the level 0 backup as the starting point, then updates changed blocks based on level 1 backups where possible to avoid reapplying changes from redo one at a time. Recovering with incremental backups requires no additional effort on your part. If incremental backups are available, then RMAN uses them during recovery. To make incremental backups of the database: 1. Start RMAN and connect to a target database. 2. Run the BACKUP INCREMENTAL command. The following example creates a level 0 incremental backup to serve as a base for an incremental backup strategy: BACKUP INCREMENTAL LEVEL 0 DATABASE; The following example creates a level 1 cumulative incremental backup: BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE; The following example creates a level 1 differential incremental backup: BACKUP INCREMENTAL LEVEL 1 DATABASE;
Recovery Manager(RMAN)
Page 66 of 212
to use with FOR RECOVER OF COPY to implement an incrementally updated backup strategy. To implement an incrementally updated backup strategy: 1. Start RMAN and connect to a target database. 2. Run the RECOVER COPY and BACKUP INCREMENTAL commands. The following script, run on a regular basis, is all that is required to implement a strategy based on incrementally updated backups. RECOVER COPY OF DATABASE WITH TAG 'incr_update'; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE; You can use the VALIDATE command to confirm that all database files exist, are in their correct location, and are free of physical corruption. The CHECK LOGICAL option also checks for logical block corruption. To validate database files: 1. Start RMAN and connect to a target database. 2. Run the VALIDATE command for the desired files. For example, enter the following commands to validate all database files and archived redo log files for physical and logical corruption: BACKUP VALIDATE CHECK LOGICAL DATABASE ARCHIVELOG ALL; You can also use the VALIDATE command to individual data blocks, as shown in the following example: VALIDATE DATAFILE 4 BLOCK 10 TO 13; You can also validate backup sets, as shown in the following example: VALIDATE BACKUPSET 3; You specify backup sets by primary key, which is shown in the output of the LIST BACKUP command.
www.wilshiresoft.com [email protected]
Recovery Manager(RMAN)
Page 67 of 212
To list backups and copies: 1. Start RMAN and connect to a target database. 2. Run the LIST command at the RMAN prompt. You can display specific objects, as in the following examples: LIST BACKUP OF DATABASE; LIST COPY OF DATAFILE 1, 2; LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 10; LIST BACKUPSET OF DATAFILE 1;
To generate reports of database files and backups: 1. Start RMAN and connect to a target database. 2. Run the REPORT command at the RMAN prompt. The following example reports backups that are obsolete according to the currently configured backup retention policy: REPORT OBSOLETE; The following example reports the datafiles and tempfiles in the database:
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 68 of 212
HIGH
OPEN
23-APR-07
Page 69 of 212
RMAN> ADVISE FAILURE; List of Database Failures ========================= Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- ------142 HIGH OPEN 23-APR-07 One or more non-system datafiles are missing 101 HIGH OPEN 23-APR-07 Datafile 1:
analyzing automatic repair options; this may take some time using channel ORA_DISK_1 analyzing automatic repair options complete
Mandatory Manual Actions ======================== no manual actions available Optional Manual Actions ======================= 1. If file /disk1/oradata/prod/users01.dbf was unintentionally renamed or moved, restore it Automated Repair Options ======================== Option Repair Description ------ -----------------1 Restore and recover datafile 28; Perform block media recovery of block 56416 in file 1 Strategy: The repair includes complete media recovery with no data loss Repair script: /disk1/oracle/log/diag/rdbms/prod/prod/hm/reco_660500184.hm The ADVISE FAILURE output shows both manual and automated repair options. First try to fix the problem manually. If you cannot fix the problem manually, then review the automated repair section. An automated repair option describes a server-managed repair for one or more failures. Repairs are consolidated when possible so that a single repair can fix multiple failures. The repair option indicates which repair will be performed and whether data will be lost by performing the repair. In Example, the output indicates the filename of a repair script containing RMAN commands. If you do not want to use Data Recovery Advisor to repair the failure automatically, then you can use the script as the basis of your own recovery strategy.
Page 70 of 212
By default, REPAIR FAILURE prompts for confirmation before it begins executing. After executing a repair, Data Recovery Advisor reevaluates all existing failures on the possibility that they may also have been fixed. Data Recovery Advisor always verifies that failures are still relevant and automatically closes fixed failures. If a repair fails to complete because of an error, then the error triggers a new assessment and re-evaluation of existing failures and repairs.
Recovery Manager(RMAN)
Page 71 of 212
not actually read the backup files. The database can be open when you run this command. To preview a database restore and recovery: 1. Start RMAN and connect to the target database. 2. Optionally, list the current tablespaces and datafiles, as shown in the following command: RMAN> REPORT SCHEMA; 3. Run the RESTORE DATABASE command with the PREVIEW option. The following command specifies SUMMARY so that the backup metadata is not displayed in verbose mode (sample output included): RMAN> RESTORE DATABASE PREVIEW SUMMARY; Starting restore at 21-MAY-07 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=80 device type=DISK List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
List of Archived Log Copies for database with db_unique_name PROD =====================================================================
Key
Thrd Seq
S Low Time
Name: /disk1/oracle/dbs/db1r_60ffa882_1_18_0622902157.arc
Media recovery start SCN is 586534 Recovery must be done beyond SCN 587194 to clear datafile fuzziness validation succeeded for backup piece Finished restore at 21-MAY-07
Recovery Manager(RMAN) 4. Recover the database, as shown in the following example: RMAN> RECOVER DATABASE; 5. Open the database, as shown in the following example: RMAN> ALTER DATABASE OPEN;
Page 72 of 212
RECOVER TABLESPACE users; } 4. Bring the tablespace online, as shown in the following example: RMAN> SQL 'ALTER TABLESPACE users ONLINE'; You can also use RESTORE DATAFILE and RECOVER DATAFILE for recovery at the datafile level.
RMAN - Architecture
Page 73 of 212
The only required components in an RMAN environment are a target database and RMAN client, but most realworld configurations are more complicated. For example, you could use an RMAN client connecting to multiple media managers and multiple target databases and auxiliary databases, all accessed through Enterprise Manager.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
RMAN - Architecture
Page 74 of 212
Figure illustrates components in a possible RMAN environment. The graphic shows that the primary database, standby database, and recovery catalog databases all reside on different computers. The primary and standby database hosts use a locally attached tape drive. The RMAN client and Enterprise Manager Console run on a separate computer. Figure - Sample RMAN Environment
www.wilshiresoft.com [email protected]
RMAN - Architecture
Page 75 of 212
Most RMAN commands are executed by channels, which must be either configured to persist across RMAN sessions, or manually allocated in each RMAN session. As illustrated in Figure, a channel establishes a connection from the RMAN client to a target or auxiliary database instance by starting a server session on the instance.
www.wilshiresoft.com [email protected]
RMAN - Architecture
Page 76 of 212
www.wilshiresoft.com [email protected]
RMAN - Architecture
Page 77 of 212
www.wilshiresoft.com [email protected]
RMAN - Architecture
Page 78 of 212
being connected as TARGET to this database, however, then RMAN changes configurations in the recovery catalog only.
www.wilshiresoft.com [email protected]
Page 79 of 212
Note: Most RMAN commands require that RMAN connect to at least a target database to perform useful work. To quit RMAN and terminate the program, enter EXIT or QUIT at the RMAN prompt: RMAN> EXIT
www.wilshiresoft.com [email protected]
Page 80 of 212
Starting & Interacting with RMAN Client allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=118 device type=DISK channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current SPFILE in backup set channel ORA_DISK_1: starting piece 1 at 30-APR-07 channel ORA_DISK_1: finished piece 1 at 30-APR-07 piece
Page 81 of 212
handle=/disk2/PROD/backupset/2007_04_30/o1_mf_nnsnf_TAG20070430T101234_33d8wgbj_.bkp tag=TAG20070430T101234 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 30-APR-07
Starting Control File and SPFILE Autobackup at 30-APR-07 piece handle=/disk1/oracle/dbs/c-32126750-20070430-00 comment=NONE Finished Control File and SPFILE Autobackup at 30-APR-07
CONNECT TARGET / RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=&1)'; BACKUP DATABASE TAG &2 FORMAT '/disk2/bck/&1%U.bck' KEEP FOREVER RESTORE POINT &3; } EXIT;
www.wilshiresoft.com [email protected]
Page 82 of 212
2. Create a shell script that you can use to run the RMAN command file created in the previous step. The following example creates a shell script named runbackup.sh. The example creates shell variables for the format and restore point name and accepts the values for these variables as command-line arguments to the script. #!/bin/tcsh # name: runbackup.sh # usage: use the tag name and number of copies as arguments set media_family = $argv[1] set format = $argv[2] set restore_point = $argv[3] rman @'/disk1/scripts/whole_db.cmd' USING $media_family $format $restore_point 3. Every quarter, execute the shell script created in the previous step, specifying the desired arguments on the command line. The following example runs the runbackup.sh shell script and passes it archival_backup as the media family name, bck0906 as the format string, and FY06Q3 as the restore point name. % runbackup.sh archival_backup bck0906 FY06Q3
RMAN> run { backup database; } The command has no syntax errors RMAN>
Starting & Interacting with RMAN Client RECOVER DATABASE; Assume that you create another command file, /tmp/badcmdfile, with the following contents: # command file with bad syntax commands RESTORE DATABASE RECOVER DATABASE
Page 83 of 212
2. Run the command file from the RMAN prompt in the following format, where filename is the name of the command file: % rman CHECKSYNTAX @filename The following example shows the output when you run /tmp/goodcmdfile with CHECKSYNTAX: RMAN> # command file with legal syntax 2> restore database; 3> recover database; 4> The cmdfile has no syntax errors Recovery Manager complete. In contrast, the following example shows the output you run /tmp/badcmdfile with CHECKSYNTAX: Making Database Connections with RMAN RMAN> #command file with syntax error 2> restore database 3> recover RMAN-00571: ======================================================== RMAN-00569:========= ERROR MESSAGE STACK FOLLOWS=============== RMAN-00571: =============================================== RMAN-00558: error encountered while parsing input commands RMAN-01005: syntax error: found "recover": expecting one of: "archivelog, channel, check, controlfile, clone, database, datafile, device, from, force, high, (, preview, ;, skip, spfile, standby, tablespace, until, validate" RMAN-01007: at line 3 column 1 file: /tmp/badcmdfile You make your command files dynamic by including substitution variables. When you check the syntax of a command file that contains substitution variables, RMAN prompts you to enter values. Example illustrates what happens you enter invalid values when checking the syntax of a dynamic command file. The text in bold indicates text entered as the prompt. Example - Checking the Syntax of a Command File with Bad Syntax RMAN> CONNECT TARGET * 2> BACKUP TAG Enter value for 1: mybackup abc COPIES Enter value for 2: mybackup abc RMAN-00571: ======================================================== RMAN-00569:========= ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =============================================== RMAN-00558: error encountered while parsing input commands
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Starting & Interacting with RMAN Client RMAN-01009: syntax error: found "identifier": expecting one of: "integer" RMAN-01008: the bad identifier was: mybackup RMAN-01007: at line 2 column 25 file: /tmp/whole_db.cmd RMAN indicates a syntax error because the string mybackup is not a valid argument for COPIES.
Page 84 of 212
Authentication for RMAN Database Connections RMAN connections to a database are specified and authenticated in the same way as SQL*Plus connections to a database. The only difference is that RMAN connections to a target or auxiliary database require the SYSDBA privilege. The AS SYSDBA keywords are implied for target and auxiliary connections and cannot be explicitly specified. A SYSDBA privilege is not required when connecting to the recovery catalog. Note that you must grant the RECOVERY_CATALOG_OWNER role to the catalog schema owner. Authentication for RMAN Database Connections Using the Operating System To connect to a database using operating system authentication, you must set the environment variable specifying the Oracle SID. For example, to set the SID to prod in some UNIX shells, you would enter: % ORACLE_SID=prod; export ORACLE_SID A special operating system groups controls SYSDBA connections when using operating system authentication. This group is generically referred to as OSDBA. The group is created and assigned a specific name as part of the database installation process. The specific name varies depending upon your operating system. If the current operating system user is a member of the OSDBA group, and if the Oracle SID is set, then RMAN can connect to this database with SYSDBA privileges as follows: % rman TARGET / Authentication for RMAN Database Connections Using a Password File If a database uses a password file, and then RMAN can use a password to connect to this database. Use a password file for either local or remote access. You must use a password file if you are connecting remotely as SYSDBA with a net service name.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 85 of 212
Caution: Good security practice requires that passwords should not be entered in plain text on the command line. You should enter passwords in RMAN only when requested by an RMAN prompt. You can start RMAN without a password in the connect string, as in this example: % rman TARGET SYS@prod
target database Password: password connected to target database: PROD1 (DBID=39525561) RMAN prompts for a password and does not echo the characters.
11.4.4 Making RMAN Database Connections from the Operating System Command Line
To connect to a target database from the operating system command line, enter the rman command followed by the connection information. You can begin executing commands after the RMAN prompt is displayed. Example - Connecting to a Target Database from the System Prompt % rman TARGET / NOCATALOG connected to target database: PROD (DBID=39525561) using target database control file instead of recovery catalog RMAN> Example illustrates a connection to a target database that uses Oracle Net authentication. RMAN prompts for the password. Example - Connecting to a Target Database from the System Prompt % rman TARGET SYS@prod NOCATALOG target database Password: password connected to target database: PROD (DBID=39525561) RMAN> Use the CATALOG keyword to connect to a recovery catalog. Example illustrates a connection that uses Oracle Net authentication for the target and recovery catalog databases. In both cases RMAN prompts for a password. Example -Connecting to Target and Catalog Databases from the System Prompt % rman TARGET SYS@prod CATALOG rco@catdb target database Password: password connected to target database: PROD (DBID=39525561) recovery catalog database Password: password connected to recovery catalog database RMAN> You can also start RMAN without specifying NOCATALOG or CATALOG. If you do not specify NOCATALOG on the command line, and if you do not specify CONNECT CATALOG after RMAN has started, then RMAN defaults to NOCATALOG mode the first time that you run a command that requires the use of the RMAN repository. Note: After you have executed a command that uses the RMAN repository in NOCATALOG mode, you must exit and restart RMAN to be able to connect to a recovery catalog. If you connect to the target database on the operating system command line, then you can begin executing commands after the RMAN prompt is displayed.
Page 86 of 212
To make a database connection from the RMAN prompt: 1. On the operating system command line, start the RMAN client without making a database connection. For example, enter rman as follows: % rman RMAN> 2. At the RMAN prompt, enter one or more CONNECT commands. The following example connects to a target database using operating system authentication: RMAN> CONNECT TARGET / The following alternative example connects to a target database and then a recovery catalog. The target connection uses operating system authentication, whereas the catalog database connection uses Oracle Net authentication. RMAN prompts for the password of the recovery catalog user. RMAN> CONNECT TARGET / RMAN> CONNECT CATALOG rco@catdb recovery catalog database Password: password connected to recovery catalog database The following example connects to a target database with database-level credentials. RMAN prompts for the SYS password. % rman RMAN> CONNECT TARGET SYS@prod target database Password: password connected to target database: PROD (DBID=39525561)
Starting & Interacting with RMAN Client RMAN> CONNECT TARGET * 2> LIST BACKUP; 3> connected to target database: RDBMS (DBID=771530996) using target database control file instead of recovery catalog List of Backup Sets =================== . . .
Page 87 of 212
www.wilshiresoft.com [email protected]
Page 88 of 212
Page 89 of 212
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/disk1/oracle/dbs/snapcf_ev.f'; # default You can also use the SHOW command with the name of a particular configuration. For example, you can view the retention policy and default device type as follows: SHOW RETENTION POLICY; SHOW DEFAULT DEVICE TYPE; 3. Optionally, use the CONFIGURE ... CLEAR command to return any configuration to its default value. You can use the CONFIGURE ... CLEAR command as shown in the following examples: CONFIGURE BACKUP OPTIMIZATION CLEAR; CONFIGURE RETENTION POLICY CLEAR; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
12.3.1 Configuring the Default Type for Backups: Backup Sets or Copies
The BACKUP command can create either backup sets or image copies. For disk, you can configure RMAN to create either backup sets or image copies as its default backup type with the CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO command. The default backup type for disk is an uncompressed backup set. Note: Because RMAN can write an image copy only to disk, the backup type for tape can only be a backup set. RMAN can create backup sets using binary compression. You can configure RMAN to use compressed backup sets by default on a device type by specifying the COMPRESSED option in the BACKUP TYPE TO ... BACKUPSET clause. To disable compression, use the CONFIGURE DEVICE TYPE command with arguments specifying your other desired settings, but omit the COMPRESSED keyword.
To configure the default type of backup: 1. Start RMAN and connect to a target database and a recovery catalog (if used). 2. Configure backup sets or image copies as the default backup type. The following examples configure the backup type for disk backups to copies and backup sets: CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # image copies CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # uncompressed The following examples configure compression for backup sets: CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET; CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;
www.wilshiresoft.com [email protected]
Page 90 of 212
old RMAN configuration parameters: CONFIGURE DEVICE TYPE 'SBT_TAPE' BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1; new RMAN configuration parameters: CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET; new RMAN configuration parameters are successfully stored
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 91 of 212
Example changes the default backup type for the SBT device to an uncompressed backup set (sample output included). Example - Configuring the Backup Type for an SBT Device RMAN> CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO BACKUPSET; old RMAN configuration parameters: CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET; new RMAN configuration parameters: CONFIGURE DEVICE TYPE 'SBT_TAPE' BACKUP TYPE TO BACKUPSET PARALLELISM 2; new RMAN configuration parameters are successfully stored Note that the CONFIGURE DEVICE TYPE commands used in this example to set parallelism and backup type do not affect the values of settings not specified. In Example, the default backup type of compressed backup set was not changed by changing the parallelism. In Example, the parallelism was not changed by changing the default backup type.
www.wilshiresoft.com [email protected]
Configuring the RMAN Environment QQ is the hex sequence that starts with 00 and has a maximum of FF.
Page 92 of 212
You can change the default format by using the following command, where device Specifier is any valid device type, and 'string' must contain the substitution variable %F (and no other substitution variables) and is a valid handle for the specified device: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE deviceSpecifier TO 'string'; For example, you can run the following command to specify a nondefault filename for the control file autobackup: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '?/oradata/cf_%F'; The following example configures the autobackup to write to an Automatic Storage Management disk group: CONFIGURE CONTROLFILE AUTOBACKUP FOR DEVICE TYPE DISK TO '+dgroup1/%F'; To clear control file autobackup formats for a device, use the following commands: CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE sbt CLEAR; If you have set up a flash recovery area for the database, then you can direct control file autobackups to the flash recovery area by clearing the control file autobackup format for disk.
Page 93 of 212
system backups to tape, as your media manager. You should refer to Oracle Secure Backup Administrator's Guide to learn how to set up RMAN for use specifically with Oracle Secure Backup. If you do not use Oracle Secure Backup, then you can use a third-party media manager. This section describes the generic steps for configuring RMAN for use with a third-party media manager. The actual steps depend on the media management product that you install and the platform on which you are running the database. If you choose to use RMAN with a media manager other than Oracle Secure Backup, then you must obtain all product-specific information from the vendor. Read the following sections in order when configuring the media manager: 1. Prerequisites for Using a Media Manager with RMAN 2. Determining the Location of the Media Management Library 3. Configuring Media Management Software for RMAN Backups 4. Testing Whether the Media Manager Library Is Integrated Correctly 5. Configuring SBT Channels for Use with a Media Manager
www.wilshiresoft.com [email protected]
Page 94 of 212
settings nstructs the media manager to back up to a family of tapes called datafile_mf. The PARMS settings are always vendor-specific. Example - PARMS Setting for Oracle Secure Backup CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'ENV=(OB_MEDIA_FAMILY=datafile_mf)';
If you do not receive an error message, then the database successfully loaded the media management library. If you receive the ORA-27211 error, the media management library could not be loaded: RMAN-00571: =========================================================== RMAN-00569: ========== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03009: failure of allocate command on c1 channel at 11/30/2007 13:57:18 ORA-19554: error allocating device, device type: SBT_TAPE, device name: ORA-27211: Failed to load Media Management Library Additional information: 25 In this case, you must check the media management installation to make sure that the library is correctly installed, and re-check the value for the SBT_LIBRARY parameter. If the database is unable to locate a media management library in the location specified by the SBT_LIBRARY parameter or the default location, then RMAN issues an ORA27211 error and exits. Whenever channel allocation fails, the database writes a trace file to the trace subdirectory in the Automatic Diagnostic Repository (ADR) home directory. The following shows sample output: SKGFQ OSD: Error in function sbtinit on line 2278 SKGFQ OSD: Look for SBT Trace messages in file /oracle/rdbms/log/sbtio.log SBT Initialize failed for /oracle/lib/libobk.so
www.wilshiresoft.com [email protected]
Page 95 of 212
This error indicates that the media management software is not correctly configured. Ensure that the steps in "Configuring RMAN to Make Backups to a Media Manager" are correctly done. Also, ensure that you have the correct PARMS and FORMAT strings required by your media management software.
Page 96 of 212
unique filename with the %U substitution variable. Your media manager may impose restrictions on file names and sizes. In this case, you may need more fine-grained control over the naming of backup pieces so that they obey media manager restrictions. For example, some media managers only support a 14-character backup piece name, and some require special FORMAT strings. Note that the unique names generated by the %U substitution variable do not exceed 14 characters. Note that some media managers may have limits on the maximum size of files that they can back up or restore. You must ensure that RMAN does not produce backup sets larger than those limits. To limit backup piece sizes, use the parameter MAXPIECESIZE, which you can set in the CONFIGURE CHANNEL and ALLOCATE CHANNEL commands.
Page 97 of 212
other automatic features of OMF will still function. When storing backups, using OMF on top of ASM without using a flash recovery area is supported but discouraged. It is awkward to directly manipulate files under ASM.
12.9.3 How Oracle Manages Disk Space in the Flash Recovery Area
Space in the flash recovery area is balanced among backups and archived logs that must be kept according to the retention policy, and other files which may be subject to deletion. Oracle Database does not delete eligible files from the flash recovery area until the space must be reclaimed for some other purpose. Thus, files recently moved to tape are often still available on disk for use in recovery. The recovery area can thus serve as a cache for tape. When the flash recovery area is full, Oracle Database automatically deletes eligible files to reclaim space in the recovery area as needed.
Considerations When Setting the Size of the Flash Recovery Area The larger the flash recovery area is, the more useful it becomes. The recovery area should be able to contain a copy of all datafiles in the database and the incremental backups used by your chosen backup strategy. If providing this much space is impractical, then it is best to create an area large enough to keep a backup of the most important tablespaces and all the archived logs not yet on tape. At an absolute minimum, the flash recovery area must be
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Page 98 of 212
large enough to contain the archived redo logs not yet on tape. If the recovery area has insufficient space to store flashback logs and meet other backup retention requirements, then the recovery area may delete flashback logs to make room. Formulas for estimating a useful flash recovery area size depend on whether: Your database has a small or large number of data blocks that change frequently You store backups only on disk, or on disk and tape You use a redundancy-based backup retention policy, or a recovery window-based retention policy You plan to use Flashback Database or a guaranteed restore point as alternatives to point-in-time recovery in response to logical errors If you plan to enable flashback logging, then note that the volume of flashback log generation is approximately the same order of magnitude as redo log generation. For example, if you intend to set DB_FLASHBACK_RETENTION_TARGET to 24 hours, and if the database generates 20 GB of redo in a day, then a rule of thumb is to allow 20 GB to 30 GB disk space for the flashback logs. The same rule applies to guaranteed restore points when flashback logging is enabled. For example, if the database generates 20 GB redo every day, and if the guaranteed restore point will be kept for a day, then plan to allocate 20 to 30 GB. Suppose that you want to determine the size of a flash recovery when the backup retention policy is set to REDUNDANCY 1 and you intend to follow the Oracle Suggested Strategy of using an incrementally updated backup. In this example, you use the following formula to estimate the disk quota, where n is the interval in days between incremental updates and y is the delay in applying the foreign archived redo logs on a logical standby database: Disk Quota = Size of a copy of database + Size of an incremental backup + Size of (n+1) days of archived redo logs + Size of (y+1) days of foreign archived redo logs (for logical standby) + Size of control file + Size of an online redo log member * number of log groups + Size of flashback logs (based on DB_FLASHBACK_RETENTION_TARGET value)
12.9.5 Considerations When Setting the Location of the Flash Recovery Area
Place the flash recovery area on a separate disk from the database area, where the database maintains active database files such as datafiles, control files, and online redo logs. Keeping the flash recovery area on the same disk as the database area exposes you to loss of both your live database files and backups if a media failure occurs. Oracle recommends that DB_RECOVERY_FILE_DEST be set to a different value from DB_CREATE_FILE_DEST or any of the DB_CREATE_ONLINE_LOG_ DEST_n initialization parameters. The database writes a warning to the alert log if DB_RECOVERY_FILE_DEST is the same as these parameters. Multiple databases can have the same value for DB_RECOVERY_FILE_DEST, but one of the following must be true: No two databases for which the DB_UNIQUE_NAME initialization parameters are specified have the same value for DB_UNIQUE_NAME. For those databases where no DB_UNIQUE_NAME is provided, no two databases have the same value for DB_NAME. When databases share a single recovery area in this way, the location should be large enough to hold the files for all databases. Add the values for DB_RECOVERY_FILE_DEST_SIZE for the databases, then allow for overhead such as mirroring or compression.
www.wilshiresoft.com [email protected]
Page 99 of 212
12.9.6 Setting the Flash Recovery Area Location and Initial Size
This section explains how to specify a location for the recovery area and set its initial size.To determine the optimum size for the flash recovery area: 1. If you plan to use flashback logging or guaranteed restore points, then query V$ARCHIVED_LOG to determine how much redo the database generates in the time to which you intend to set DB_FLASHBACK_RETENTION_TARGET. 2. Set the recovery area size. If you plan to use flashback logging or guaranteed restore points, then ensure that the size value obtained from step 1 is incorporated into the setting. Set the DB_RECOVERY_FILE_DEST_SIZE initialization parameter by any of the following means: Shut down the database and set the DB_RECOVERY_FILE_DEST_SIZE parameter in the initialization parameter file of the database, as shown in the following example: DB_RECOVERY_FILE_DEST_SIZE = 10G Specify them with the SQL statement ALTER SYSTEM SET when the database is open, as shown in the following examples: ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G SCOPE=BOTH SID='*'; Use the Database Configuration Assistant to set the size 3. Set the recovery area location. Set the initialization parameters by any of the following means: Set DB_RECOVERY_FILE_DEST in the initialization parameter file of the database, as shown in the following example: DB_RECOVERY_FILE_DEST = '/u01/oradata/rcv_area' Specify DB_RECOVERY_FILE_DEST with the SQL statement ALTER SYSTEM SET when the database is open, as shown in the following example: ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '+disk1' SCOPE=BOTH SID='*'; Use the Database Configuration Assistant to set the location. If you do not plan to use flashback logging, then open the database (if it is closed) and do not complete the rest of the steps in this procedure. 4. If flashback logging is enabled, then run the database under a normal workload for the time period specified by DB_FLASHBACK_RETENTION_TARGET. In this way, the database can generate a representative sample of flashback logs. 5. Query the V$FLASHBACK_DATABASE_LOG view as follows: SELECT ESTIMATED_FLASHBACK_SIZE FROM V$FLASHBACK_DATABASE_LOG;
The result is an estimate of the disk space needed to meet the current flashback retention target, based on the database workload since Flashback Database was enabled. 6. If necessary, adjust the flashback log space requirement based on the actual size of flashback logs generated during the time period specified by DB_FLASHBACK_RETENTION_TARGET.
Configuring Online Redo Log Locations The initialization parameters that determine where online redo log files are created are DB_CREATE_ONLINE_LOG_DEST_n, DB_RECOVERY_FILE_DEST, and DB_CREATE_FILE_DEST Details of the effect of combinations of these parameters on online redo log creation can be found in Oracle Database SQL Language Reference in the description of the LOGFILE clause of the CREATE DATABASE statement. The following SQL statements can create online redo logs in the flash recovery area: CREATE DATABASE ALTER DATABASE ADD LOGFILE ALTER DATABASE ADD STANDBY LOGFILE ALTER DATABASE OPEN RESETLOGS
The default size of an online log created in the flash recovery area is 100 MB. The log member filenames are automatically generated by the database. Configuring Control File Locations The initialization parameters CONTROL_FILES, DB_CREATE_ONLINE_LOG_DEST_n, DB_RECOVERY_FILE_DEST, and DB_CREATE_FILE_DEST all interact to determine the location where the database control files are created. If the database creates an Oracle managed control file, and if the database uses a server parameter file, then the database sets the CONTROL_FILES initialization parameter in the server parameter file. If the database uses a client-side initialization parameter file, then you must set the CONTROL_FILES initialization parameter manually in the initialization parameter file. Configuring Archived Redo Log Locations It is recommended that you the use flash recovery area as an archiving location because the archived logs are automatically managed by the database. The generated filenames for the archived logs in the flash recovery area are for Oracle-managed files and are not determined by LOG_ARCHIVE_FORMAT. Whatever archiving scheme you choose, it is always advisable to create multiple copies of archived redo logs. You have the following basic options for archiving redo logs, listed from most to least recommended: 1. Enable archiving to the flash recovery area only and use disk mirroring to create the redundancy needed to protect the archived redo logs. If DB_RECOVERY_FILE_DEST is specified and no LOG_ARCHIVE_DEST_n is specified, then LOG_ARCHIVE_DEST_10 is implicitly set to the recovery area. You can override this behavior by setting LOG_ARCHIVE_DEST_10 to an empty string. 2. Enable archiving to the flash recovery area and set other LOG_ARCHIVE_DEST_n initialization parameter to locations outside the flash recovery area. If a flash recovery area is configured, then you can add the flash recovery area as an archiving destination by setting any LOG_ARCHIVE_DEST_n parameter to LOCATION=USE_DB_RECOVERY_FILE_DEST. 3. Set LOG_ARCHIVE_DEST_n initialization parameters to archive only to non-flash recovery area locations. If you use the flash recovery area, then you cannot use the LOG_ARCHIVE_DEST and LOG_ARCHIVE_DUPLEX_DEST initialization parameters. If you do, then will not be able to start the instance. Instead, set the LOG_ARCHIVE_DEST_n parameters. After your database is using LOG_ARCHIVE_DEST_n, you can configure a recovery area. Note also that if you enable archiving but do not set any value for LOG_ARCHIVE_DEST, LOG_ARCHIVE_DEST_n, or DB_RECOVERY_FILE_DEST, then the redo logs are archived to a default location that is platform-specific. For example, on Solaris the default is ?/dbs. Configuring RMAN File Creation in the Flash Recovery Area This section describes RMAN commands or implicit actions (such as control file autobackups) that can create files in the flash recovery area, and how to control whether a command creates files there or in another destination. The commands are: BACKUP If you do not specify the FORMAT clause for disk backups, then RMAN creates backup pieces and image copies in the flash recovery area, with names in Oracle Managed Files name format. If a flash recovery area is enabled, and
www.wilshiresoft.com [email protected]
if you do specify FORMAT on BACKUP or a channel, then RMAN creates the backup in a platform-specific location rather than in the recovery area. Control File Autobackup RMAN can create control file autobackups in the flash recovery area. Use the RMAN command CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR %F; DEVICE TYPE DISK CLEAR to clear any configured format option for the control file autobackup location on disk. RMAN creates control file autobackups in the flash recovery area when no other destination is configured. RESTORE ARCHIVELOG Explicitly or implicitly set one of the LOG_ARCHIVE_DEST_n parameters to LOCATION= USE_DB_RECOVERY_FILE_DEST. If you do not specify SET ARCHIVELOG DESTINATION to override this behavior, then RMAN restores archived redo log files to the flash recovery area. RECOVER DATABASE or RECOVER TABLESPACE, RECOVER ... BLOCK, and FLASHBACK DATABASE These commands restore archived redo log files from backup for use during media recovery, as required by the command. RMAN restores any redo log files needed during these operations to the flash recovery area and deletes them after they are applied during media recovery. To direct the restored archived logs to the flash recovery area, set one of the LOG_ARCHIVE_DEST_n parameters to LOCATION = USE_DB_RECOVERY_FILE_DEST. Make sure you are not using SET ARCHIVELOG DESTINATION to direct restored logs to some other destination.
If RMAN determines that a file is identical and it has already been backed up, then it is a candidate to be skipped. RMAN must do further checking to determine whether to skip the file, however, because both the retention policy and the backup duplexing feature are factors in the algorithm that determines whether RMAN has sufficient backups on the specified device type. RMAN uses backup optimization when the following conditions are true: The CONFIGURE BACKUP OPTIMIZATION ON command has been run to enable backup optimization. You run BACKUP DATABASE, BACKUP ARCHIVELOG with ALL or LIKE options, or BACKUP BACKUPSET ALL, BACKUP RECOVERY AREA, BACKUP RECOVERY FILES, or BACKUP DATAFILECOPY. Only one type of channel is allocated, that is, you do not mix disk and SBT channels in the same backup command. Note: In backup undo optimization, RMAN excludes undo that is not needed for recovery of a backup, that is, for transactions have already been committed. You can enable and disable backup optimization, but backup undo optimization is built-in behavior. Assume that you have configured backup optimization. Example illustrates a session in which back up the database, all archived logs, and all backup sets to tape.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Configuring the RMAN Environment Example -Specifying the Device Type on the BACKUP Command BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG; BACKUP DEVICE TYPE sbt BACKUPSET ALL;
If none of the backed-up files in Example has changed since the last backup, then RMAN does not back up the files again. RMAN also does not signal an error if it skips all files specified in the command because the files have already been backed up. You can override optimization at any time by specifying the FORCE option on the BACKUP command. For example, you can run: BACKUP DATABASE FORCE; BACKUP ARCHIVELOG ALL FORCE; Effect of Retention Policies on Backup Optimization for SBT Backups Backup optimization is not always applied when backing up to SBT devices. The exceptions to normal backup optimization behavior for recovery window-based and redundancy-based retention policies are described in the following sections. Note: Use caution when enabling backup optimization if you use a media manager with its own internal expiration policy. Run the CROSSCHECK command periodically to synchronize the RMAN repository with the media manager. Otherwise, RMAN may skip backups due to optimization without recognizing that the media manager has discarded backups stored on tape. Backup Optimization for SBT Backups with Recovery Window Retention Policy Suppose that backup optimization is enabled, and a recovery window backup retention policy is in effect. In this case, when performing SBT backup s RMAN always backs up datafiles whose most recent backup is older than the recovery window. For example, assume the following scenario: Today is February 21. The recovery window is 7 days. The most recent backup of tablespace tools to tape is January 3. Tablespace tools is read-only.
On February 21, when you issue a command to back up tablespace tools to tape, RMAN backs it up even though it did not change after the January 3 backup (because it is read-only). RMAN makes the backup because no backup of the tablespace exists within the 7-day recovery window. This behavior enables the media manager to expire old tapes. Otherwise, the media manager would be forced to keep the January 3 backup of tablespace tools indefinitely. By making a more recent backup of tablespace tools on February 21, RMAN enables the media manager to expire the tape containing the January 3 backup. Backup Optimization for SBT Backups with Redundancy Retention Policy Assume that you configure a retention policy for redundancy. In this case, RMAN only skips backups of offline or read-only datafiles to SBT when there are r + 1 backups of the files, where r is set in CONFIGURE RETENTION POLICY TO REDUNDANCY .For example, assume that you enable backup optimization and set the following retention policy: CONFIGURE DEFAULT DEVICE TYPE TO sbt; CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE RETENTION POLICY TO REDUNDANCY 2; With these settings, RMAN only skips backups when three identical files are already backed up. Also assume that you have never backed up the users tablespace, which is read/write, and that you perform the actions. By default, backup optimization is configured to OFF. You can use the SHOW BACKUP OPTIMIZATION command to view the current settings of backup optimization.
www.wilshiresoft.com [email protected]
To configure backup optimization: 1. Start RMAN and connect to a target database and a recovery catalog (if used). 2. Run the SHOW BACKUP OPTIMIZATION command to determine whether optimization is currently enabled. For example, enter the following command: SHOW BACKUP OPTIMIZATION; Sample output for SHOW BACKUP OPTIMIZATION follows: RMAN configuration parameters for database with db_unique_name PROD1 are: CONFIGURE BACKUP OPTIMIZATION ON; 3. Enable backup optimization by running the following command: CONFIGURE BACKUP OPTIMIZATION ON;
www.wilshiresoft.com [email protected]
The archived log deletion policy also has options specific to a Data Guard environment. For example, if you specify the APPLIED ON STANDBY clause, then RMAN can delete logs after they have been applied at all mandatory remote destinations. If you specify SHIPPED TO STANDBY, for example, then RMAN can delete logs when they have been transferred to all mandatory standby destinations. Enabling an Archived Redo Log Deletion Policy This section explains how to configure an archived redo log deletion policy. By default the policy is set to NONE. To enable an archived redo log deletion policy: 1. Start RMAN and connect to a target database and a recovery catalog (if used). 2. Run the CONFIGURE ARCHIVELOG DELETION POLICY command with the desired options. The following example specifies that archived redo logs are eligible to be deleted from the flash recovery area and all local archiving destinations when logs have been backed up at least once to tape: CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO SBT;
www.wilshiresoft.com [email protected]
About the Flashback Database Window the range of SCNs for which there is currently enough flashback log data to support the FLASHBACK DATABASE command is called the flashback database window. The flashback database window cannot extend further back than the earliest SCN in the available flashback logs. Note: Some database operations, such as dropping a tablespace or shrinking a datafile, cannot be reversed with Flashback Database. In these cases the flashback database window begins at the time immediately following that operation. You cannot back up flashback logs to locations outside the flash recovery area. To increase the likelihood that enough flashback logs are retained to meet the flashback database window, you can increase the space in your flash recovery area. If the flash recovery area is not large enough to hold the flashback logs and files such as archived redo logs and other backups needed for the retention policy, then the database may delete flashback logs from the earliest SCNs to make room for other files. Consequently, the flashback database window can be shorter than the flashback retention target, depending on the size of the flash recovery area, other backups that must be retained, and how much flashback logging data is needed. The flashback retention target is a target, not a guarantee that Flashback Database will be available. If you cannot use FLASHBACK DATABASE because the flashback database window is not long enough, then you can use database point-in-time recovery (DBPITR) in most cases to achieve a similar result. Guaranteed restore points are the only way to ensure that you can use Flashback Database to return to a specific point in time or guarantee the size of the flashback window.
www.wilshiresoft.com [email protected]
Note: Limitations that apply to Flashback Data base also apply to guarantee restore points. For example, shrinking a datafile or dropping a tablespace can prevent flashing back the affected datafiles to the guaranteed restore point. See the FLASHBACK DATABASE entry in Oracle Database Backup and Recovery Reference for a complete list of command prerequisites and usage notes. Guaranteed Restore Points and Storage Snapshots In practice, guaranteed restore points provide a useful alternative to storage snapshots. Storage snapshots are often used to protect a database before risky operations such as large-scale database updates or application patches or upgrades. Rather than creating a snapshot or duplicate database to test the operation, you can create a guaranteed restore point on a primary or physical standby database. You can then perform the risky operation with the certainty that the required flashback logs are retained.
www.wilshiresoft.com [email protected]
Disk space usage is considerably less than normal flashback logging. Less space is needed because each changed block is only logged once. Thus, you can maintain a guaranteed restore point for days or even weeks without concern over the growth of flashback logs. Typically, the performance overhead of logging for a guaranteed restore point without flashback database logging is lower as well.
Assume that your primary goal is the ability to return your database to the time at which the guaranteed restore point was created. In this case, it is usually more efficient to turn off flashback logging and use only guaranteed restore points. For example, suppose that you are performing an application upgrade on a database host over a weekend. You could create a guaranteed restore point at the start of the upgrade. If the upgrade fails, then reverse the changes with FLASHBACK DATABASE.
Logging for Flashback Database with Guaranteed Restore Points Defined If you enable Flashback Database and define one or more guaranteed restore points, then the database performs normal flashback logging. In this case, the recovery area retains the flashback logs required to flash back to any arbitrary time between the present and the earliest currently defined guaranteed restore point. Flashback logs are not deleted in response to space pressure if they are required to satisfy the guarantee. Flashback logging causes some performance overhead. Depending upon the pattern of activity on your database, it can also cause significant space pressure in the flash recovery area. Thus, you should monitor space used in the flash recovery area.
www.wilshiresoft.com [email protected]
the
Environment
for Optimal
Flashback
Database
Maintaining flashback logs imposes comparatively limited overhead on an Oracle database instance. Changed blocks are written from memory to the flashback logs at relatively infrequent, regular intervals, to limit processing and I/O overhead. To achieve good performance for large production databases with Flashback Database enabled, Oracle recommends the following: Use a fast file system for your flash recovery area, preferably without operating system file caching. Files that the database creates in the flash recovery area, including flashback logs, are typically large. Operating system file
www.wilshiresoft.com [email protected]
caching is typically not effective for these files, and may actually add CPU overhead for reading from and writing to these files. Thus, it is recommended to use a file system that avoids operating system file caching, such as ASM. Configure enough disk spindles for the file system that will hold the flash recovery area. For large production databases, multiple disk spindles may be needed to support the required disk throughput for the database to write the flashback logs effectively. If the storage system used to hold the flash recovery area does not have nonvolatile RAM, then try to configure the file system on striped storage volumes. Use a relatively small stripe size such as 128 KB. This technique enables each write to the flashback logs to be spread across multiple spindles, improving performance. For large databases, set the initialization parameter LOG_BUFFER to at least 8 MB. This setting ensures that the database allocates maximum memory (typically 16MB) for writing flashback database logs. The overhead of logging for Flashback Database depends on the mixture of reads and writes in the database workload. The more writeintensive the workload, the higher the overhead caused by turning on logging for Flashback Database. Queries do not change data and thus do not contribute to logging activity for Flashback Database.
www.wilshiresoft.com [email protected]
Although the database depends on other types of files, such as network configuration files, password files, and the contents of the Oracle home, you cannot back up these files with RMAN. Likewise, some features of Oracle, such as external tables, may depend upon files other than the datafiles, control files, and redo log. RMAN cannot back up these files. Use some non-RMAN backup solution for any files not in the preceding list. When you execute the BACKUP command in RMAN, the output is always either one or more backup sets or one or more image copies. A backup set is an RMAN-specific proprietary format, whereas an image copy is a bit-for-bit copy of a file. By default, RMAN creates backup sets.
When performing a user-managed online backup, you must place your datafiles into backup mode with the ALTER DATABASE or ALTER TABLESPACE statement with the BEGIN BACKUP clause. When a tablespace is in backup mode, the database writes the before image for an entire block to the redo stream before modifying a block. The database also records changes to the block in the online redo log. Backup mode also freezes the datafile checkpoint until the file is removed from backup mode. Oracle Database performs this safeguard because it cannot guarantee that a third-party backup tool will copy the file header before copying the data blocks. Unlike user-managed tools, RMAN does not require extra logging or backup mode because it knows the format of data blocks. RMAN is guaranteed not to back up fractured blocks. During an RMAN backup, a database server session reads each data block and checks whether it is fractured by comparing the block header and footer. If a block is fractured, then the session rereads the block. If the same fracture is found, then the block is considered permanently corrupt. Also, RMAN does not need to freeze the datafile header checkpoint because it knows the order in which the blocks will be read, which enables it to capture a known good checkpoint for the file.
Note: Wallet-based encryption is more secure than password-based encryption because no passwords are involved. You should use password-based encryption only when absolutely necessary because your backups need to be transportable. To create encrypted backups on disk with RMAN, the database must use the Advanced Security Option. The Oracle Secure Backup SBT is the only supported interface for making encrypted RMAN backups directly to tape. Note that the Advanced Security Option is not required when making encrypted backups to the Oracle Secure Backup SBT.
As Figure illustrates, RMAN can back up three datafiles into a backup set that contains only one backup piece. This backup piece contains the intermingled data blocks of the three input datafiles. Figure - Datafile Multiplexing
RMAN multiplexing is determined by several factors. For example, the FILESPERSET parameter of the BACKUP command determines how many datafiles to put in each backup set. The MAXOPENFILES parameter of ALLOCATE CHANNEL or CONFIGURE CHANNEL defines how many datafiles RMAN can read from simultaneously. The basic multiplexing algorithm is as follows: Number of files in each backup set This number is the minimum of the FILESPERSET setting and the number of files read by each channel. The FILESPERSET default is 64. The level of multiplexing This is the number of input files simultaneously read and then written into the same backup piece. The level of multiplexing is the minimum of MAXOPENFILES and the number of files in each backup set. The MAXOPENFILES default is 8.Suppose that you back up 12 datafiles with one channel. The number of files in each backup set is 4. The level of multiplexing is the lesser of this number and 8. Thus, the channel simultaneously writes blocks from 4 datafiles into each backup piece. Now suppose that you back up 50 datafiles with one channel. The number of files in each backup set is 50. The level of multiplexing is the lesser of this number and 8. Thus, the channel simultaneously writes blocks from 8 datafiles into each backup piece. RMAN multiplexing of backup sets is different from media manager multiplexing. One type of media manager multiplexing occurs when the media manager writes the concurrent output from multiple RMAN channels to a single sequential device. Another type occurs when a backup mixes database files and non-database files on the same tape. Caution: Oracle recommends that you never use media management multiplexing for RMAN backups.
The PROXY option of the BACKUP command specifies that a backup should be a proxy copy. For each file that you attempt to back up with the BACKUP PROXY command, RMAN queries the media manager to determine whether it can perform a proxy copy. If the media manager cannot proxy copy the file, then RMAN backs the file up as if the PROXY option had not been used. (Use the PROXY ONLY option to force RMAN to fail if a proxy copy cannot be performed.) Note that control files are never backed up with proxy copy. If the PROXY option is specified on an operation backing up a control file, then it is silently ignored for the purposes of backing up the control file.
www.wilshiresoft.com [email protected]
RMAN Bakup Concepts Read all blocks in the datafile copy to insure there are no corruptions Guarantee that the image copy was correctly made in backup mode
After you catalog these files, you can use them with the RESTORE or SWITCH commands just as you can for RMAN-generated image copies. Some sites store their datafiles on mirrored disk volumes, which permit the creation of image copies by breaking a mirror. After you have broken the mirror, you can notify RMAN of the existence of a new user-managed copy, thus making it eligible for a backup. You must notify RMAN when the copy is no longer available by using the CHANGE ... UNCATALOG command.
You can also use BACKUP BACKUPSET to manage backup space allocation. Example backs up backup sets that were created more than a week ago from disk to tape, and then deletes them from disk. Example Managing Space Allocation: BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-7' DELETE INPUT; Note that DELETE INPUT here is equivalent to DELETE ALL INPUT: RMAN deletes all existing copies of the backup set. If you duplexed a backup to four locations, then RMAN deletes all four copies of the pieces in the backup set.
www.wilshiresoft.com [email protected]
www.wilshiresoft.com [email protected]
www.wilshiresoft.com [email protected]
Every datafile has a datafile checkpoint SCN, which you can view in V$DATAFILE.CHECKPOINT_CHANGE#. All changes with an SCN lower than this SCN are guaranteed to be in the file. When a level 0 incremental backup is restored, the restored datafile contains the checkpoint SCN that it had when the level 0 was created. When a level 1 incremental is applied to a file, the checkpoint SCN of the file is advanced to the checkpoint SCN that the file had when the incremental level 1 was created. Incremental start SCN This SCN applies only to level 1 incremental backups. All blocks whose SCN is greater than or equal to the incremental start SCN are included in the backup. Blocks whose SCN is lower than the incremental start SCN are not included in the backup. The incremental start SCN is most often the checkpoint SCN of the parent of the level 1 backup. Block SCN Every data block in a datafile records the SCN at which the most recent change was made to the block. When RMAN makes an incremental backup of a file, RMAN reads the file, examines the SCN of every block, and backs up blocks whose SCN is greater than or equal to the incremental start SCN for this backup. If the backup is differential, then the incremental start SCN is the checkpoint SCN of the most recent level 1 backup. If the backup is cumulative, then the incremental start SCN is the checkpoint SCN of the most recent level 0 backup. When block change tracking is enabled, RMAN uses bitmaps to avoid reading blocks that have not changed during the range from incremental start SCN to checkpoint SCN. Note that RMAN still examines every block that is read and uses the SCN in the block to decide which blocks to include in the backup. One consequence of the incremental backup algorithm is that RMAN applies all blocks containing changed data during recovery, even if the change is to an object created with the NOLOGGING option. Thus, if you restore a backup made before NOLOGGING changes were made, then incremental backups are the only way to recover them.
www.wilshiresoft.com [email protected]
performs a crosscheck and cannot find the file. In short, obsolete means a file is not needed, whereas expired means it is not found. A backup retention policy applies only to full or level 0 datafile and control file backups. For datafile copies and proxy copies, if RMAN determines that the copy or proxy copy is not needed, then the copy or proxy copy can be deleted. For datafile backup sets, RMAN cannot delete the backup set until all datafile backups within the backup set are obsolete. The retention policy does not directly affect archived redo logs and incremental level 1 backups. Rather, these files become obsolete when no full backups exist that need them. Besides affecting full or level 0 datafile and control file backups, the retention policy affects archived redo logs and level 1 incremental backups. First, RMAN decides which datafile and control file backups are obsolete. Then, RMAN considers as obsolete all archived logs and incremental level 1 backups that are not needed to recover the oldest datafile or control file backup that must be retained. Note: RMAN cannot implement an automatic retention policy if backups are deleted by non-RMAN techniques, for example, through the media manager's tape retention policy. The media manager should never expire a tape until all RMAN backups on that tape have been removed from the media manager's catalog.
The database runs in ARCHIVELOG mode, and archived logs are saved on disk only as long as needed for the retention policy. In this scenario, the current time is January 30 and the point of recoverability is January 23. Note how the January 14 backup is not obsolete even though a more recent backup (January 28) exists in the recovery window. This situation occurs because restoring the January 28 backup does not enable you to recover to the earliest time in the window, January 23. To ensure recoverability to any point in the window, you must save the January 14 backup and all archived logs from sequence 500 to 1150.
www.wilshiresoft.com [email protected]
policy specifies how many backups of each datafile must be retained. For example, you can configure a redundancy of 2 as follows: CONFIGURE RETENTION POLICY TO REDUNDANCY 2; The default retention policy is configured to REDUNDANCY 1.
13.13 Backup Retention Policy and Flash Recovery Area Deletion Rules
The RMAN status OBSOLETE is always determined in reference to a retention policy. For example, if a database backup is considered OBSOLETE in the RMAN repository, it is because it is either not needed for recovery to a point within the recovery window, or it is redundant. If you configure a flash recovery area, then the database uses an internal algorithm to select files in the flash recovery area that are no longer needed to meet the configured retention policy. These backups have status OBSOLETE and are eligible for deletion to satisfy the disk quota rules. The retention policy is never violated when determining which files to delete from the flash recovery area to satisfy the disk quota rules.There is one important difference between the flash recovery area rules for OBSOLETE status and the disk quota rules for deletion eligibility. Assume that archived logs 1000 through 2000, which are on disk, are needed for the current recovery window and so are not obsolete. If you back up these logs to tape, then the retention policy considers the disk logs as required, that is, not obsolete. Nevertheless, the flash recovery area disk quota algorithm considers the logs on disk as eligible for deletion because they have been backed up to tape. The logs on disk do not have OBSOLETE status in the repository, but they are eligible for deletion by the flash recovery area.
www.wilshiresoft.com [email protected]
www.wilshiresoft.com [email protected]
RMAN automatically backs up the control file and the server parameter file (if the instance was started with a server parameter file) when datafile 1 is included in the backup. If control file autobackup is enabled, then RMAN writes the current control file and server parameter file to a separate autobackup piece. Otherwise, RMAN includes these files in the backup set that contains datafile 1. To back up tablespaces or datafiles: 1. Start RMAN and connect to a target database and a recovery catalog (if used). 2. If the database instance is not started, then either mount or open the database. 3. Run the BACKUP TABLESPACE command or BACKUP DATAFILE command at the RMAN prompt. The following example backs up the users and tools tablespaces to tape: BACKUP DEVICE TYPE sbt TABLESPACE users, tools; The following example uses an SBT channel to back up datafiles 1 through 4 and a datafile copy stored at /tmp/system01.dbf to tape: BACKUP DEVICE TYPE sbt DATAFILE 1,2,3,4 DATAFILECOPY '/tmp/system01.dbf';
Backingup the Database BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/tmp/control01.ctl'; The following example backs up the control file copy created in the previous example to tape: BACKUP AS COPY CURRENT CONTROLFILE FORMAT '/tmp/control01.ctl'; BACKUP DEVICE TYPE sbt CONTROLFILECOPY '/tmp/control01.ctl';
If the control file autobackup feature is enabled, then RMAN makes two control file backups in these examples: the explicit backup of the files specified in the BACKUP command and the control file and server parameter file autobackup.
log sequence number are identical, RMAN does not need to include more than one log copy. The archived redo log failover feature enables RMAN to complete a backup even when some archiving destinations are missing logs or contain logs with corrupt blocks. If at least one log corresponding to a given log sequence and thread is available in the flash recovery area or any of the archiving destinations, then RMAN tries to back it up. If RMAN finds a corrupt block in a log file during backup, it searches other destinations for a copy of that log without corrupt blocks. For example, assume that you archive logs 121 through 124 to two destinations: /arch1 and /arch2. Table shows the archived redo log record s in the control file. Table - Sample Archived Redo Log Records Sequence ---------121 122 123 124 Filename in /arch1 Filename in /arch2 --------------------------------------------------/arch1/archive1_121.arc /arch2/archive1_121.arc /arch1/archive1_122.arc /arch2/archive1_122.arc /arch1/archive1_123.arc /arch2/archive1_123.arc /arch1/archive1_124.arc /arch2/archive1_124.arc
However, unknown to RMAN, a user deletes logs 122 and 124 from the /arch1 directory. Afterward, you run the following backup: BACKUP ARCHIVELOG FROM SEQUENCE 121 UNTIL SEQUENCE 125; With failover, RMAN completes the backup, using logs 122 and 124 in /arch2. Online Redo Log Switching Another important RMAN feature is automatic online redo log switching. To make an open database backup of archived redo logs that includes the most recent online redo log, you can execute the BACKUP command with any of the following clauses: PLUS ARCHIVELOG ARCHIVELOG ALL ARCHIVELOG FROM...
Before beginning the backup, RMAN switches out of the current redo log group, and archives all online redo logs that have not yet been archived, up to and including the redo log group that was current when the command was issued. This feature ensures that the backup contains all redo generated before the start of the command. One of the most effective ways of backing up archived redo logs is the BACKUP ... PLUS ARCHIVELOG clause, which causes RMAN to do the following: 1. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT statement. 2. Runs BACKUP ARCHIVELOG ALL. If backup optimization is enabled, then RMAN skips logs that it has already backed up to the specified device. 3. Backs up the rest of the files specified in BACKUP command. 4. Runs the ALTER SYSTEM ARCHIVE LOG CURRENT statement. 5. Backs up any remaining archived logs generated during the backup. If backup optimization is not enabled, then RMAN backs up the logs generated in step 1 plus all the logs generated during the backup. The preceding steps guarantee that datafile backups taken during the command are recoverable to a consistent state. Also, unless the online redo log is archived at the end of the backup, DUPLICATE is not possible with the backup. Backing Up Archived Redo Log Files To back up archived logs, use the BACKUP ARCHIVELOG command. Note that if backup optimization is enabled, then RMAN skips backups of archived logs that have already been backed up to the specified device. To back up archived redo log files: 1. Start RMAN and connect to a target database and a recovery catalog (if used). 2. Make sure the target database is mounted or open. 3. Execute the BACKUP ARCHIVELOG or BACKUP ... PLUS ARCHIVELOG command. The following example backs up the database and all archived redo logs:
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
The following example uses a configured disk or SBT channel to back up one copy of each log sequence number for all archived redo logs: BACKUP ARCHIVELOG ALL; You can also specify a range of archived redo logs by time, SCN, or log sequence number, as in the following example: BACKUP ARCHIVELOG FROM TIME SYSDATE-30' UNTIL TIME 'SYSDATE-7';
www.wilshiresoft.com [email protected]
If you had specified DELETE INPUT rather than DELETE ALL INPUT, then RMAN would only delete the specific archived redo log files that it backed up. For example, RMAN would delete the logs in /arc_dest1 if these files were used as the source of the backup, but leave the contents of the /arc_dest2 intact.
ORDER BY COMPLETION_TIME;
www.wilshiresoft.com [email protected]
Compare the number of blocks in level 1 backups to a level 0 backup. For example, if you only create level 1 cumulative backups, then take a new level 0 backup when the most recent level 1 backup is about half of the size of the level 0 backup. An effective way to conserve disk space is to make incremental backups to disk, and then offload the backups to tape with BACKUP AS BACKUPSET. Incremental backups are generally smaller than full backups, which limits the space required to store them until they are moved to tape. When the incremental backups on disk are backed up to tape, the tape is more likely to stream because all blocks of the incremental backup are copied to tape. There is no possibility of delay due to time required for RMAN to locate changed blocks in the datafiles. Another strategy is to use incrementally updated backups. In this strategy, you create an image copy of each datafile, and then periodically roll forward this copy by making and then applying a level 1 incremental backup. In this way you avoid the overhead of making repeated full image copies of your datafiles, but enjoy all of the advantages. In a Data Guard environment, you can offload incremental backups to a physical standby database. Incremental backups of a standby and primary database are interchangeable. Thus, you can apply an incremental backup of a standby database to a primary database, or apply an incremental backup of a primary database to a standby database. You can also enable block change tracking at a standby database, regardless of whether it is enabled at any other database in the Data Guard environment. In this way, RMAN automatically optimizes incremental backups of the standby database.
To create incremental backups for use in an incrementally updated backups strategy, use the BACKUP ... FOR RECOVER OF COPY WITH TAG form of the BACKUP command. The command is best understood in the context of a sample script that implements the strategy. This script in Example, run on a regular basis, is all that is required to implement a strategy based on incrementally updated backups. Example - Basic Incremental Update Script RUN { RECOVER COPY OF DATABASE WITH TAG 'incr_update'; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE; } To understand the script and the strategy, it is necessary to understand the effects of these two commands when no datafile copies or incremental backup s exist. Note two important features: The BACKUP command in Example does not always create a level 1 incremental backup. The RECOVER command in Example causes RMAN to apply any available incremental level 1 backups to a set of datafile copies with the specified tag. The effect of the script is shown in the following table. The columns show the effects of the first run of the script, the second run of the script, and then the third and all subsequent run of the script. Each time a datafile is added to the database, an image copy of the new datafile is created the next time the script runs. The next run makes the first level 1 incremental for the added datafile. On all subsequent runs the new datafile is processed like any other datafile. You must use tags to identify the incremental level 0 datafile copies created for use in this strategy so that they do not interfere with other backup strategies you implement. If you use multiple incremental backup strategies, then RMAN cannot unambiguously create incremental level 1 backups unless you tag level 0 backups. The incremental level 1 backups to apply to those image copies are selected based upon the checkpoint SCNs of the image copy datafiles and the available incremental level 1 backups. The tag used on the image copy being recovered is not a factor in the selection of the incremental level backups. In practice, you would schedule the script in Example to run after each day, possibly at midnight. After the third run of the script, the following files would be available for a point-in-time recovery: An image copy of the database, as of the checkpoint SCN of the receding run of the script, 24 hours earlier An incremental backup for the changes after the checkpoint SCN of receding run Archived redo logs including all changes between the checkpoint SCN of the image copy and the current time if at some point during the following 24 hours you need to restore and recover your database, then you can restore the datafiles from the incrementally updated datafile copies. You can then apply changes from the most recent incremental level 1 and the redo logs to reach the d esired SCN. At most, you have 24 hours of redo to apply, which limits how long point-in-time recovery will take. Incrementally Updated Backups: Advanced Example You can extend the basic script in Example to provide fast recoverability to a window greater than 24 hours. Example shows how to maintain a window of seven days by specifying the beginning time of your window of recoverability in the RECOVER command. Example - Advanced Incremental Update Script RUN {
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Backingup the Database RECOVER COPY OF DATABASE WITH TAG 'incr_update' UNTIL TIME 'SYSDATE - 7'; BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE; }
The effect of the script is shown in the following table. The columns show the effects of the first run of the script, the second through seventh run of the scripts, and then each subsequent run of the script.
the space required for block change tracking is approximately 1/30,000 the size of the data blocks to be tracked. The following factors that may cause the file to be larger than this estimate suggests: To avoid the overhead of allocating space as your database grows, the block change tracking file size starts at 10 MB. New space is allocated in 10 MB increments. Thus, for any database up to approximately 300 GB, the file size is no smaller than 10 MB, for up to ap proximately 600 GB the file size is no smaller than 20 MB, and so on. For each datafile, a minimum of 320 KB of space is allocated in the block change tracking file, regardless of the size of the datafile. Thus, if you have a large number of relatively small datafiles, the change tracking file is larger than for databases with a smaller number of larger datafiles containing the same data.
www.wilshiresoft.com [email protected]
STATUS
FILENAME
www.wilshiresoft.com [email protected]
Moving backups from disk to tape and then freeing space on disk. This task is especially important when the database uses a flash recovery area so that the space can be reused as needed.
Note: You cannot duplex backups when running BACKUP BACKUPSET. RMAN always makes one and only one copy on the specified media when performing BACKUP BACKUPSET. You can also the BACKUP COPY OF command to back up image copies of datafiles, control files, and archived redo logs. The output of this command can be either backup sets or image copies, so you can generate backup sets from image copies. This form of backup is used to back up a database backup created as image copies on disk to tape.
TAG20070804T160 134 3. Use the backup set key from the previous step to back up the backup set. For example, enter the following command: BACKUP BACKUPSET 18; 4. Run the same LIST command that you ran in step 2. For example, run the following command (sample output included). LIST BACKUP OF DATAFILE 5 SUMMARY; List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
TAG20070804T160 134 Only one backup set is shown in this output, but there are now two copies of it. 5. Generate a report to see the effect of these copies under a redundancy-based backup retention policy.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Backingup the Database For example, issue the following command: REPORT OBSOLETE REDUNDANCY 1;
None of the copies is reported as obsolete because both copies of the backup set have the same values for set_stamp and set_count. 6. Generate a report to see the effect of these copies under a recovery window-based backup retention policy. For example, issue the following command: REPORT OBSOLETE RECOVERY WINDOW 1 DAY; None of the copies of the backup set is reported as obsolete or based on the CHECKPOINT_CHANGE# of this backup set, with respect to the current time and the availability of other backups.
List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Comp Tag --- -- -- - ----------- --------------- ------- ------- ---- --1 2 3 B B B F F F A DISK A DISK A DISK 28-MAY-07 29-MAY-07 30-MAY-07 1 1 1 1 1 1 NO NO NO TAG20070528T132432 TAG20070529T132433 TAG20070530T132434
The following example lists details about backup set 3 in verbose form: RMAN> LIST BACKUPSET 3; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ --------------3 Full 8.33M DISK 00:00:01 30-MAY-07 Tag: TAG20070530T132434
BP Key: 3
Status: AVAILABLE
Compressed: NO
Piece Name: /disk1/oracle/dbs/c-35764265-20070530-02 Control File Included: Ckp SCN: 397221 Ckp time: 30-MAY-07
SPFILE Included: Modification time: 30-MAY-07 SPFILE db_unique_name: PROD DELETE INPUT; The following example backs up only the backup sets with the primary key 1 and 2 to tape and then deletes the input disk backups: BACKUP BACKUPSET 1,2 DELETE INPUT; 3. Optionally, execute the LIST command to see a listing of backup sets and pieces. The output lists all copies, including backup piece copies created by BACKUP BACKUPSET.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
www.wilshiresoft.com [email protected]
www.wilshiresoft.com [email protected]
The primary purpose of the LIST command is to list backup and copies. Besides backups and copies, the RMAN can list other types of data.
TAG20071104T195949 3. To view verbose output for backups and copies, execute the LIST command without the SUMMARY option. The following commands list RMAN backups and copies with the default verbose output: LIST BACKUP; LIST COPY; Sample output for LIST BACKUP and LIST COPY follows: List of Backup Sets ===================
BS Key
Size
------- ---------- ----------- ------------ --------------www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Reporting on RMAN Operations 7 136M BP Key: 7 Piece Name: DISK 00:00:20 04-NOV-06
Status: AVAILABLE
Compressed: NO
Tag: TAG20071104T200759
/d2/RDBMS/backupset/2007_11_04/o1_mf_annnn_TAG20071104T200759_ztjxx3k8_.bkp
List of Archived Logs in backup set 7 Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- --------1 1 1 1 2 3 173832 174750 174755 21-OCT-06 174750 21-OCT-06 174755 21-OCT-06 174758 21-OCT-06 21-OCT-06 21-OCT-06
BS Key
Type LV Size
------- ---- -- ---------- ----------- ------------ --------------8 Full 2M DISK Status: AVAILABLE 00:00:01 04-NOV-06 Tag: TAG20071104T200829
BP Key: 8
Compressed: NO
Piece Name: /disk1/oracle/dbs/c-774627068-20071104-01 Controlfile Included: Ckp SCN: 631510 Ckp time: 04-NOV-06
Key
Ckp Time
A 11-OCT-06
360244
11-OCT-06
Key
Ckp Time
List of Archived Log Copies for database with db_unique_name RDBMS =====================================================================
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Key
Thrd Seq
S Low Time
Name: /work/arc_dest/arcr_1_1_603561743.arc
A 11-OCT-06
Name: /work/arc_dest/arcr_1_2_603561743.arc
A 11-OCT-06
Name: /work/arc_dest/arcr_1_3_603561743.arc
4. To list backups by file, execute LIST with the BY FILE option, specifying the desired objects to list and options. For example, you can enter: LIST BACKUP BY FILE;
File Key
TY LV S Ckp SCN
Ckp Time
---- ------- 1 5 B
TAG20071021T094513
Thrd Seq
Low SCN
Low Time
BS Key
---- ------- ---------- --------- ------- - ------- ------- ---------- --1 1 173832 21-OCT-06 7 A 1 1 NO
TAG20071104T200759 1 TAG20071021T094505
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
A 1
NO
TAG20071104T200759
List of Controlfile Backups =========================== CF Ckp SCN Ckp Time BS Key S #Pieces #Copies Compressed Tag
---------- --------- ------- - ------- ------- ---------- --631510 631205 04-NOV-06 8 04-NOV-06 6 A 1 A 1 1 1 NO NO TAG20071104T200829 TAG20071104T200432
List of SPFILE Backups ====================== Modification Time BS Key S #Pieces #Copies Compressed Tag
LIST COPY OF DATAFILE 2 COMPLETED BETWEEN '10-DEC-2002' AND '17-DEC-2002'; # specify logs backed up at least twice to tape LIST ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE sbt; 3. Examine the output. The output depends upon the options you pass to the LIST command. For example, the following lists copies of datafile 1: RMAN> LIST BACKUP OF DATAFILE 1;
------- ---- -- ---------- ----------- ------------ --------------2 Full 230M SBT_TAPE 00:00:49 21-OCT-06 Tag: TAG20071021T094513
BP Key: 2
Status: AVAILABLE
Compressed: NO
Handle: 02f4eatc_1_1
Media: /smrdir
List of Datafiles in backup set 2 File LV Type Ckp SCN Ckp Time Name
BS Key
Type LV Size
------- ---- -- ---------- ----------- ------------ --------------5 Full 233M DISK 00:04:30 04-NOV-06 Tag: TAG20071104T195949
Status: AVAILABLE
Compressed: NO
/disk1/2007_11_04/o1_mf_nnndf_TAG20071104T195949_ztjxfvgz_.bkp List of Datafiles in backup set 5 File LV Type Ckp SCN Ckp Time Name
Reporting on RMAN Operations RMAN> LIST INCARNATION OF DATABASE; List of Database Incarnations DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- -----1 2 1 2 RDBMS RDBMS 774627068 774627068 PARENT
CURRENT 173832
The preceding output indicates that a RESETLOGS was performed on database trgt a t SCN 164378, resulting in a new incarnation. The incarnation is distinguished by incarnation key (represented in the Inc Key column).
You can also see a list of the currently defined restore points by querying the V$RESTORE_POINT view as follows: SELECT NAME, SCN, TIME, DATABASE_INCARNATION#, GUARANTEE_FLASHBACK_DATABASE,STORAGE_SIZE FROM V$RESTORE_POINT;
You can view the name of each restore point, the SCN, wall-clock time and database incarnation number at which the restore points were created, whether each restore point is a guaranteed restore point, and how much space in the recovery area is being used for data needed for Flashback Database operations to that restore point. You can also use the following query to view only the guaranteed restore points: SELECT NAME, SCN, TIME, DATABASE_INCARNATION#, GUARANTEE_FLASHBACK_DATABASE, STORAGE_SIZE FROM V$RESTORE_POINT
WHERE GUARANTEE_FLASHBACK_DATABASE='YES'; For normal restore points, STORAGE_SIZE is zero. For guaranteed restore points, STORAGE_SIZE indicates the amount of disk space in the flash recovery area used to retain logs required to guarantee FLASHBACK DATABASE to that restore point.
Reporting on RMAN Operations REPORT NEED BACKUP Reports which database files need to be backed up to meet a configured or specified retention policy
REPORT UNRECOVERABLE Reports which database files require backup because they have been affected by some NOLOGGING operation such as a direct-path INSERT The RMAN repository contains other information that you can access with the REPORT command. Table 103 summarizes the REPORT options. Table - REPORT Options
Note: If you disable the retention policy using CONFIGURE RETENTION POLICY TO NONE, then REPORT NEED BACKUP returns an error message, because without a retention policy, RMAN cannot determine which files need to be backed up.
www.wilshiresoft.com [email protected]
15.3.9. Using RMAN REPORT NEED BACKUP with Tablespaces and Datafiles
REPORT NEED BACKUP can check the entire database, skip specified tablespaces, or check only specific tablespaces or datafiles against different retention policies, as shown in the following examples: REPORT NEED BACKUP RECOVERY WINDOW OF 2 DAYS DATABASE SKIP TABLESPACE TBS_2; REPORT NEED BACKUP REDUNDANCY 2 DATAFILE 1; REPORT NEED BACKUP TABLESPACE TBS_3; # uses configured retention policy REPORT NEED BACKUP INCREMENTAL 2; # checks entire database
15.3.10. Using REPORT NEED BACKUP with Backups on Tape or Disk Only
You can limit the backups tested by REPORT NEED BACKUP to disk-based or tape-based backups only, as shown in these examples: REPORT NEED BACKUP RECOVERY WINDOW OF 2 DAYS DATABASE DEVICE TYPE sbt; REPORT NEED BACKUP DEVICE TYPE DISK; REPORT NEED BACKUP TABLESPACE TBS_3 DEVICE TYPE sbt;
www.wilshiresoft.com [email protected]
Reporting on RMAN Operations Datafile Copy Datafile Copy Datafile Copy Backup Set Backup Piece . . . 44 45 46 26 26 08-FEB-06 08-FEB-06 08-FEB-06 08-FEB-06 08-FEB-06
/backup/ora_df549738682_s76_s1
You can also check which backups are obsolete under different recovery window-based or redundancy-based retention policies, by using REPORT OBSOLETE with RECOVERY WINDOW and REDUNDANCY options, as shown in these examples: REPORT OBSOLETE RECOVERY WINDOW OF 3 DAYS; REPORT OBSOLETE REDUNDANCY 1;
---- -------- -------------------- ------- -----------------------1 2 3 4 5 450 141 50 50 50 SYSTEM SYSAUX UD1 TBS_11 TBS_11 YES NO YES NO NO /disk1/oracle/dbs/t_db1.f /disk1/oracle/dbs/t_ax1.f /disk1/oracle/dbs/t_undo1.f /disk1/oracle/dbs/tbs_111.f /disk1/oracle/dbs/tbs_112.f
List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name
www.wilshiresoft.com [email protected]
If you use a recovery catalog, then you can use the atClause to specify a past time, SCN, or log sequence number, as shown in these examples of the command: RMAN> REPORT SCHEMA AT TIME 'SYSDATE-14'; # schema 14 days ago RMAN> REPORT SCHEMA AT SCN 1000; # schema at scn 1000
RMAN> REPORT SCHEMA AT SEQUENCE 100 THREAD 1; # schema at sequence 100 RMAN> REPORT SCHEMA FOR DB_UNIQUE_NAME standby1; # schema for database standby1
SELECT SESSION_KEY, INPUT_TYPE, STATUS, TO_CHAR(START_TIME,'mm/dd/yy hh24:mi') start_time, TO_CHAR(END_TIME,'mm/dd/yy hh24:mi') ELAPSED_SECONDS/3600 FROM V$RMAN_BACKUP_JOB_DETAILS ORDER BY SESSION_KEY; end_time, hrs
The following sample output shows the backup job history: SESSION_KEY INPUT_TYPE STATUS START_TIME END_TIME HRS
----------- ------------- --------- -------------- -------------- ------9 DATAFILE FULL COMPLETED 04/18/07 18:14 04/18/07 18:15 16 DB FULL 113 ARCHIVELOG COMPLETED 04/18/07 18:20 04/18/07 18:22 COMPLETED 04/23/07 16:04 04/23/07 16:05 .02 .03 .01
3. Query the V$RMAN_BACKUP_JOB_DETAILS view for the rate of backup jobs in an RMAN session.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
The following query shows the backup job speed ordered by session key, which the primary key for the RMAN session. The columns in_sec and out_sec columns display the data input and output per second. COL in_sec FORMAT a10 COL out_sec FORMAT a10 COL TIME_TAKEN_DISPLAY FORMAT a10 SELECT SESSION_KEY, OPTIMIZED, COMPRESSION_RATIO, INPUT_BYTES_PER_SEC_DISPLAY in_sec, OUTPUT_BYTES_PER_SEC_DISPLAY out_sec, TIME_TAKEN_DISPLAY FROM V$RMAN_BACKUP_JOB_DETAILS
ORDER BY SESSION_KEY; The following sample output shows the speed of the backup jobs: SESSION_KEY OPT COMPRESSION_RATIO IN_SEC OUT_SEC
TIME_TAKEN
----------- --- ----------------- ---------- ---------- ---------9 NO 16 NO 113 NO 1 1.32732239 1 8.24M 6.77M 2.99M 8.24M 5.10M 2.99M 00:01:14 00:01:45 00:00:44
4. Query the V$RMAN_BACKUP_JOB_DETAILS view for the size of the backups in an RMAN session. If you run BACKUP DATABASE, then V$RMAN_BACKUP_JOB_DETAILS.OUTPUT_BYTES shows the total size of backup sets written by the backup job for the database that you are backing up. To view backup set sizes for all registered databases, query RC_RMAN_BACKUP_JOB_DETAILS. The following query shows the backup job speed ordered by session key, which the primary key for the RMAN session. The columns in_sec and out_sec columns display the data input and output per second. COL in_size FORMAT a10 COL out_size FORMAT a10 SELECT SESSION_KEY, INPUT_TYPE, COMPRESSION_RATIO, INPUT_BYTES_DISPLAY in_size, OUTPUT_BYTES_DISPLAY out_size FROM V$RMAN_BACKUP_JOB_DETAILS
ORDER BY SESSION_KEY; The following sample output shows the speed of the backup jobs: SESSION_KEY INPUT_TYPE COMPRESSION_RATIO IN_SIZE
OUT_SIZE
----------- ------------- ----------------- ---------- ---------10 DATAFILE FULL 17 DB FULL 1 1.13736669 602.50M 634.80M 602.58M 558.13M
About Recovery Catalog Views RMAN obtains backup and recovery metadata from a target database control file and stores it in the tables of the recovery catalog. The recovery catalog views are derived from these tables. Note that the recovery catalog views are not normalized or optimized for user queries. In general, the recovery catalog views are not as user-friendly as the RMAN reporting commands. For example, when you start RMAN and connect to a target database, you obtain the information for this target database only when you issue LIST, REPORT, and SHOW commands. If you have ten different target databases registered in the same recovery catalog, then any query of the catalog views show the metadata for all incarnations of all ten databases. You often have to perform complex selects and joins among the views to extract usable information about a database incarnation. Most of the catalog views have a corresponding V$ view in the database. For example, RC_BACKUP_PIECE corresponds to V$BACKUP_PIECE. The primary difference between the recovery catalog view and corresponding V$ view is that each recovery catalog view contains metadata about all the target databases registered in the recovery catalog. The V$ view contains information only about itself.
www.wilshiresoft.com [email protected]
catalog owner. The owner of the base recovery catalog determines which objects each virtual catalog user can access. You can use a recovery catalog in an environment in which you use or have used different versions of Oracle Database. As a result, your environment can have different versions of the RMAN client, recovery catalog database, recovery catalog schema, and target database.
Most of the space used in the recovery catalog database is devoted to supporting tablespaces, for example, the SYSTEM, temporary, and undo tablespaces.
www.wilshiresoft.com [email protected]
Caution: Ensure that the recovery catalog and target databases do not reside on the same disk. If both your recovery catalog and your target database suffer hard disk failure, then your recovery process is much more difficult. If possible, take other measures as well to eliminate common points of failure between your recovery catalog database and the databases you are backing up.
To create the recovery catalog schema in the recovery catalog database: 1. Start SQL*Plus and connect with administrator privileges to the database containing the recovery catalog. In this example, the database is catdb. 2. Create a user and schema for the recovery catalog. For example, you could enter the following SQL statement (replacing password with a user-defined password): CREATE USER rman IDENTIFIED BY password TEMPORARY TABLESPACE temp DEFAULT TABLESPACE tools QUOTA UNLIMITED ON tools; 3. Grant the RECOVERY_CATALOG_OWNER role to the schema owner. This role provides the user with all privileges required to maintain and query the recovery catalog. GRANT RECOVERY_CATALOG_OWNER TO rman;
---- ---------- ---------------- ------- ------------------1 2 3 4 5 6 7 8 307200 SYSTEM 20480 UNDOTBS 10240 CWMLITE 10240 DRSYS 10240 EXAMPLE 10240 INDX 10240 TOOLS 10240 USERS NO YES NO NO NO NO NO NO /oracle/oradata/trgt/system01.dbf /oracle/oradata/trgt/undotbs01.dbf /oracle/oradata/trgt/cwmlite01.dbf /oracle/oradata/trgt/drsys01.dbf /oracle/oradata/trgt/example01.dbf /oracle/oradata/trgt/indx01.dbf /oracle/oradata/trgt/tools01.dbf /oracle/oradata/trgt/users01.dbf
For example, assume that a group of directories /disk1/backups, /disk1/backups-year2003, /disk1/backupsets, and /disk1/backupsets/test and so on, all contain backup files. The following command catalogs all files in all of these directories, because /disk1/backups is a prefix for the paths for all of these directories: CATALOG START WITH '/disk1/backups'; To catalog only backups in the /disk1/backups directory, the correct command would be as follows: CATALOG START WITH '/disk1/backups/';
www.wilshiresoft.com [email protected]
3. Grant the RECOVERY_CATALOG_OWNER role to the database user that will own the virtual catalog, and then exit SQL*Plus. The following example grants the role to user vpc1: SQL> GRANT recovery_catalog_owner TO vpc1; SQL> EXIT; 4. Start RMAN and connect to the recovery catalog database as the base recovery catalog owner (not the virtual catalog owner). The following example connects to the base recovery catalog as catowner: % rman RMAN> CONNECT CATALOG catowner@catdb;
recovery catalog database Password: password connected to recovery catalog database 5. Grant desired privileges to the virtual catalog owner. The following example gives user vpc1 access to the metadata for prod1 and prod2 (but not prod3): RMAN> GRANT CATALOG FOR DATABASE prod1 TO vpc1; RMAN> GRANT CATALOG FOR DATABASE prod2 TO vpc1; You can also use a DBID rather than a database name. Note that the virtual catalog user does not have access to the metadata for any other databases registered in the recovery catalog. You can also grant the user the ability to register new target databases in the recovery catalog. For example: RMAN> GRANT REGISTER DATABASE TO vpc1;
www.wilshiresoft.com [email protected]
Reporting on RMAN Operations 2. Revoke specified privileges from the virtual catalog owner. The following command revokes access to the metadata for prod1 from virtual catalog owner vpc1: REVOKE CATALOG FOR DATABASE prod1 FROM vpc1;
You can also specify a DBID rather than a database name. Note that vpc1 retains all other granted catalog privileges. You can also revoke the privilege to register new target databases in the recovery catalog. For example: REVOKE REGISTER DATABASE FROM vpc1;
www.wilshiresoft.com [email protected]
Reporting on RMAN Operations to disk. Do not use another recovery catalog as the repository for the backups. Configure the control file autobackup feature to ON.
With this strategy, the control file autobackup feature ensures that the recovery catalog database can always be recovered, so long as the control file autobackup is available.
any database registered in the recovery catalog, if the RMAN client is connected to the recovery catalog and a target database. The commands allowable within the brackets of the CREATE SCRIPT command are the same commands supported within a RUN block. Any command that is legal within a RUN command is permitted in the stored script. The following commands are not legal within stored scripts: RUN, @, and @@. When specifying a script name, RMAN permits but generally does not require that you u se quotes around the name of a stored script. If the name begins with a digit or is an RMAN reserved word, however, then you must put quotes around the name to use it as a stored script name. Consider avoiding stored script names that begin with nonalphabetic characters or that are the same as RMAN reserved words. Consider using a naming convention to avoid confusion between global and local stored scripts. For the EXECUTE SCRIPT, DELETE SCRIPT and PRINT SCRIPT commands, if the script name passed as an argument is not the name of a script defined for the connected target instance, then RMAN looks for a global script by the same name. For example, if the global script global_backup is in the recovery catalog, but no local stored script global_backup is defined for the target database, then the following command deletes the global script: DELETE SCRIPT global_backup; Note that to use commands related to stored scripts, even global scripts, you must be connected to both a recovery catalog and a target database instance.
3. Examine the output. If no errors are displayed, then RMAN successfully created the script and stored in the recovery catalog.
www.wilshiresoft.com [email protected]
recovery catalog database is in Japan. You may not want to make daily backups of the target database in CATALOG mode, to avoid depending on the availability of a geographically distant database. In such a case you could connect to the catalog as often as feasible and run the RESYNC CATALOG command. Resynchronizing in ARCHIVELOG Mode When You Backup Infrequently Assume that a target database runs in ARCHIVELOG mode. Also assume that you do the following: Back up the database infrequently (for example, hundreds of redo logs are archived between database backups) Generate a high number of log switches every day (for example, 1000 switches between catalog resynchronizations) In this case, you may want to manually resynchronize the recovery catalog regularly because the recovery catalog is not updated automatically when a redo log switch occurs or when a redo log is archived. The database stores metadata about redo log switches and archived redo logs only in the control file. You must periodically resynchronize in order to propagate this information into the recovery catalog. How frequently you need to resynchronize the recovery catalog depends on the rate at which the database archives redo logs. The cost of the operation is proportional to the number of records in the control file that have been inserted or changed since the previous resynchronization. If no records have been inserted or changed, then the cost of resynchronization is very low; if many records have been inserted or changed, then the resynchronization is more time-consuming. Resynchronizing the Recovery Catalog before Control File Records Age out Your goal is to ensure that the metadata in the recovery catalog is current. Because the recovery catalog obtains its metadata from the target control file, the currency of the data in the catalog depends on the currency of the data in the control file. You need to make sure that the backup metadata in the control file is recorded in the catalog before it is overwritten with new records. The CONTROL_FILE_RECORD_KEEP_TIME initialization parameter determines the minimum number of days that records are retained in the control file before they are candidates for being overwritten. Thus, you must ensure that you resynchronize the recovery catalog with the control file record s before these records are erased. You should perform either of the following actions at intervals less than the CONTROL_FILE_RECORD_KEEP_TIME setting: Make a backup, thereby performing an implicit resynchronization of the recovery catalog Manually resynchronize the recovery catalog with the RESYNC CATALOG command Make sure that CONTROL_FILE_RECORD_KEEP_TIME is longer than the interval between backups or resynchronizations. Otherwise, control file records could be reused before they are propagated to the recovery catalog. An extra week is a safe margin in most circumstances. Caution: Never set CONTROL_FILE_RECORD_KEEP_TIME to 0. If you do, then backup records may be overwritten in the control file before RMAN is able to add them to the catalog. One problem can arise if the control file becomes too large. The size of the target database control file grows depending on the number of: Backups that you perform Archived redo logs that the database generates Days that this information is stored in the control file
If the control file grows so large that it can no longer expand because it has reached either the maximum number of blocks or the maximum number of records, then the database may overwrite the oldest records even if their age is less than the CONTROL_FILE_RECORD_KEEP_TIME setting. In this case, the database writes a message to the alert log. If you discover that this situation occurs frequently, then reducing the value of CONTROL_FILE_RECORD_KEEP_TIME and increase the frequency of resynchronizations.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
contents of the control file at the time of reregistration. Records older than the CONTROLFILE_RECORD_KEEP_TIME setting in the target database control file are lost. Stored scripts, which are not stored in the control file, are also lost. To unregister a database: 1. Start RMAN and connect as TARGET to the database that you want to unregister. Also connect to the recovery catalog. It is not necessary to connect to the target database, but if you do not, then you must specify the name of the target database in the UNREGISTER command. If more than one database has the same name in the recovery catalog, then you must create a RUN block around the command and use SET DBID to set the DBID for the database. 2. Make a note of the DBID as displayed by RMAN at startup. For example, RMAN outputs a line of the following form when it connects to a target database that is open: connected to target database: PROD (DBID=39525561) If more than one database is registered in the recovery catalog with the same name, then you need the DBID to uniquely identify the database. 3. As a precaution, it may be useful to list all of the backups recorded in the recovery catalog using LIST BACKUP SUMMARY and LIST COPY SUMMARY. This way, you can recatalog backups not known to the control file if you later decide to reregister the database. 4. If your intention is to actually delete all backups of the database completely, then run DELETE statements to delete all existing backups. Do not delete all backups if your intention is only to remove the database from the recovery catalog and rely on the control file to store the RMAN metadata for this database. The following commands illustrate how to delete backups: DELETE BACKUP DEVICE TYPE sbt; DELETE BACKUP DEVICE TYPE DISK; DELETE COPY; RMAN lists the backups that it intends to delete and prompts for confirmation before deleting them. 5. Run the UNREGISTER DATABASE command. For example: UNREGISTER DATABASE; RMAN displays the database name and DBID, and prompts you for a confirmation: database name is "RDBMS" and DBID is 931696259 Do you really want to unregister the database (enter YES or NO)? yes When the process is complete, RMAN outputs the following message: database unregistered from the recovery catalog
www.wilshiresoft.com [email protected]
Reporting on RMAN Operations List of Database Incarnations DB Key Inc Key DB Name ------TRGT TRGT DB ID -----1224038686 1224038686 STATUS ------PARENT CURRENT Reset SCN ---------1 59727
The incarnation key is listed in the Inc Key column. 2. Reset the database to the old incarnation. For example, enter: RESET DATABASE TO INCARNATION 2; 3. If the control file of the previous incarnation is available and mounted, then skip to step 6 of this procedure. Otherwise, shut down the database and start it without mounting. For example: SHUTDOWN IMMEDIATE STARTUP NOMOUNT 4. Restore a control file from the old incarnation. If you have a control file tagged, then specify the tag. Otherwise, you can run the SET UNTIL command, as in this example: RUN { SET UNTIL 'SYSDATE-45'; RESTORE CONTROLFILE; # only if current control file is not available } 5. Mount the restored control file: ALTER DATABASE MOUNT; 6. Run RESTORE and RECOVER commands to restore and recover the database files from the prior incarnation, then open the database with the RESETLOGS option. For example, enter: RESTORE DATABASE; RECOVER DATABASE; ALTER DATABASE OPEN RESETLOGS;
www.wilshiresoft.com [email protected]
www.wilshiresoft.com [email protected]
If you drop a recovery catalog, and if you have no backups of the recovery catalog schema, then backups of all target databases registered in this catalog may become unusable. However, the control file of every target database will still retain a record of recent backups of this database. The DROP CATALOG command is not appropriate for unregistering a single database from a recovery catalog that has multiple target databases registered. Dropping the recovery catalog deletes the recovery catalog record of backups for all target databases registered in the catalog. To drop a recovery catalog schema: 1. Start RMAN and connect to a target database and recovery catalog. Connect to the recovery catalog as the owner of the catalog schema to be dropped.
The following example connects to a recovery catalog as user catowner: % rman TARGET / CATALOG catowner@catdb 2. Run the DROP CATALOG command: DROP CATALOG; recovery catalog owner is catowner enter DROP CATALOG command again to confirm catalog removal 3. Run the DROP CATALOG command again to confirm: DROP CATALOG; Note: Even after you drop the recovery catalog, the control file still contains records about the backups. To purge RMAN repository records from the control file, re-create the control file.
www.wilshiresoft.com [email protected]
Tablespace point-in-time recovery (TSPITR) This is a specialized form of point-in-time recovery in which you recover one or more tablespaces to a time earlier than the rest of the database. In general, the concepts required to use the preceding repair techniques are explained along with the techniques. This chapter explains concepts that are common to several RMAN data repair solutions.
You can specify either the default location or a new location for restored datafiles and control files. If you restore to the default location, then RMAN overwrites any files with the same name that currently exist in this location. Alternatively, you can use the SET NEWNAME command to specify new locations for restored datafiles. You can then run a SWITCH command to update the control file to indicate that the restored files in their new locations are now the current datafiles.
RMAN Data Reair Concepts ORA-19505: failed to identify file "/u01/backup/db_1" ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3 failover to previous backup
RMAN will perform restore failover repeatedly until it has exhausted all possible backups. If all of the backups are unusable or no backups exists, then RMAN attempts to re-create the datafile. Restore failover is also used when there are errors restoring archived redo logs during RECOVER, RECOVER ... BLOCK, and FLASHBACK DATABASE commands.
backup control file, however, you must open the database with the RESETLOGS option, thereby creating a new incarnation of the database. The database requires a new incarnation to avoid confusion when two different redo streams have the same SCNs, but occurred at different times. If you apply the wrong redo to your database, then you will corrupt it. The existence of multiple incarnations of a single database determines how RMAN treats backups that are not in the current incarnation path. In almost all cases, the current database incarnation is the correct one to use. Nevertheless, in some cases resetting the database to a previous incarnation is the best approach. For example, you may be dissatisfied with the results of a point-in-time recovery that you have already performed and want to return the database to a time before the RESETLOGS. An understanding of database incarnations is helpful to prepare for such situations. OPEN RESETLOGS Operations When you open the database with the RESETLOGS option, the database performs the following actions: Archives the current online redo logs (if they are accessible) and then erases the contents of the online redo logs and resets the log sequence number to 1. For example, if the current online redo logs are sequence 1000 and 1001 when you open RESETLOGS, then the database archives logs 1000 and 1001 and then resets the online redo logs to sequence 1 and 2. Creates the online redo log files if they do not currently exist. Initializes redo thread records and online redo log records in the control file to the beginning of the new database incarnation. More specifically, the database sets the redo thread status to closed, sets the current thread sequence in the redo thread records to 1, sets the thread checkpoint of each redo thread to the beginning of log sequence 1, chooses one redo log from each thread and initialize its sequence to 1, and so on. Updates all current datafiles and online redo logs and all subsequent archived redo logs with a new RESETLOGS SCN and time stamp. Because the database will not apply an archived redo log to a datafile unless the RESETLOGS SCN and time stamps match, the RESETLOGS requirement prevents you from corrupting datafiles with archived logs that are not from direct parent incarnations of the current incarnation. The relationship among incarnations is explained more fully in the following section. In previous releases, it was recommended that you back up the database immediately after the OPEN RESETLOGS. Because you can now easily recover a pre-RESETLOGS backup like any other backup, making a new database backup is optional. To perform recovery through RESETLOGS you must have all archived logs generated after the most recent backup and at least one control file (current, backup, or created).
www.wilshiresoft.com [email protected]
reactively or proactively. Failures are normally detected reactively. A database operation involving corrupted data results in an error, which automatically invokes a data integrity check that searches the database for failures related to the error. If failures are diagnosed, then they are recorded in the Automatic Diagnostic Repository (ADR), which is a directory structure stored outside of the database. You can use Data Recovery Advisor to generate repair advice and repair failures only after failures have been detected by the database and stored in ADR. You can also invoke a data integrity check proactively. You can execute the check through the Health Monitor, which detects and stores failures in the same way as when the checks are invoked reactively. You can also check for block corruption with the VALIDATE and BACKUP VALIDATE commands.
18.2.3 Failures
A failure is a persistent data corruption that is detected by a data integrity check. A failure can manifest itself as observable symptoms such as error messages and alerts, but a failure is different from a symptom because it represents a diagnosed problem. After a problem is diagnosed by the database as a failure, you can obtain information about the failure and potentially repair it by means of Data Recovery Advisor. Because failure information is not stored in the database itself, the database does not need to be open or mounted for you to access it. You can view failures when the database is started in NOMOUNT mode. Thus, the availability of the control file and recovery catalog does not affect the ability to view detected failures, although it may affect the feasibility of some repairs. Data Recovery Advisor can diagnose failures such as the following: Components such as datafiles and control files that are not accessible because they do not exist, do not have the correct access permissions, have been taken offline, and so on. Physical corruptions such as block checksum failures and invalid block header field values.
Inconsistencies such as a datafile that is older than other database files I/O failures such as hardware errors, operating system driver failures, and exceeding operating system resource limits (for example, the number of open files) Note that Data Recovery Advisor may detect or handle some logical corruptions. But in general, corruptions of this type require help from Oracle Support Services. Failure Status Every failure has a failure status: OPEN or CLOSED. The status of a failure is OPEN until the appropriate repair action is invoked. The status changes to CLOSED after the failure is repaired. Every time you execute LIST FAILURE, Data Recovery Advisor revalidates all open failures and closes failures that no longer exist. Thus, if you fixed some failures as part of a separate procedure, or if the failures were transient problems that disappeared by themselves, running LIST FAILURE will automatically close them. If a failure cannot be revalidated at this time (for example, because of another failure), then LIST FAILURE shows the failure as open. You can use CHANGE FAILURE to change the status of an open failure to CLOSED if you have fixed it manually. However, it makes sense to use CHANGE FAILURE ... CLOSED only if for some reason the failure was not closed automatically. If a failure still exists when you use CHANGE to close it manually, then Data Recover Advisor recreates it with a different failure ID when the appropriate data integrity check is executed. Failure Priority Every failure has a failure priority: CRITICAL, HIGH, or LOW. Data Recovery Advisor only assigns CRITICAL or HIGH priority to diagnosed failures. Failures with CRITICAL priority requires immediate attention because they make the whole database unavailable. For example, a disk containing a current control file may fail. Failures with HIGH priority make a database partly unavailable or unrecoverable and usually have to be repaired quickly. Examples include block corruptions and missing archived redo logs. If a failure was assigned a HIGH priority, but the failure has little impact on database availability and recoverability, then you can downgrade the priority to LOW. A LOW priority indicates that a failure can be ignored until more important failures are fixed. By default LIST FAILURE displays only failures with CRITICAL and HIGH priority. You can use the CHANGE command to change the status for LOW and HIGH failures, but you cannot change the status of CRITICAL failures. The main reason for changing a priority to LOW is to reduce the LIST FAILURE output. Failure grouping for clarity, Data Recovery Advisor groups related failures together. For example, if 20 different blocks in a file are corrupted, then these failures will be grouped under a single parent failure. By default, Data Recovery Advisor lists information about the group of failures, although you can specify the DETAIL option to list
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
information about the individual subfailures. A subfailure has the same format as a failure. You can get advice on a subfailure and repair it separately or in a combination with any other failure.
Data Recovery Advisor cannot use blocks or files transferred from a physical standby database to repair failures on a primary database. Also, you cannot use Data Recovery Advisor to diagnose and repair failures on a standby database. If you are using Enterprise Manager Grid Control in a Data Guard configuration, however, then you can fail over to a standby database and perform repairs on the old primary database.
---------- -------- --------- ------------- ------142 HIGH OPEN 23-APR-07 One or more non-system datafiles
www.wilshiresoft.com [email protected]
Diagnoising & Repairing Failures '/disk1/oradata/prod/system01.dbf' contains one or more corrupt blocks
In this example, RMAN reports two different failures: a group of missing datafiles and a datafile with corrupt blocks. The output indicates the unique identifier for each failure (12 and 5), the priority, status, and detection time. 3. Optionally, execute LIST FAILURE ... DETAIL to list failures individually. Data Recovery Advisor consolidates failures when possible. Specify the DETAIL option to list failures individually. For example, if multiple block corruptions exist in a file, then specifying the DETAIL option would list each of the block corruptions. The following example lists detailed information about failure 101. RMAN> LIST FAILURE 101 DETAIL; List of Database Failures ========================= Failure ID Priority Status Time Detected Summary
'/disk1/oradata/prod/system01.dbf' contains one or more corrupt blocks List of child failures for parent failure ID 101 Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- ------104 HIGH OPEN 23-APR-07 Block 56416 in datafile 1:
'/disk1/oradata/prod/system01.dbf' is media corrupt Impact: Object BLKTEST owned by SYS might be unavailable 4. Proceed to determine how to repair the failures displayed by the LIST FAILURE command.
www.wilshiresoft.com [email protected]
The following example uses VALIDATE DATABASE to check for physical and logical corruption in the whole database (partial sample output included). Because it indicates that some datafiles are missing, the
Starting validate at 23-APR-07 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=103 device type=DISK could not access datafile 28 skipping inaccessible file 28 RMAN-06060: WARNING: skipping datafile compromises tablespace USERS recoverability RMAN-06060: WARNING: skipping datafile compromises tablespace USERS recoverability channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation input datafile file number=00001 name=/disk1/oradata/prod/system01.dbf input datafile file number=00002 name=/disk1/oradata/prod/sysaux01.dbf input datafile file number=00022 name=/disk1/oradata/prod/undotbs01.dbf input datafile file number=00023 name=/disk1/oradata/prod/cwmlite01.dbf input datafile file number=00024 name=/disk1/oradata/prod/drsys01.dbf input datafile file number=00025 name=/disk1/oradata/prod/example01.dbf input datafile file number=00026 name=/disk1/oradata/prod/indx01.dbf input datafile file number=00027 name=/disk1/oradata/prod/tools01.dbf channel ORA_DISK_1: validation complete, elapsed time: 00:00:25 List of Datafiles ================= File Status Marked Corrupt Empty Blocks Blocks Examined High SCN ---- ------ -------------- ------------ --------------- ---------1 FAILED 0 3536 57600 637711
File Name: /disk1/oradata/prod/system01.dbf Block Type Blocks Failing Blocks Processed ---------- -------------- ---------------Data Index Other . . . File Status Marked Corrupt Empty Blocks Blocks Examined High SCN ---- ------ -------------- ------------ --------------- ---------27 OK 0 1272 1280 400914 1 0 0 41876 7721 4467
File Name: /disk1/oradata/prod/tools01.dbf Block Type Blocks Failing Blocks Processed ---------- -------------- ---------------Data 0 0
Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
www.wilshiresoft.com [email protected]
validate found one or more corrupt blocks See trace file /disk1/oracle/log/diag/rdbms/prod/prod/trace/prod_ora_2596.trc for details channel ORA_DISK_1: starting validation of datafile channel ORA_DISK_1: specifying datafile(s) for validation including current control file for validation including current SPFILE in backup set channel ORA_DISK_1: validation complete, elapsed time: 00:00:01 List of Control File and SPFILE =============================== File Type Status Blocks Failing Blocks Examined
Control File OK
---------- -------- --------- ------------- ------142 HIGH OPEN 23-APR-07 One or more non-system datafiles are missing 101 HIGH OPEN 23-APR-07 Datafile 1:
Diagnoising & Repairing Failures using channel ORA_DISK_1 analyzing automatic repair options complete Mandatory Manual Actions ======================== no manual actions available
Optional Manual Actions ======================= 1. If file /disk1/oradata/prod/users01.dbf was unintentionally renamed or moved, restore it Automated Repair Options ======================== Option Repair Description ------ -----------------1 Restore and recover datafile 28; Perform block media recovery of block 56416 in file 1 Strategy: The repair includes complete media recovery with no data loss Repair script: /disk1/oracle/log/diag/rdbms/prod/prod/hm/reco_660500184.hm In the preceding example, ADVISE FAILURE reports two failures: a missing datafile and a datafile with corrupt blocks. The command does not list mandatory manual actions, but it suggests making sure that the missing datafile was not accidentally renamed or removed. The automated repair option involves block media recovery and restoring and recovering the missing datafile. ADVISE FAILURE lists the location of the repair script. The following variation of the same example shows the output when the RMAN backups or archived redo logs needed for the automated repair are not available. Note that ADVISE FAILURE now shows mandatory manual actions. RMAN> ADVISE FAILURE; List of Database Failures ========================= Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- ------142 HIGH OPEN 23-APR-07 One or more non-system datafiles are missing 101 HIGH OPEN 23-APR-07 Datafile 1:
analyzing automatic repair options; this may take some time allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=103 device type=DISK analyzing automatic repair options complete
Mandatory Manual Actions ======================== 1. If file /disk1/oradata/prod/users01.dbf was unintentionally renamed or moved, restore it
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
2. Contact Oracle Support Services if the preceding recommendations cannot be used, or if they do not fix the failures selected for repair
Automated Repair Options ======================== Option Repair Description ------ -----------------1 Perform block media recovery of block 56416 in file 1 Strategy: The repair includes complete media recovery with no data loss Repair script: /disk1/oracle/log/diag/rdbms/prod/prod/hm/reco_1863891774.hm 3. Proceed to determine how to repair the failures shown in the LIST FAILURE output. Determining Repair Options for a Subset of Failures You can also request repair options for specific failures. You can specify failures by status (CRITICAL, HIGH, or LOW) or by failure number. You can also use EXCLUDE FAILURE to exclude one or more failures from the report. To determine repair options for a subset of failures: 1. List failures. 2. In the same RMAN session, execute ADVISE FAILURE with the desired options. The following example requests repair options for failure 101 only. RMAN> ADVISE FAILURE 101; List of Database Failures ========================= Failure ID Priority Status Time Detected Summary
analyzing automatic repair options; this may take some time using channel ORA_DISK_1 analyzing automatic repair options complete
Diagnoising & Repairing Failures ------ -----------------1 Perform block media recovery of block 56416 in file 1 Strategy: The repair includes complete media recovery with no data loss
Repair script: /disk1/oracle/log/diag/rdbms/prod/prod/hm/reco_708819503.hm 3. Proceed to determine how to repair the failures displayed by the LIST FAILURE command.
Strategy: The repair includes complete media recovery with no data loss Repair script: /disk1/oracle/log/diag/rdbms/prod/prod/hm/reco_475549922.hm contents of repair script: # restore and recover datafile sql 'alter database datafile 28 offline'; restore datafile 28; recover datafile 28; sql 'alter database datafile 28 online'; # block media recovery recover datafile 1 block 56416; 4. Execute REPAIR FAILURE. The following repair restores and recovers one datafile and performs block media recovery on one corrupt block. RMAN prompts for confirmation that it should perform the repair. The user-entered text is in bold.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Strategy: The repair includes complete media recovery with no data loss Repair script: /disk1/oracle/log/diag/rdbms/prod/prod/hm/reco_475549922.hm contents of repair script: # restore and recover datafile sql 'alter database datafile 28 offline'; restore datafile 28; recover datafile 28; sql 'alter database datafile 28 online'; # block media recovery recover datafile 1 block 56416;
Do you really want to execute the above repair (enter YES or NO)? YES executing repair script sql statement: alter database datafile 28 offline Starting restore at 23-APR-07 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00028 to /disk1/oradata/prod/users01.dbf channel ORA_DISK_1: reading from backup piece /disk2/PROD/backupset/2007_04_18/o1_mf_nnndf_TAG20070418T182042_32fjzd3z_.bkp channel ORA_DISK_1: piece handle=/disk2/PROD/backupset/2007_04_18/o1_mf_nnndf_TAG20070418T182042_32fjzd3z_.bkp tag=TAG20070418T182042
channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03 Finished restore at 23-APR-07 Starting recover at 23-APR-07 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 23-APR-07
using channel ORA_DISK_1 searching flashback logs for block images until SCN 429690 finished flashback log search, restored 1 blocks
Diagnoising & Repairing Failures media recovery complete, elapsed time: 00:00:03
Finished recover at 23-APR-07 repair failure complete 5. Optionally, execute LIST FAILURE to confirm
---------- -------- --------- ------------- ------142 HIGH OPEN 23-APR-07 One or more non-system datafiles are missing 101 HIGH OPEN 23-APR-07 Datafile 25:
'/disk1/oradata/prod/example01.dbf' contains one or more corrupt blocks 2. Execute CHANGE FAILURE with the desired options. The following example changes the priority of a block corruption failure from HIGH to LOW. RMAN> CHANGE FAILURE 101 PRIORITY LOW;
---------- -------- --------- ------------- ------101 HIGH OPEN 23-APR-07 Datafile 25:
Do you really want to change the above failures (enter YES or NO)? YES changed 1 failures to LOW priority 3. Optionally, execute LIST FAILURE ALL to view the change.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Note that if you execute LIST FAILURE without ALL, then the command lists failures with LOW priority only if no CRITICAL or HIGH priority failures exist. RMAN> LIST FAILURE ALL;
---------- -------- --------- ------------- ------142 HIGH OPEN 23-APR-07 One or more non-system datafiles are missing 101 LOW OPEN 23-APR-07 Datafile 25:
www.wilshiresoft.com [email protected]
In a physical corruption, which is also called a media corruption, the database does not recognize the block at all: the checksum is invalid, the block contains all zeros, or the header and footer of the block do not match. In a logical corruption, the contents of the block are logically inconsistent. Examples of logical corruption include corruption of a row piece or index entry. Block corruptions can also be divided into interblock corruption and intrablock corruption. In intrablock corruption, the corruption occurs within the block itself and can be either physical or logical corruption. In an interblock corruption, the corruption occurs between blocks and can only be logical corruption. Oracle Database supports different techniques for detecting, repairing, and monitoring block corruption. The technique depends on the corruption type. For example, the V$DATABASE_BLOCK_ CORRUPTION view tracks intrablock corruptions, while the Automatic Diagnostic Repository (ADR) tracks all types of corruptions.
www.wilshiresoft.com [email protected]
Use VALIDATE BACKUPSET when you suspect that one or more backup pieces in a backup set are missing or have been damaged. This command checks every block in a backup set to ensure that the backup can be restored. If RMAN finds block corruption, then it issues an error and terminates the validation. Note that VALIDATE BACKUPSET enables you to choose which backups to check, whereas the VALIDATE option of the RESTORE command lets RMAN choose. To use VALIDATE to check database files and backups: 1. Start RMAN and connect to a target database. 2. Execute the VALIDATE command with the desired options. For example, to validate all datafiles and control files (and the server parameter file if one is in use), execute the following command at the RMAN prompt: RMAN> VALIDATE DATABASE; Alternatively, you can validate a particular backup set by using the form of the command shown in the following example (sample output included). RMAN> VALIDATE BACKUPSET 22;
Starting validate at 17-AUG-06 using channel ORA_DISK_1 allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=89 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Oracle Secure Backup channel ORA_DISK_1: starting validation of datafile backup set channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/RDBMS/backupset/2007_08_16/o1_mf_nnndf_TAG20070816T153 034_2g774bt2_.bkp channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/RDBMS/backupset/2007_08_16/o1_mf_nnndf_TAG20070 816T153034_2g774bt2_.bkp tag=TAG20070816T153034 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: validation complete, elapsed time: 00:00:01 Finished validate at 17-AUG-06 The following example illustrates how you can check individual data blocks within a datafile for corruption. RMAN> VALIDATE DATAFILE 1 BLOCK 10; Starting validate at 17-AUG-06 using channel ORA_DISK_1 channel ORA_DISK_1: starting validation of datafile channel ORA_DISK_1: specifying datafile(s) for validation input datafile file number=00001 name=/disk1/oracle/dbs/tbs_01.f channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
List of Datafiles ================= File Status Marked Corrupt Empty Blocks Blocks Examined High SCN ---- ------ -------------- ------------ --------------- ---------1 OK 0 2 127 481907
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 08/29/2007 14:33:47 ORA-19625: error identifying file /oracle/oradata/trgt/arch/archive1_6.dbf ORA-27037: unable to obtain file status SVR4 Error: 2: No such file or directory Additional information: 3
www.wilshiresoft.com [email protected]
Report of database schema for database with db_unique_name RDBMS Preparing for Complete Database Recovery
List of Permanent Datafiles =========================== File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- -----------------------1 2 3 4 5 6 7 450 86 15 2 2 2 2 SYSTEM SYSAUX UD1 SYSTEM TBS_1 TBS_1 TBS_2 *** *** *** *** *** *** *** +DATAFILE/tbs_01.f +DATAFILE/tbs_ax1.f +DATAFILE/tbs_undo1.f +DATAFILE/tbs_02.f +DATAFILE/tbs_11.f +DATAFILE/tbs_12.f +DATAFILE/tbs_21.f
List of Temporary Files ======================= File Size(MB) Tablespace Maxsize(MB) Tempfile Name
Identifying Datafiles with SQL Although VALIDATE DATABASE is a good technique for determining whether files are inaccessible, you may want to use SQL queries to obtain more detailed information. To determine whether datafiles require media recovery: 1. Start SQL*Plus and connect to the target database instance with administrator privileges. 2. Determine the status of the database by executing the following SQL query: SELECT STATUS FROM V$INSTANCE; If the status is OPEN, then the database is open. Nevertheless, some datafiles may require media recovery. 3. Query V$DATAFILE_HEADER to determine the status of your datafiles. Run the following SQL statements to check the datafile headers: COL FILE# FORMAT 999 COL STATUS FORMAT A7 COL ERROR FORMAT A10 COL TABLESPACE_NAME FORMAT A10 COL NAME FORMAT A30
SELECT FILE#, STATUS, ERROR, RECOVER, TABLESPACE_NAME, NAME FROM OR V$DATAFILE_HEADER WHERE RECOVER = 'YES' (RECOVER IS NULL AND ERROR IS NOT NULL);
Each row returned represents a datafile that either requires media recovery or has an error requiring a restore. Check the RECOVER and ERROR columns. RECOVER indicates whether a file needs media recovery, and ERROR indicates whether there was an error reading and validating the datafile header. If ERROR is not NULL, then the datafile header cannot be read and validated. Check for a temporary hardware or operating system problem causing the error. If there is no such problem, you must restore the file or switch to a copy. If the ERROR column is NULL and the RECOVER column is YES, then the file requires media recovery (and may also require a restore from backup).
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Note: Because V$DATAFILE_HEADER only reads the header block of each datafile, it does not detect all problems that require the datafile to be restored. For example, this view cannot tell whether a datafile contains corrupt data blocks. 4. Optionally, query V$RECOVER_FILE to list datafiles requiring recovery by datafile number with their status and error information. For example, execute the following query: SELECT FILE#, ERROR, ONLINE_STATUS, CHANGE#, TIME FROM V$RECOVER_FILE;
Note: You cannot use V$RECOVER_FILE with a control file restored from backup or a control file that was recreated after the time of the media failure affecting the datafiles. A restored or re-created control file does not contain the information needed to update V$RECOVER_FILE accurately. To find datafile and tablespace names, you can also perform useful joins using the datafile number and the V$DATAFILE and V$TABLESPACE views. For example: COL DF# FORMAT 999 COL DF_NAME FORMAT A35 COL TBSP_NAME FORMAT A7 COL STATUS FORMAT A7 COL ERROR FORMAT A10 COL CHANGE# FORMAT 99999999
SELECT r.FILE# AS df#, d.NAME AS df_name, t.NAME AS tbsp_name, d.STATUS, r.ERROR, r.CHANGE#, r.TIME FROM V$RECOVER_FILE r, V$DATAFILE d, V$TABLESPACE t WHERE t.TS# = d.TS# AND d.FILE# = r.FILE#; The ERROR column identifies the problem for each file requiring recovery.
Recovery Manager: Release 11.1.0.6.0 - Production on Wed Jul 11 17:51:30 2007 Copyright (c) 1982, 2007, Oracle. All rights reserved.
the files on disk or in the media management catalog correspond to the metadata in the RMAN repository. When planning your restore and recovery operation, use RESTORE ... PREVIEW or RESTORE ... VALIDATE HEADER to ensure that all required backups are available or to identify situations in which you may want to direct RMAN to use or avoid specific backups. To preview backups to be used in a restore operation: 1. Run a RESTORE command with the PREVIEW option. For example, run one of the following commands: RESTORE DATABASE PREVIEW; RESTORE ARCHIVELOG FROM TIME 'SYSDATE-7' PREVIEW; If the report produced by RESTORE ... PREVIEW provides too much information, then specify the SUMMARY option as shown in the following example: RESTORE DATABASE PREVIEW SUMMARY; If satisfied with the output, then stop here. If the output indicates that RMAN will request a backup from a tape that you know is temporarily unavailable, then continue with this procedure. 2. If needed, use the CHANGE command to set the backup status of any temporarily unavailable backups to UNAVAILABLE. 3. Optionally, run RESTORE ... PREVIEW again to confirm that the restore will not attempt to use unavailable backups.
------- ---------- ----------- ------------ --------------9 2.25M BP Key: 9 SBT_TAPE 00:00:00 21-MAY-07 Tag: TAG20070521T144258
Status: AVAILABLE
Compressed: NO
Handle: 0aii9k7i_1_1
Media: 0aii9k7i_1_1
List of Archived Logs in backup set 9 Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- --------1 1 1 1 1 1 1 2 3 4 5 6 392314 392541 392545 392548 395066 395095 21-MAY-07 392541 21-MAY-07 392545 21-MAY-07 392548 21-MAY-07 395066 21-MAY-07 395095 21-MAY-07 395355 21-MAY-07 21-MAY-07 21-MAY-07 21-MAY-07 21-MAY-07 21-MAY-07
Finished restore at 21-MAY-07 released channel: dev1 You can use RESTORE ... PREVIEW RECALL to instruct the media manager to make offsite backups available. To recall offsite backups: If backups are stored offsite, then execute a RESTORE ... PREVIEW command with the RECALL option. The following example initiates recall for the offsite archived log backups shown in Example (sample output included): RESTORE ARCHIVELOG ALL PREVIEW RECALL; The following sample output indicates that RMAN initiated a recall: Preparing for Complete Database Recovery List of Backup Sets ===================
BS Key
Size
------- ---------- ----------- ------------ --------------9 2.25M BP Key: 9 SBT_TAPE 00:00:00 21-MAY-07 Tag: TAG20070521T144258
Status: AVAILABLE
Compressed: NO
Handle: VAULT0aii9k7i_1_1
Media: /tmp,VAULT0aii9k7i_1_1
List of Archived Logs in backup set 9 Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- --------1 1 1 1 1 1 1 2 3 4 5 6 392314 392541 392545 392548 395066 395095 21-MAY-07 392541 21-MAY-07 392545 21-MAY-07 392548 21-MAY-07 395066 21-MAY-07 395095 21-MAY-07 395355 21-MAY-07 21-MAY-07 21-MAY-07 21-MAY-07 21-MAY-07 21-MAY-07
Initiated recall for the following list of remote backup files ========================================================== Handle: VAULT0aii9k7i_1_1 Media: /tmp,VAULT0aii9k7i_1_1
validation succeeded for backup piece Finished restore at 21-MAY-07 released channel: dev1 2. Run the RESTORE ... PREVIEW command. If necessary, return to the previous step until no backups needed for the restore are reported as offsite.
RESTORE ... VALIDATE tests whether RMAN can restore a specific object from a backup. RMAN chooses which backups to use. VALIDATE BACKUPSET tests the validity of a backup set that you specify.
Otherwise, you can use the DELETE ARCHIVELOG command to delete restored archived redo logs from disk when they are no longer needed for recovery. For example, you can enter the following command: RECOVER DATABASE DELETE ARCHIVELOG;
RMAN configuration parameters for database with db_unique_name PROD1 are: . . . CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so"; If the necessary devices and channels are already configured, then no action is necessary. Otherwise, you can use the CONFIGURE command to configure automatic channels, or include ALLOCATE CHANNEL commands within a RUN block. 4. If restoring password-protected encrypted backups, then specify the password. Use the SET DECRYPTION IDENTIFIED BY command to specify a password for password-protected backups, as shown in the following example (where password represents the actual password that you enter): SET DECRYPTION IDENTIFIED BY password;
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
If you created backups with different passwords, then you can run the SET DECRYPTION IDENTIFIED BY password command multiple times, specifying all of the possible passwords that might be required to restore the backups. 5. Restore and recover the database. Do one of the following: If you are restoring all datafiles to their original locations, then execute RESTORE DATABASE and RECOVER DATABASE sequentially at the RMAN prompt. For example, enter the following commands if automatic channels are configured (sample output included): RMAN> RESTORE DATABASE;
Starting restore at 20-JUN-06 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=35 device type=DISK allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=34 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Oracle Secure Backup
channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00001 to /disk1/oracle/dbs/tbs_01.f channel ORA_DISK_1: restoring datafile 00002 to /disk1/oracle/dbs/tbs_ax1.f . . . Finished restore at 20-JUN-06 RMAN> RECOVER DATABASE;
Starting recover at 20-JUN-06 using channel ORA_DISK_1 allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=34 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Oracle Secure Backup
channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=5 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=6 . . . channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20070620T
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
113128_29jhr197_.bkp channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20 070620T113128_29jhr197_.bkp tag=TAG20070620T113128 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jhv47k _.arc thread=1 sequence=5 channel default: deleting archived log(s) . . . media recovery complete, elapsed time: 00:00:15 Finished recover at 20-JUN-06 If you manually allocate channels, then you must issue the RESTORE and RECOVER commands together within a RUN block as shown in the following example: RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt; RESTORE DATABASE; RECOVER DATABASE; } If you are restoring some datafiles to new locations, then execute RESTORE DATABASE and RECOVER DATABASE sequentially in a RUN command. Use the SET NEWNAME to rename datafiles. The following example restores the database, specifying new names for three of the datafiles, and then recovers the database: RUN { SET NEWNAME FOR DATAFILE 2 TO '/disk2/df2.dbf'; SET NEWNAME FOR DATAFILE 3 TO '/disk2/df3.dbf'; SET NEWNAME FOR DATAFILE 4 TO '/disk2/df4.dbf'; RESTORE DATABASE; SWITCH DATAFILE ALL; RECOVER DATABASE; } 6. Examine the output to see if media recovery was successful. If so, open the database. For example, enter the following command: ALTER DATABASE OPEN;
For example, enter the following command to take users offline: SQL "ALTER TABLESPACE users OFFLINE IMMEDIATE"; 3. Use the SHOW command to see which channels are preconfigured. For example, enter the following command (sample output is included): SHOW ALL;
RMAN configuration parameters for database with db_unique_name PROD1 are: . . . CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DEVICE TYPE SBT_TAPE PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so"; If the necessary devices and channels are already configured, then no action is necessary. Otherwise, you can use the CONFIGURE command to configure automatic channels, or include ALLOCATE CHANNEL commands within a RUN block. 4. If restoring password-protected encrypted backups, then specify the password. Use the SET DECRYPTION IDENTIFIED BY command to specify a password for password-protected backups, as shown in the following example (where password represents the actual password that you enter): SET DECRYPTION IDENTIFIED BY password; 5. Restore and recover the tablespace. Do one of the following: If you are restoring datafiles to their original locations, then run the RESTORE TABLESPACE and RECOVER TABLESPACE commands at the RMAN prompt. For example, enter the following command if automatic channels are configured (sample output included): RMAN> RESTORE TABLESPACE users;
Starting restore at 20-JUN-06 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=37 device type=DISK allocated channel: ORA_SBT_TAPE_1 channel ORA_SBT_TAPE_1: SID=38 device type=SBT_TAPE channel ORA_SBT_TAPE_1: Oracle Secure Backup
channel ORA_DISK_1: starting datafile backup set restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set channel ORA_DISK_1: restoring datafile 00012 to /disk1/oracle/dbs/users01.f channel ORA_DISK_1: restoring datafile 00013 to /disk1/oracle/dbs/users02.f channel ORA_DISK_1: restoring datafile 00021 to /disk1/oracle/dbs/users03.f channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_nnndf_TAG20070620T 105435_29jflwor_.bkp channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_nnndf_TAG20 070620T105435_29jflwor_.bkp tag=TAG20070620T105435
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 20-JUN-06
starting media recovery archived log for thread 1 with sequence 27 is already on disk as file /disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_27_29jjmtc9_.ar c archived log for thread 1 with sequence 28 is already on disk as file /disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_28_29jjnc5x_.ar c . . . channel ORA_DISK_1: starting archived log restore to default destination channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=5 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=6 channel ORA_DISK_1: restoring archived log archived log thread=1 sequence=7 . . . channel ORA_DISK_1: reading from backup piece /disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20070620T 113128_29jhr197_.bkp channel ORA_DISK_1: piece handle=/disk1/oracle/work/orcva/TKRM/backupset/2007_06_20/o1_mf_annnn_TAG20 070620T113128_29jhr197_.bkp tag=TAG20070620T113128 channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jkdvjq _.arc thread=1 sequence=5 channel default: deleting archived log(s) archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_5_29jkdvjq
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
_.arc RECID=91 STAMP=593611179 archived log file name=/disk1/oracle/work/orcva/TKRM/archivelog/2007_06_20/o1_mf_1_6_29jkdvbz _.arc thread=1 sequence=6 channel default: deleting archived log(s) . . . media recovery complete, elapsed time: 00:00:01 Finished recover at 20-JUN-06 If you are restoring some datafiles to new locations, then execute RESTORE TABLESPACE and RECOVER TABLESPACE in a RUN command. Use the SET NEWNAME to rename datafiles. The following example restores the datafiles in tablespaces users to a new location, and then performs recovery. Assume that the old datafiles were stored in the /disk1 path and the new ones will be stored in the /disk2 path. RUN { # specify the new location for each datafile SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users01.f' TO '/disk2/users01.f'; SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users02.f' TO '/disk2/users02.f'; SET NEWNAME FOR DATAFILE '/disk1/oracle/dbs/users03.f' TO '/disk2/users03.f'; RESTORE TABLESPACE users; SWITCH DATAFILE ALL; # update control file with new filenames
RECOVER TABLESPACE users; } 6. Examine the output to see if recovery was successful. If so, bring the recovered tablespace back online. For example, enter the following command: SQL "ALTER TABLESPACE users ONLINE";
2. If the database is open, then take the tablespace requiring recovery offline. For example, enter the following command to take datafile 4 offline: SQL "ALTER DATABASE DATAFILE 4 OFFLINE"; 3. Switch the offline datafile to the latest copy. For example, enter the following command to point the control file to the latest image copy of datafile 4: SWITCH DATAFILE 4 TO COPY; 4. Recover the datafile with the RECOVER DATAFILE command. For example, enter the following command (sample output included): RECOVER DATAFILE 4; RMAN automatically restores a rchived redo logs and incremental backups. Because the database uses a flash recovery area, RMAN automatically deletes them after they have been applied. 5. Examine the output to see if recovery was successful. If so, bring the recovered datafile back online. For example, enter the following command to bring datafile 4 online: SQL "ALTER DATABASE DATAFILE 4 ONLINE";
www.wilshiresoft.com [email protected]
www.wilshiresoft.com [email protected]
Note: Each block is recovered independently during block media recovery, so recovery may be successful for a subset of blocks.
When RMAN first detects missing or corrupt redo record s during block media recovery, it does not immediately signal an error because the block undergoing recovery may become a newed block later in the redo stream. When a block is newed all previous redo for that block becomes irrelevant because the redo applies to an old incarnation of the block. For example, the database can new a block when users drop or truncate a table and then use the block for other data.
For example, you may discover the following messages in a user trace file: ORA-01578: ORACLE data block corrupted (file # 7, block # 3) ORA-01110: data file 7: '/oracle/oradata/trgt/tools01.dbf' ORA-01578: ORACLE data block corrupted (file # 2, block # 235) ORA-01110: data file 2: '/oracle/oradata/trgt/undotbs01.dbf' In the following procedure, you identify the blocks that require recovery and then use any available backup to perform the restore and recovery of these blocks.To recover specific data blocks:
www.wilshiresoft.com [email protected]
1. Obtain the datafile numbers and block numbers of the corrupted blocks. The easiest way to locate trace files and the alert log is to connect SQL*Plus to the target database and execute the following query: SELECT NAME, VALUE FROM V$DIAG_INFO; 2. Start RMAN and connect to the target database, which must be mounted or open. 3. Run the SHOW ALL command to make sure that the appropriate channels are preconfigured. 4. Run the RECOVER ... BLOCK command at the RMAN prompt, specifying the file and block numbers for the corrupted blocks. The following example recovers two blocks. RECOVER DATAFILE 8 BLOCK 13 DATAFILE 2 BLOCK 19; You can also specify various options to control RMAN behavior. The following example indicates that only backups with tag mondayam will be used when searching for blocks. You could use the FROM BACKUPSET option to restrict the type of backup that RMAN searches, or EXCLUDE FLASHBACK LOG to restrict RMAN from searching the flashback logs. RECOVER DATAFILE 8 BLOCK 13 DATAFILE 2 BLOCK 199 FROM TAG mondayam;
www.wilshiresoft.com [email protected]
The auxiliary destination is an optional location on disk which can be used to store any of the auxiliary set datafiles, control files and online redo logs of the auxiliary instance during TSPITR. Files stored here can be deleted after TSPITR is complete. 1. Queries SYS.TS_PITR_CHECK for the tablespaces in the recovery set. If the query returns rows, then RMAN does not proceed with the TSPITR. 2. Creates the auxiliary instance, starts it, and connects to it (if there is no existing auxiliary instance). 3. Takes the tablespaces to be recovered offline in the target database. 4. Restores a backup control file from a point in time before the target time to the auxiliary instance. 5. Restores the datafiles from the recovery set and the auxiliary set to the auxiliary instance.
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
Files are restored either in locations you specify for each file, or the original location of the file (for recovery set files) or in the auxiliary destination (for auxiliary set files, if you used the AUXILIARY DESTINATION argument of RECOVER TABLESPACE). 6. Recovers the restored datafiles in the auxiliary instance to the specified time. 7. Opens the auxiliary database with the RESETLOGS option. 8. Exports the dictionary metadata about objects in the recovered tablespaces to the target database. 9. Shuts down the auxiliary instance. 10. Issues SWITCH commands on the target database instance if new names were given to the datafiles in the recovery set. The target database control file now points to the datafiles in the recovery set that were just recovered at the auxiliary instance. 11. Imports the dictionary metadata from the auxiliary instance to the target instance, allowing the recovered objects to be accessed. 12. Deletes all auxiliary set files. At this point the TSPITR is complete. The recovery set datafiles are returned to their contents a t the specified point in time, and belong to the target database.
partitions of the table.) Tables with VARRAY columns, nested tables, or external files Snapshot logs and snapshot tables Tablespaces containing undo or rollback segments Tablespaces that contain objects owned by SYS, including rollback segments Consequences of TSPITR After TSPITR completes, RMAN recovers the datafiles in the recovery set to the target time. Note the following consequences of TSPITR: If a datafile was added after the point to which RMAN is recovering, then an empty datafile by the same name will be included in the tablespace after RMAN TSPITR. TSPITR will not recover query optimizer statistics for recovered objects. You must gather new statistics after the TSPITR completes. If you run TSPITR on a tablespace and bring the tablespace online at time t, then backups of the tablespace created before time t are no longer usable for recovery with a current control file. You cannot run TSPITR again on this tablespace to recover it to any time less than or equal to time t, nor can you use the current control file to recover the database to any time less than or equal to t. Therefore, you must back up the recovered tablespace as soon as TSPITR is complete.
www.wilshiresoft.com [email protected]
If you have a recovery catalog, then you can perform repeated TSPITR operations to different target times because the catalog contains tablespace history information. If RMAN uses only a control file, however, then it does not have the tablespace history. In this case, RMAN knows only the current set of tablespaces. The tablespace on which TSPITR was performed has a creation time of the time it was brought online. Assume a situation in which you are not using a recovery catalog. You run TSPITR on a tablespace and then bring the tablespace online at 5 p.m. on Friday. Backups of the tablespace created before 5 p.m. Friday are no longer usable for recovery with a current control file. You cannot run TSPITR again on this tablespace with a target time earlier than 5 p.m. Friday, nor can you use the current control file to recover the database to any time earlier than 5 p.m. Friday. Your only option is point-in-time recovery of the entire database using a restored control file. To investigate past states of your data to identify the target time for TSPITR, you can use Oracle Flashback Query, Oracle Transaction Query and Oracle Flashback Version Query to find the point in time when unwanted database changes occurred.
www.wilshiresoft.com [email protected]
INDEX
Page I of VIII
INDEX 1. Introduction to Oracle Net Services..................................................................................................................1 1.1 About Oracle Net Services .............................................................................................................................1 1.2 Connectivity...................................................................................................................................................1 1.2.1 Client/Server Application Connections ......................................................................................................1 1.2.2. Web Client Application Connections ........................................................................................................1 1.3 Prerequisites to Establishing Connectivity.......................................................................................................3 1.4 Alternate Connection using Oracle Net Configuration Assistant .......................................................................4 1.5 Connectivity Concepts ...................................................................................................................................5 1.5.1 Database Service and Database Instance Identification ............................................................................5 1.6 Enhanced Service Accessibility with Multiple Listeners....................................................................................7 1.7 Listener Architecture ......................................................................................................................................9 2. Configuring Naming Methods......................................................................................................................... 11 2.1 Naming Method Configuration Overview ....................................................................................................... 11 2.2 About Connect Descriptors........................................................................................................................... 11 2.3 Naming Methods.......................................................................................................................................... 12 2.3.1 Using the Easy Connect Naming Method................................................................................................ 12 2.3.2 Using Easy Connect Naming on the Client ............................................................................................. 14 2.4 Configuring the Local Naming Method .......................................................................................................... 14 3. Oracle Net Listener Administration ................................................................................................................ 16 3.1 Oracle Net Listener Configuration Overview.................................................................................................. 16 3.1.1 Oracle Net Listener Configuration during Installation............................................................................... 16 3.1.2 Customizing Oracle Net Listener Configuration....................................................................................... 17 3.1.3 Configuring Passwords for Oracle Net Listener....................................................................................... 17 3.1.4 Changing the Oracle Net Listener Password........................................................................................... 17 3.2 Registering Information with a Non-default Listener....................................................................................... 18 3.3 Configuring a Naming Method ...................................................................................................................... 19 3.4 Listener Administration................................................................................................................................. 19 3.4.1 Determining the Current Status of a Listener .......................................................................................... 20 3.4.2 Using the Listener Control Utility to Determine the Listener Status........................................................... 20 3.4.3 Monitoring Services of a Listener ........................................................................................................... 20 4. Distributed Transactions Concepts ................................................................................................................ 21 4.1. What Are Distributed Transactions?............................................................................................................. 21 4.2. Managing a Distributed Database................................................................................................................ 22 4.2.1 Database Links...................................................................................................................................... 22 4.2.2. Why Use Database Links? .................................................................................................................... 24 4.2.3 Global Database Names in Database Links............................................................................................ 24 4.3. Types of Database Links............................................................................................................................. 25 4.4. Creating Database Links ............................................................................................................................. 26 4.4.1. Obtaining Privileges Necessary for Creating Database Links.................................................................. 26 4.4.2 Specifying Link Types ............................................................................................................................ 27 4.4.3 Specifying Link Users ............................................................................................................................ 27 4.4.4. Using Connection Qualifiers to Specify Service Names within Link Names ............................................. 28 4.5. Managing Database Links ........................................................................................................................... 29 4.5.1. Closing Database Links ........................................................................................................................ 29 4.5.2. Dropping Database Links...................................................................................................................... 29 4.5.3. Limiting the Number of Active Database Link Connections ..................................................................... 30 4.6. Viewing Information about Database Links................................................................................................... 30 5. Export and Import ........................................................................................................................................... 31 5.1. Export and Import Utilities ........................................................................................................................... 31 5.2. Before Using Export and Import................................................................................................................... 31 5.2.1. Running catexp.sql or catalog.sql.......................................................................................................... 31 5.2.2. Ensuring Sufficient Disk Space for Export Operations ............................................................................ 32 5.2.3. Verifying Access Privileges for Export and Import Operations................................................................. 32 5.3. Invoking Export and Import as SYSDBA ...................................................................................................... 32 5.4. Restrictions When Using Export's Interactive Method................................................................................... 33 5.5. Getting Online Help..................................................................................................................................... 34
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
Page II of VIII
5.6. Importing Grants ......................................................................................................................................... 34 5.6.1. Grant Conditions................................................................................................................................... 34 5.7. Importing Objects into Other Schemas......................................................................................................... 34 5.7.1. Importing System Objects ..................................................................................................................... 34 5.7.2. Table Objects: Order of Import .............................................................................................................. 35 5.7.3. Importing into Existing Tables ............................................................................................................... 35 5.7.4. Disabling Referential Constraints........................................................................................................... 35 6. Data Pump....................................................................................................................................................... 37 6.1. Data Pump Components ............................................................................................................................. 37 6.2. How Does Data Pump Move Data? ............................................................................................................. 37 6.2.1. Using Data File Copying to Move Data .................................................................................................. 38 6.2.2. Using Direct Path to Move Data ............................................................................................................ 38 6.2.3. Situations in Which Direct Path Load Is Not Used .................................................................................. 38 6.2.4. Situations in Which Direct Path Unload Is Not Used............................................................................... 38 6.2.5. Using Network Link Import to Move Data............................................................................................... 39 6.3. Process during execution of a DATAPUMP job ............................................................................................ 39 6.3.1. Coordination of a Job............................................................................................................................ 39 6.3.2. Tracking Progress within a Job.............................................................................................................. 39 6.3.3. Filtering Data and Metadata during a Job .............................................................................................. 40 6.3.4. Transforming Metadata during a Job ..................................................................................................... 40 6.3.5. Maximizing Job Performance ................................................................................................................ 40 6.3.6. Loading and Unloading of Data ............................................................................................................. 40 6.3.7. Monitoring Job Status ........................................................................................................................... 40 6.3.8. Monitoring the Progress of Executing Jobs ............................................................................................ 41 6.4. File Allocation ............................................................................................................................................. 41 6.4.1. Specifying Files and Adding Additional Dump Files ................................................................................ 41 6.4.2. Default Locations for Dump, Log, and SQL Files.................................................................................... 41 6.5. Setting Parallelism ...................................................................................................................................... 43 6.6. Using Substitution Variables........................................................................................................................ 43 6.7. Moving Data between Different Database Versions...................................................................................... 43 6.8. Data Pump Export....................................................................................................................................... 44 6.8.1. Invoking Data Pump Export................................................................................................................... 44 6.8.2. Data Pump Export Interfaces ................................................................................................................ 44 6.8.3. Data Pump Export Modes ..................................................................................................................... 44 6.8.4. Filtering During Export Operations......................................................................................................... 45 6.9. Data Pump Import....................................................................................................................................... 46 6.9.1. Invoking Data Pump Import................................................................................................................... 46 6.9.2. Data Pump Import Interfaces................................................................................................................. 46 6.9.3. Data Pump Import Modes ..................................................................................................................... 47 7. Introduction to Backup and Recovery ............................................................................................................ 49 7.1. Purpose of Backup and Recovery................................................................................................................ 49 7.1.1. Data Protection..................................................................................................................................... 49 7.1.2. Media Failures...................................................................................................................................... 49 7.1.3. User Errors........................................................................................................................................... 50 7.1.4. Application Errors ................................................................................................................................. 50 7.1.5. Data Preservation ................................................................................................................................. 50 7.1.6. Data Transfer ....................................................................................................................................... 50 7.1.7. Recovery Manager (RMAN) .................................................................................................................. 50 7.1.8. User-managed backup and recovery ..................................................................................................... 50 7.2 Oracle Flashback Technology ...................................................................................................................... 51 7.3 Logical Flashback Features.......................................................................................................................... 52 7.3.1 Oracle Flashback Query ........................................................................................................................ 52 7.3.2 Oracle Flashback Version Query............................................................................................................ 52 7.3.3 Oracle Flashback Transaction Query...................................................................................................... 52 7.3.4 Oracle Flashback Transaction................................................................................................................ 52 7.3.5 Oracle Flashback Table ......................................................................................................................... 52 7.3.6 Oracle Flashback Drop .......................................................................................................................... 52 7.3.7 Flashback Database .............................................................................................................................. 52
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
7.3.8 Data Recovery Advisor .......................................................................................................................... 53 8. User-Managed Database Backups .................................................................................................................. 54 8.1 Querying V$ Views to Obtain Backup Information ......................................................................................... 54 8.1.1 Listing Database Files before a Backup.................................................................................................. 54 8.1.2 Determining Datafile Status for Online Tablespace Backups ................................................................... 54 8.2 Making User-Managed Backups of the Whole Database ............................................................................... 55 8.2.1 Making Consistent Whole Database Backups......................................................................................... 55 8.3 Making User-Managed Backups of Tablespaces and Datafiles ...................................................................... 55 8.3.1 Making User-Managed Backups of Offline Tablespaces and Datafiles ..................................................... 55 8.3.2 Making User-Managed Backups of Online Tablespaces and Datafiles ..................................................... 56 8.3.3 Making User-Managed Backups of Online Read/Write Tablespaces........................................................ 56 8.3.4 Making Multiple User-Managed Backups of Online Read/Write Tablespaces ........................................... 57 8.3.6 Ending a Backup after an Instance Failure or SHUTDOWN ABORT........................................................ 58 8.3.7 Making User-Managed Backups of Read-Only Tablespaces ................................................................... 60 8.4 Making User-Managed Backups of the Control File ....................................................................................... 60 8.4.1 Backing up the Control File to a Binary File............................................................................................. 61 8.4.2 Backing up the Control File to a Trace File ............................................................................................. 61 8.5 Making User-Managed Backups of Archived Redo Logs ............................................................................... 61 9. Recovery Manager (RMAN)............................................................................................................................. 62 9.1 Overview of the RMAN Environment............................................................................................................. 62 9.2 Starting RMAN and Connecting to Database ................................................................................................ 62 Syntax of Common RMAN Command-line Options .......................................................................................... 63 9.3 Showing the Default RMAN Configuration..................................................................................................... 63 9.4 Backing up a Database ................................................................................................................................ 64 9.4.1 Backing up a Database in ARCHIVELOG Mode ..................................................................................... 64 9.4.2 Backing up a Database in NOARCHIVELOG Mode ................................................................................ 64 9.4.3 Typical Backup Options ......................................................................................................................... 64 9.4.4 Making Incrementally Updated Backups ................................................................................................. 65 9.5 Scripting RMAN Operations ......................................................................................................................... 66 9.6 Reporting on RMAN Operations ................................................................................................................... 66 9.6.1 Listing Backups ..................................................................................................................................... 67 9.6.2 Reporting on Database Files and Backups ............................................................................................. 67 9.7 Maintaining RMAN Backups......................................................................................................................... 68 9.7.1 Crosschecking Backups......................................................................................................................... 68 9.7.2 Deleting Obsolete Backups .................................................................................................................... 68 9.8 Diagnosing and Repairing Failures with Data Recovery Advisor .................................................................... 68 9.8.1 Listing Failures and Determining Repair Options..................................................................................... 68 9.8.2 Repairing Failures ................................................................................................................................. 69 9.8.3 Rewinding a Database with Flashback Database.................................................................................... 70 9.9 Restoring and Recovering Database Files .................................................................................................... 70 9.9.1 Preparing to Restore and Recover Database Files.................................................................................. 70 9.9.2 Recovering the Whole Database ............................................................................................................ 71 9.9.3 Recovering Tablespaces........................................................................................................................ 72 9.9.4 Recovering Individual Data Blocks ......................................................................................................... 72 10. Recovery Manager Architecture ................................................................................................................... 73 10.1 About the RMAN Environment.................................................................................................................... 73 10.2 RMAN Command-Line Client ..................................................................................................................... 74 10.3 RMAN Channels ........................................................................................................................................ 74 10.4 Channels and Devices ............................................................................................................................... 75 10.5 Automatic and Manual Channels ................................................................................................................ 75 10.6 RMAN Repository ...................................................................................................................................... 76 10.7 Media Management ................................................................................................................................... 76 10.8 RMAN Interaction with a Media Manager .................................................................................................... 76 10.9 Oracle Secure Backup ............................................................................................................................... 77 10.10 Backup Solutions Program ....................................................................................................................... 77 10.11 Flash Recovery Area................................................................................................................................ 77 10.12 RMAN in a Data Guard Environment ........................................................................................................ 77 10.12.1 RMAN Configuration in a Data Guard Environment ............................................................................. 77
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
Page IV of VIII
10.12.2 RMAN File Management in a Data Guard Environment ....................................................................... 78 10.12.3 Interchangeability of Backups in a Data Guard Environment................................................................ 78 10.12.4 Association of Backups in a Data Guard Environment ......................................................................... 78 10.12.5 Accessibility of Backups in a Data Guard Environment........................................................................ 78 11. Starting and Interacting with the RMAN Client ............................................................................................. 79 11.1 Starting and Exiting RMAN......................................................................................................................... 79 11.2 Specifying the Location of RMAN Output .................................................................................................... 79 11.3 Entering RMAN Commands ....................................................................................................................... 80 11.3.1 Entering RMAN Commands at the RMAN Prompt................................................................................. 80 11.3.2 Using Command Files with RMAN........................................................................................................ 80 11.3.3 Entering Comments in RMAN Command Files...................................................................................... 80 11.3.4 Using Substitution Variables in Command Files .................................................................................... 81 11.4 Checking RMAN Syntax............................................................................................................................. 82 11.4.1 Checking RMAN Syntax at the Command Line ..................................................................................... 82 11.4.2 Checking RMAN Syntax in Command Files .......................................................................................... 82 11.4.3 Making Database Connections with RMAN........................................................................................... 84 11.4.4 Making RMAN Database Connections from the Operating System Command Line ................................ 85 11.4.5 Making Database Connections from the RMAN Prompt ........................................................................ 85 11.4.6 Connecting RMAN to an Auxiliary Database ......................................................................................... 86 11.4.7 Making RMAN Database Connections within Command Files ............................................................... 86 11.5 Diagnosing RMAN Connection Problems.................................................................................................... 87 11.5.1 Diagnosing Target and Auxiliary Database Connection Problems.......................................................... 87 11.5.2 Diagnosing Recovery Catalog Connection Problems............................................................................. 87 12. Configuring the RMAN Environment ............................................................................................................ 88 12.1 Configuring the Environment for RMAN Backups ........................................................................................ 88 12.2 Showing and Clearing Persistent RMAN Configurations .............................................................................. 88 12.3 Configuring the Default Device for Backups: Disk or SBT ............................................................................ 89 12.3.1 Configuring the Default Type for Backups: Backup Sets or Copies ........................................................ 89 12.4 Configuring Channels................................................................................................................................. 89 12.4.1 About Channel Configuration ............................................................................................................... 90 12.4.2 Configuring Channels for Disk .............................................................................................................. 90 12.4.3 Configuring Channel Parallelism for Disk and SBT Devices................................................................... 90 12.4.4 Manually Overriding Configured Channels ............................................................................................ 91 12.5 Configuring Control File & Server Parameter File Autobackups ................................................................... 91 12.5.1 Configuring the Control File Autobackup Format ................................................................................... 91 12.5.2 Overriding the Configured Control File Autobackup Format ................................................................... 92 12.6 Configuring RMAN to Make Backups to a Media Manager........................................................................... 92 12.6.1 Prerequisites for Using a Media Manager with RMAN ........................................................................... 93 12.6.2 Determining the Location of the Media Management Library ................................................................. 93 12.6.3 Configuring Media Management Software for RMAN Backups .............................................................. 93 12.6.4 Testing Whether the Media Manager Library Is Integrated Correctly ...................................................... 94 12.6.5 Testing Backup and Restore Operations on the Media Manager............................................................ 95 12.7 About Media Manager Backup Piece Names .............................................................................................. 95 12.8 Configuring Automatic SBT Channels ......................................................................................................... 96 12.9 Configuring the Flash Recovery Area.......................................................................................................... 96 12.9.1 Overview of the Flash Recovery Area................................................................................................... 96 12.9.2 Oracle Managed Files and Automatic Storage Management ................................................................. 96 12.9.3 How Oracle Manages Disk Space in the Flash Recovery Area .............................................................. 97 12.9.4 Enabling the Flash Recovery Area ....................................................................................................... 97 12.9.5 Considerations When Setting the Location of the Flash Recovery Area ................................................. 98 12.9.6 Setting the Flash Recovery Area Location and Initial Size ..................................................................... 99 12.9.7 Configuring Locations for Control Files and Redo Logs ......................................................................... 99 12.10 Configuring the Backup Retention Policy................................................................................................. 101 12.10.1 Configuring a Redundancy-Based Retention Policy........................................................................... 101 12.10.2 Configuring a Recovery Window-Based Retention Policy .................................................................. 101 12.10.3 Disabling the Retention Policy .......................................................................................................... 102 12.11 Configuring Backup Optimization............................................................................................................ 102 12.11.1 Overview of Backup Optimization ..................................................................................................... 102
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
Page V of VIII
12.12 Configuring an Archived Redo Log Deletion Policy .................................................................................. 104 12.12.1. About Archived Redo Log Deletion Policies ..................................................................................... 104 12.12.2. When the Archived Redo Log Deletion Policy Is Disabled................................................................. 104 12.12.3. When the Archived Redo Log Deletion Policy Is Enabled ................................................................. 104 12.13 Configuring Oracle Flashback Database and Restore Points ................................................................... 105 12.13.1. About Restore Points and Flashback Database................................................................................ 105 12.13.2. Flashback Database ....................................................................................................................... 105 12.13.3 Normal Restore Points ..................................................................................................................... 106 12.13.4 Guaranteed Restore Points .............................................................................................................. 106 12.13.5 Logging for Flashback Database and Guaranteed Restore Points ..................................................... 107 12.13.6 Prerequisites for Flashback Database and Guaranteed Restore Points.............................................. 108 12.13.7 Enabling Flashback Database .......................................................................................................... 109 12.13.8 Creating Normal and Guaranteed Restore Points.............................................................................. 109 12.13.9 Configuring the Environment for Optimal Flashback Database Performance ...................................... 109 13. RMAN Backup Concepts............................................................................................................................. 111 13.1 Consistent and Inconsistent RMAN Backups............................................................................................. 111 13.1.1 Consistent Backups ........................................................................................................................... 111 13.1.2 Inconsistent Backups ......................................................................................................................... 111 13.2 Online Backups and Backup Mode ........................................................................................................... 111 13.3 Backup Sets ............................................................................................................................................ 112 13.3.1 Backup Sets and Backup Pieces........................................................................................................ 112 13.3.2 Compression for Backup Sets ............................................................................................................ 112 13.3.3 Encryption for Backup Sets ................................................................................................................ 112 13.3.4 Filenames for Backup Pieces ............................................................................................................. 113 13.3.5 Number and Size of Backup Pieces.................................................................................................... 113 13.3.6 Number and Size of Backup Sets ....................................................................................................... 113 13.3.7 Multiplexed Backup Sets.................................................................................................................... 113 13.3.8 Proxy Copies ..................................................................................................................................... 114 13.4 Image Copies .......................................................................................................................................... 115 13.4.1 RMAN-Created Image Copies ............................................................................................................ 115 13.4.2 User-Managed Image Copies............................................................................................................. 115 13.5 Multiple Copies of RMAN Backups ........................................................................................................... 116 13.5.1 Duplexed Backup Sets....................................................................................................................... 116 13.6 Backups of Backups................................................................................................................................. 116 13.6.1 Backups of Backup Sets .................................................................................................................... 116 13.6.2 Backups of Image Copies .................................................................................................................. 117 13.7 Control File and Server Parameter File Autobackups ................................................................................ 117 13.7.1 When RMAN Performs Control File Autobackups................................................................................ 117 13.7.2 How RMAN Performs Control File Autobackups.................................................................................. 117 13.8 Incremental Backups................................................................................................................................ 118 13.8.1 Multilevel Incremental Backups .......................................................................................................... 118 13.8.2 Differential Incremental Backups ........................................................................................................ 118 13.8.3 Cumulative Incremental Backups ....................................................................................................... 119 13.9 Block Change Tracking ............................................................................................................................ 119 13.10 Incremental Backup Algorithm ................................................................................................................ 119 13.11 Recovery with Incremental Backups ....................................................................................................... 120 13.12 Backup Retention Policies ...................................................................................................................... 120 13.12.1 Recovery Window............................................................................................................................ 121 13.12.2 Backup Redundancy........................................................................................................................ 121 13.12.3 Batch Deletes of Obsolete Backups.................................................................................................. 122 13.13 Backup Retention Policy and Flash Recovery Area Deletion Rules .......................................................... 122 14. Backing up the Database ............................................................................................................................ 123 14.1 Purpose of RMAN Backups...................................................................................................................... 123 14.2 Basic Concepts of RMAN Backups........................................................................................................... 123 14.3 Specifying Backup Output Options............................................................................................................ 123 14.3.1 Specifying the Device Type for an RMAN Backup ............................................................................... 123 14.3.2 Specifying Backup Set or Copy for an RMAN Backup to Disk .............................................................. 123 14.3.3 Specifying a Format for RMAN Backups............................................................................................. 124
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
Page VI of VIII
14.3.4 Specifying Multiple Formats for Disk Backups..................................................................................... 124 14.4 Specifying Tags for an RMAN Backup ...................................................................................................... 125 14.4.1. About Backup Tags........................................................................................................................... 125 14.4.2. Specifying Tags for Backup Sets and Image Copies .......................................................................... 125 14.5 Making Compressed Backups .................................................................................................................. 126 14.6 Backing up Database Files with RMAN ..................................................................................................... 126 14.6.1 Making Whole Database Backups with RMAN .................................................................................... 126 14.6.2 Backing up Tablespaces and Datafiles with RMAN ............................................................................. 126 14.6.3 Backing up Control Files with RMAN .................................................................................................. 127 14.6.4 Making a Manual Backup of the Control File ....................................................................................... 127 14.6.5 Backing up Server Parameter Files with RMAN .................................................................................. 128 14.6.7 Backing up a Database in NOARCHIVELOG Mode ............................................................................ 128 14.6.8 Backing up Archived Redo Logs with RMAN....................................................................................... 128 14.6.9 Backing Up Only Archived Redo Logs That Need Backups ................................................................. 130 14.7 Making and Updating Incremental Backups .............................................................................................. 131 14.7.1 Purpose of Incremental Backups........................................................................................................ 131 14.7.2 Planning an Incremental Backup Strategy .......................................................................................... 131 14.7.3 Making Incremental Backups ............................................................................................................. 132 14.7.4 Incrementally Updating Backups ........................................................................................................ 132 14.8. Using Block Change Tracking to Improve Incremental Backup Performance............................................. 134 14.8.1. About Block Change Tracking ........................................................................................................... 134 14.8.2 Enabling and Disabling Block Change Tracking .................................................................................. 135 14.8.3 Disabling Block Change Tracking ....................................................................................................... 135 14.8.4 Checking Whether Change Tracking is Enabled ................................................................................. 135 14.8.5 Changing the Location of the Block Change Tracking File ................................................................... 136 14.9 Backing up RMAN Backups...................................................................................................................... 136 14.9.1. About Backups of Backups................................................................................................................ 136 14.9.2 Multiple Copies of Backup Sets .......................................................................................................... 137 14.9.3 Effect of a Backup Retention Policy on Backups of Backups ............................................................... 137 14.9.4 Backing Up Backup Sets with RMAN.................................................................................................. 138 14.9.5 Backing up Image Copy Backups with RMAN ..................................................................................... 139 15. Reporting on RMAN Operations ................................................................................................................. 140 15.1 Purpose of RMAN Reporting .................................................................................................................... 140 15.2 Basic Concepts of RMAN Reporting ......................................................................................................... 140 15.3 Listing Backups and Recovery-Related Objects ........................................................................................ 140 15.3.1. About the LIST Command................................................................................................................. 141 15.3.2 Listing Backups and Copies ............................................................................................................... 141 15.3.3 Listing Selected Backups and Copies ................................................................................................. 144 15.3.4 Listing Database Incarnations ............................................................................................................ 145 15.3.5 Listing Restore Points ........................................................................................................................ 146 15.3.6 Reporting on Backups and Database Schema .................................................................................... 146 15.3.7. Reporting on Files Needing a Backup under a Retention Policy.......................................................... 147 15.3.8. RMAN REPORT NEED BACKUP with Different Retention Policies..................................................... 147 15.3.9. Using RMAN REPORT NEED BACKUP with Tablespaces and Datafiles ............................................ 148 15.3.10. Using REPORT NEED BACKUP with Backups on Tape or Disk Only ............................................... 148 15.3.11. Reporting on Datafiles Affected by Unrecoverable Operations .......................................................... 148 15.3.12. Reporting on Obsolete Backups ...................................................................................................... 148 15.3.13. Reporting on the Database Schema ................................................................................................ 149 15.4 Using V$ Views to Query Backup Metadata .............................................................................................. 150 15.4.1 Querying Details of Past and Current RMAN Jobs .............................................................................. 150 15.4.2 Querying Recovery Catalog Views ..................................................................................................... 151 16. Managing a Recovery Catalog .................................................................................................................... 153 16.1 Purpose of the Recovery Catalog ............................................................................................................. 153 16.2 Basic Concepts for the Recovery Catalog ................................................................................................. 153 16.3 Database Registration.............................................................................................................................. 153 16.4 Centralization of Metadata in a Base Recovery Catalog ............................................................................ 153 16.5 Recovery Catalog Resynchronization ....................................................................................................... 154 16.6 Stored Scripts .......................................................................................................................................... 154
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
16.7 Planning the Size of the Recovery Catalog Schema.................................................................................. 154 16.8 Allocating Disk Space for the Recovery Catalog Database ........................................................................ 154 16.9 Creating the Recovery Catalog Schema Owner ........................................................................................ 155 16.9.1 Executing the CREATE CATALOG Command.................................................................................... 155 16.10 Registering a Database in the Recovery Catalog..................................................................................... 155 16.10.1 Registering a Database with the REGISTER DATABASE Command................................................. 156 16.11 Cataloging Backups in the Recovery Catalog.......................................................................................... 156 16.12 Creating and Managing Virtual Private Catalogs...................................................................................... 157 16.12.1 About Virtual Private Catalogs.......................................................................................................... 157 16.12.2 Creating and Granting Privileges to a Virtual Private Catalog Owner.................................................. 157 16.12.3 Creating a Virtual Private Catalog..................................................................................................... 158 16.12.4 Revoking Privileges from a Virtual Private Catalog Owner ................................................................. 158 16.12.5. Dropping a Virtual Private Catalog................................................................................................... 159 16.12.6. Protecting the Recovery Catalog ..................................................................................................... 159 16.12.7 Backing up the Recovery Catalog..................................................................................................... 159 16.12.7 Separating the Recovery Catalog from the Target Database ............................................................. 160 16.12.8 Exporting the Recovery Catalog Data for Logical Backups ................................................................ 160 16.12.9 Recovering the Recovery Catalog .................................................................................................... 160 16.13 Managing Stored Scripts ........................................................................................................................ 160 16.13.1 About Stored Scripts ........................................................................................................................ 160 16.13.2 Creating Stored Scripts .................................................................................................................... 161 16.13.3 Replacing Stored Scripts.................................................................................................................. 162 16.13.4 Executing Stored Scripts .................................................................................................................. 162 16.13.5 Creating and Executing Dynamic Stored Scripts ............................................................................... 163 16.13.6 Printing Stored Scripts ..................................................................................................................... 164 16.13.7 Listing Stored Script Names ............................................................................................................. 164 16.13.8 Deleting Stored Scripts .................................................................................................................... 164 16.13.10 Executing a Stored Script at RMAN Startup .................................................................................... 165 16.14 Maintaining a Recovery Catalog ............................................................................................................. 165 16.14.1 About Recovery Catalog Maintenance .............................................................................................. 165 16.14.2 Resynchronizing the Recovery Catalog ............................................................................................ 165 16.14.3 About Resynchronization of the Recovery Catalog ............................................................................ 165 16.14.4 Deciding When to Resynchronize the Recovery Catalog ................................................................... 165 16.14.5 Manually Resynchronizing the Recovery Catalog.............................................................................. 167 16.14.6 Updating the Recovery Catalog after Changing a DB_UNIQUE_ NAME ............................................ 167 16.14.7 Unregistering a Target Database from the Recovery Catalog ............................................................ 167 16.14.8 Resetting the Database Incarnation in the Recovery Catalog............................................................. 168 16.15 Recovery Catalog Imports ...................................................................................................................... 169 16.15.1 Prerequisites for Importing a Recovery Catalog ................................................................................ 170 16.15.2 Importing a Recovery Catalog .......................................................................................................... 170 16.16 Moving a Recovery Catalog.................................................................................................................... 170 16.17 Dropping a Recovery Catalog................................................................................................................. 170 17. RMAN Data Repair Concepts ...................................................................................................................... 172 17.1 Overview of RMAN Data Repair ............................................................................................................... 172 17.2 RMAN Data Repair Techniques................................................................................................................ 172 17.3 RMAN Restore Operations....................................................................................................................... 173 17.4 Backup Selection ..................................................................................................................................... 173 17.5 Restore Failover ...................................................................................................................................... 173 17.6 Restore Optimization................................................................................................................................ 174 17.7 RMAN Media Recovery............................................................................................................................ 174 17.8 Selection of Incremental Backups and Archived Redo Logs....................................................................... 174 17.9 Database Incarnations ............................................................................................................................. 174 18. Diagnosing and Repairing Failures............................................................................................................. 176 18.1 Purpose of Data Recovery Advisor ........................................................................................................... 176 18.2 Basic Concepts of Data Recovery Advisor ................................................................................................ 176 18.2.1 User Interfaces to Data Recovery Advisor........................................................................................... 176 18.2.2 Data Integrity Checks......................................................................................................................... 176 18.2.3 Failures ............................................................................................................................................. 177
www.wilshiresoft.com [email protected] Wilshire Software Technologies Ph: 2761-2214 / 5577-2214 Rev. Dt: 10-Oct-08 Version: 6
INDEX
18.2.4 Manual Actions and Automatic Repair Options ................................................................................... 178 18.2.5 Supported Database Configurations ................................................................................................... 178 18.3 Basic Steps of Diagnosing and Repairing Failures .................................................................................... 179 18.3.1 Listing Failures .................................................................................................................................. 179 18.3.2 Listing All Failures.............................................................................................................................. 179 18.3.3 Listing a Subset of Failures ................................................................................................................ 180 18.4 Checking for Block Corruptions by Validating the Database....................................................................... 180 18.5 Determining Repair Options ..................................................................................................................... 182 18.6. Repairing Failures................................................................................................................................... 185 18.6.1. About Repairing Failures................................................................................................................... 185 18.6.2. Repairing a Failure ........................................................................................................................... 185 18.6.3 Changing Failure Status and Priority .................................................................................................. 187 19. Validating Database Files and Backups...................................................................................................... 189 19.1 Purpose of RMAN Validation .................................................................................................................... 189 19.2 Basic Concepts of RMAN Validation ......................................................................................................... 189 19.3 Checking for Block Corruption with the VALIDATE Command ................................................................... 189 19.4 Parallelizing the Validation of a Datafile .................................................................................................... 191 19.5 Validating Backups before Restoring Them............................................................................................... 192 20. Performing Complete Database Recovery.................................................................................................. 193 20.1 Purpose of Complete Database Recovery................................................................................................. 193 20.2 Preparing for Complete Database Recovery ............................................................................................. 193 20.3 Identifying the Database Files to Restore or Recover ................................................................................ 193 20.3.1 Identifying a Lost Control File ............................................................................................................. 193 20.3.2 Identifying Datafiles Requiring Media Recovery .................................................................................. 193 20.3.3 Determining the DBID of the Database ............................................................................................... 195 20.3.4 Previewing Backups Used in Restore Operations................................................................................ 195 20.3.5 Recalling Offsite Backups .................................................................................................................. 196 20.4 Validating Backups before Restoring Them............................................................................................... 197 20.4.1 Restoring Archived Redo Logs Needed for Recovery.......................................................................... 198 20.5 Performing Complete Database Recovery ................................................................................................ 198 20.5.1. About Complete Database Recovery................................................................................................. 198 20.5.2. Performing Complete Recovery of the Whole Database ..................................................................... 199 20.5.3 Performing Complete Recovery of a Tablespace ................................................................................ 201 20.5.4 Performing Complete Recovery of a Datafile after Switching to a Copy................................................ 204 21. Performing Block Media Recovery ............................................................................................................. 206 21.1 Purpose of Block Media Recovery ............................................................................................................ 206 21.2 Basic Concepts of Block Media Recovery ................................................................................................. 206 21.2.1 Identification of Corrupt Blocks........................................................................................................... 206 21.2.2 Missing Redo during Block Recovery.................................................................................................. 207 21.2.3 Prerequisites for Block Media Recovery.............................................................................................. 207 21.2.4 Recovering Individual Blocks.............................................................................................................. 207 21.2.5 Recovering All Blocks in V$DATABASE_BLOCK_CORRUPTION ....................................................... 208 22. Performing RMAN Tablespace Point-in-Time Recovery (TSPITR).............................................................. 209 22.1 Purpose of RMAN TSPTIR....................................................................................................................... 209 22.2 Basic Concepts of RMAN TSPITR............................................................................................................ 209 22.2.1 Basic Steps of RMAN TSPITR ........................................................................................................... 210 22.2.2 Special Considerations When Not Using a Recovery Catalog.............................................................. 211 22.3 Planning and Preparing for TSPITR.......................................................................................................... 211 22.3.1 Choosing the Right Target Time for TSPITR....................................................................................... 211 22.3.2 Determining the Recovery Set............................................................................................................ 212
www.wilshiresoft.com [email protected]