042 nologging 题目

原题如下:
if the tablespace is in the NOLOGGING mode, no operation on the tablespace will generate redo.

这句话是错误的。
很容易从字面上误解了他的意思,my support上有解析到:
nologging影响到的操作有:
1.SQL*Loader的直接导入
2.直接的insert操作,或者是create table|index的命令
3.带有NOCACHE NOLOGGING 含有LOB的对象的装载

同样,只能在database,tablespace,object都NO FORCE LOGGING的情况下才能使用

原文如下:


The Gains and Pains of Nologging Operations [ID 290161.1]

--------------------------------------------------------------------------------

Modified 02-NOV-2008 Type BULLETIN Status PUBLISHED

THE GAINS AND PAINS OF NOLOGGING OPERATIONS
Overview
Whereas a logged INSERT operation has to generate redo for every change data or undo block, nologging operations indicate that the database operation is not logged in the online redo log file. Even though a small invalidation redo record¹ is still written to the online redo log file, nologging operations skip the redo generation of the corresponding inserted data. Nologging can be extremely beneficial for the following reasons:

data written to the redo is minimized dramatically
time to insert into a large table or index or LOB can be reduced dramatically
performance improves for parallel creation of large tables or indices
However, NOLOGGING is intended for configurations in which media recovery or the recovery of the corresponding object is not important. Thus, if the disk or tape or storage media fails, you will not be able to recover your changes from the redo because the changes were never logged.

Nologging operations are invoked by any of the following:

SQL*Loader direct load operations
Direct load INSERT operations from CREATE TABLE | INDEX or INSERT commands
Loading into an object containing LOB data when its object’s segment characteristic is NOCACHE NOLOGGING

For databases in ARCHIVELOG mode, nologging operations can only occur for a particular object if and only if:

Database allows for nologging (ALTER DATABASE NO FORCE LOGGING) and
Tablespace allows for nologging (ALTER TABLESPACE <NAME> NO FORCE LOGGING) and
Object allows for nologging (ALTER TABLE <NAME> NOLOGGING)

This paper will cover the following topics:

examples of nologging operations
prevention of nologging operations
detection of nologging operations on the primary and standby databases
repair of nologged changes on the physical and logical standby databases
Examples of nologging operations
Below is a list of examples that can be used for testing purposes. The database must be in ARCHIVELOG mode and must allow nologging operations to see the effect of nologging changes:

1. insert /*+ APPEND */ into scott.emp select * from sys.emp2;
2. create table emp nologging as select * from sys.emp;
3. create index emp_i on emp(empno) nologging;
4. sqlload operation with unrecoverable option

Prevention of nologging operations
When a standby database exists or if you want all transactions to be recoverable on a database, tablespace or object-wide perspective, it is recommended that you prevent nologging operations by issuing the relevant options. These options include:

ALTER DATABASE FORCE LOGGING (database level) or
ALTER TABLESPACE <NAME> FORCE LOGGING (tablespace level) on the relevant tablespaces you want to protect or
[CREATE | ALTER] TABLE <NAME> LOGGING (example of object level) on the relevant objects you want to protect

This ensures that all transactions are logged and can be recovered through media recovery or Redo Apply or SQL Apply assuming appropriate data type support.

Detection of Nologging Operations On the Primary and Standby Databases
On the primary database, you can monitor for the most recent nologging operation that occurred in the database by issuing the following query:

SELECT NAME, UNRECOVERABLE_CHANGE#,
TO_CHAR (UNRECOVERABLE_TIME,'DD-MON-YYYY HH:MI:SS')
FROM V$DATAFILE;

The above primary database’s query dictates when the most recent nologging operation occurred and when the invalidation redo was written to the redo.

Once Redo Apply (or Media Recovery) processes the invalidation redo, it marks all the corresponding data blocks corrupt. You will detect encounter corrupted blocks on the physical standby database when you query any data that references these data blocks. You will receive the following errors:

ORA-01578: ORACLE data block corrupted (file # 3, block # 514)
ORA-01110: data file 3: '/u01/lto_linux9206/dbs/users.dbf'
ORA-26040: Data block was loaded using the NOLOGGING option

You can proactively catch some of these corrupted blocks on Redo Apply (or media recovery) instance by running DBVERIFY on the data files.

$ dbv file=users.dbf
DBVERIFY - Verification starting : FILE = users.dbf
DBV-00200: Block, dba 12583426, already marked corrupted
DBV-00200: Block, dba 12583427, already marked corrupted
DBV-00200: Block, dba 12583428, already marked corrupted

SQL apply ignores the invalidation redo since it cannot convert it to any reasonable SQL; so, the logical standby will not receive any immediate errors. If future transactions reference the missing data, then apply slave will receive an ORA-01403 in the alert.log. For example, the following UPDATE statement failed on the logical standby because it was referencing “nologged” rows that do not exist on the logical standby database.

LOGSTDBY stmt: update "SCOTT"."NOLOG"
set
"SAL" = 810
where
"EMPNO" = 7369 and
"ENAME" = 'SMITH' and
"JOB" = 'CLERK' and
"MGR" = 7902 and
"HIREDATE" = TO_DATE('17-DEC-80', 'DD-MON-RR') and
"SAL" = 800 and
"COMM" IS NULL and
"DEPTNO" = 20 and
ROWID = 'AAAAAAAAEAAAACRAAA'
LOGSTDBY status: ORA-01403: no data found
LOGSTDBY PID 21733, oracle@dlsun1917 (P004)
LOGSTDBY XID 0x0001.010.00000cf3, Thread 1, RBA 0x038b.00000826.1a4
Tue Nov 2 18:26:51 2004
Errors in file /private/oracle/app/admin/tens/bdump/tens_lsp0_20328.trc:
ORA-12801: error signaled in parallel query server P004
ORA-01403: no data found
LOGSTDBY Reader P003 pid=27 OS id=21729 stopped

Currently in Oracle 9i and Oracle 10gR1, only the primary’s database V$DATAFILE view reflects nologging operations.. In 10gR2, the V$DATAFILE view will be enhanced to include information regarding when an invalidation redo is applied and the aforementioned corrupted blocks are written to the corresponding data file on a Redo Apply (or media recovery or standby) instance.

Repair of Nologged Changes on the Physical and Logical Standby Databases
After a nologged operation on the primary is detected, it is recommended to create a backup immediately if you want to recover from this operation in the future. However there are additional steps required if you have an existing physical or logical standby database. This is crucial if you want to preserve the data integrity of your standby databases.

For a physical standby database, Redo Apply will process the invalidation redo and mark the corresponding data blocks corrupt.

For a physical standby database, follow these steps² to reinstantiate the relevant data files .

1. stop Redo Apply (recover managed standby database cancel)
2. offline corresponding datafile(s) (alter database datafile <NAME> offline drop;)
3. start Redo Apply (recover managed standby database disconnect)
4. copy the appropriate backup datafiles over from the primary database (e.g. use RMAN to backup datafiles and copy them)
5. stop Redo Apply (recover managed standby database cancel)
6. online corresponding data files (alter database datafile <NAME> online;)
7. start Redo Apply (recover managed standby database disconnect)

For a logical standby database, SQL Apply skips over the invalidation redo completely; so, the subsequent corresponding table or index will not be updated. However, future reference to missing data will result in ORA-1403 (no data found). In order to resynchronize the table with the primary table, you need to re-create it from the primary database. Follow the steps described in Oracle Data Guard Concepts and Administration, Chapter 'Managing a Logical Standby Database', and Section 'Adding or Re-Creating Tables On a Logical Standby Database' Basically, you will be using the DBMS_LOGSTDBY.INSTANTIATE_TABLE procedure.

¹Invalidation redo containing information about the nologging operation and the range of blocks it affects.

²Please also refer to the Data Guard Concepts & Administration documentation.


Related


--------------------------------------------------------------------------------
Products
--------------------------------------------------------------------------------

Oracle Database Products > Oracle Database > Oracle Database > Oracle Server - Enterprise Edition
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Oracle中的"append nologging"是一种数据插入方式,它可以在插入数据时不写入日志文件,从而提高数据插入的效率。但是,这种方式也会带来一定的风险,因为如果系统崩溃或出现故障,这些未记录的数据将无法恢复。因此,在使用"append nologging"时需要谨慎考虑,并根据具体情况进行选择。 ### 回答2: 在Oracle数据库中,"append nologging"是一个用于插入数据的选项。当我们使用这个选项时,会告知Oracle不要将数据更改记录的日志信息写入日志文件中。 使用"append nologging"选项有以下几个优点: 1. 提高插入性能:由于不需要将每个插入操作的详细信息写入日志文件,可以大大减少写操作对性能的影响。这对于大批量数据插入操作特别有效,可以显著提高插入速度。 2. 减少日志文件大小:由于没有记录每个插入操作的日志,可以减少日志文件的大小。这对于需要保留日志一段时间的数据库来说,可以显著减少存储空间的使用。 3. 简化恢复过程:由于没有详细的插入操作日志,恢复过程可以更简单。在某些情况下,可以通过简单的回滚操作来还原数据。 然而,使用"append nologging"选项也存在一些风险和限制: 1. 不能进行点恢复:由于没有详细的插入操作日志,当发生故障时无法进行点恢复。如果需要恢复到插入操作之前的状态,只能进行完全恢复。 2. 必须小心使用:"append nologging"选项要谨慎使用,必须仔细评估数据的重要性和对插入操作的恢复需求。如果数据丢失将会造成严重问题,应该避免使用此选项。 3. 仅适用于插入操作:"append nologging"选项只适用于插入操作,对其他数据操作(如更新和删除)无效。 总之,"append nologging"选项是Oracle数据库中一个能够提高插入性能和减少存储空间使用的选项,但使用时需要注意数据的重要性和对插入操作的恢复需求。 ### 回答3: 在Oracle数据库中,"append nologging"是一种表级别的选项,用于指定在数据插入操作中不生成任何日志信息。通过使用"append nologging"选项,可以提高数据插入的性能。 当我们执行插入操作时,默认情况下,Oracle会将插入的数据写入日志文件中,以确保数据的持久性和安全性。然而,对于一些大规模的数据插入操作,特别是对于临时或者不重要的数据,生成日志文件可能会成为性能瓶颈。这时,我们可以选择使用"append nologging"选项,该选项会禁止生成日志文件,从而提高插入操作的性能。 使用"append nologging"选项需要谨慎,因为它可能会导致数据丢失的风险。由于没有生成日志文件,一旦系统发生故障或者崩溃,这些没有被记录的数据将无法恢复。因此,在使用"append nologging"选项时,需要确保数据的重要性和可恢复性,并做好相应的数据备份和恢复策略。 可以通过以下语法在Oracle中使用"append nologging"选项: ``` INSERT /*+ APPEND NOLOGGING */ INTO table_name (column1, column2, ...) VALUES (value1, value2, ...); ``` 在上述语句中,通过在INSERT语句中添加"/*+ APPEND NOLOGGING */"注释来启用"append nologging"选项。然后,我们可以指定要插入的表名和对应的列和值。 需要注意的是,使用"append nologging"选项并不会对查询和更新操作产生影响。它只适用于插入操作,并且仅在一些特定的情况下才建议使用,例如临时表、快速数据装载等。 总之,"append nologging"是Oracle数据库中的一个选项,用于指定在数据插入操作中不生成任何日志信息,从而提高插入操作的性能。但是,需要谨慎使用,并做好相应的数据备份和恢复策略。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值