Oracle 数据库如何设置归档模式与非归档模式

数据库 Oracle
本文主要介绍了Oracle数据库中设置归档模式与非归档模式的方法,希望能够对您有所帮助。

Oracle 数据库操作中,数据库可以设置为归档模式非归档模式。归档模式保存所有的事务日志,包括redolog、archivelog等,而非归档模式只记录redolog。我们常常会根据工作的需要将其设置为归档模式和非归档模式,本文我们就介绍它们的设置过程,接下来就让我们一起来了解一下吧。

-、查看oracle归档模式

 

  1. SQL> conn evan/evan  (dba)  
  2.  
  3. Connected.  
  4.  
  5. SQL> archive log list  
  6.  
  7. ORA-01031: insufficient privileges  
  8.  
  9. SQL> conn / as sysdba --archive log list需要以sysdba执行  
  10.  
  11. Connected.  
  12.  
  13. SQL> archive log list  
  14.  
  15. Database log mode              No Archive Mode  
  16.  
  17. Automatic archival             Disabled  
  18.  
  19. Archive destination            USE_DB_RECOVERY_FILE_DEST  
  20.  
  21. Oldest online log sequence     2  
  22.  
  23. Current log sequence           4  
  24.  
  25. 查询v$database  
  26.  
  27. SQL> select name,log_mode from v$database;  
  28.  
  29. NAME      LOG_MODE  
  30.  
  31. --------- ------------  
  32.  
  33. ORALIFE   NOARCHIVELOG 

 

二、修改归档模式

归档日志位置,Oracle 10g可以生成多份一样的日志,保存多个位置,以防不测。

 

  1. SQL> alter system set log_archive_dest_1='location=/oracle/10g/oracle/log/archive_log';  
  2.  
  3. System altered.  
  4.  
  5. SQL> alter system set log_archive_dest_2='location=/oracle/10g/oracle/log/archive_log2';  
  6.  
  7. System altered.  
  8.  
  9. SQL> shutdown immediate  
  10.  
  11. ORA-01031: insufficient privileges  
  12.  
  13. SQL> conn / as sysdba  
  14.  
  15. Connected.  
  16.  
  17. SQL> shutdown immediate  
  18.  
  19. Database closed.  
  20.  
  21. Database dismounted.  
  22.  
  23. ORACLE instance shut down.  
  24.  
  25. SQL> startup mount  
  26.  
  27. ORACLE instance started.  
  28.  
  29. Total System Global Area  528482304 bytes  
  30.  
  31. Fixed Size                  1220360 bytes  
  32.  
  33. Variable Size             163578104 bytes  
  34.  
  35. Database Buffers          356515840 bytes  
  36.  
  37. Redo Buffers                7168000 bytes  
  38.  
  39. Database mounted.  
  40.  
  41. SQL> alter database archivelog; --设置归档模式  
  42.  
  43. Database altered.  
  44.  
  45. SQL> alter database open;  
  46.  
  47. Database altered. 

 

配置归档文件格式(从oracle 10g 开始,必须带有%s,%t,%r)

 

  1. SQL> alter system set log_archive_format="archive_%t_%s_%r.arclog" scope=spfile;  
  2.  
  3. System altered.  
  4.  
  5. SQL> shutdown immediate  
  6.  
  7. Database closed.  
  8.  
  9. Database dismounted.  
  10.  
  11. ORACLE instance shut down.  
  12.  
  13. SQL> startup mount  
  14.  
  15. ORACLE instance started.  
  16.  
  17. Total System Global Area  528482304 bytes  
  18.  
  19. Fixed Size                  1220360 bytes  
  20.  
  21. Variable Size             163578104 bytes  
  22.  
  23. Database Buffers          356515840 bytes  
  24.  
  25. Redo Buffers                7168000 bytes  
  26.  
  27. Database mounted.  
  28.  
  29. SQL> archive log list  --查看是否归档  
  30.  
  31. Database log mode              Archive Mode  
  32.  
  33. Automatic archival             Enabled          --已开启自动归档  
  34.  
  35. Archive destination            /oracle/10g/oracle/log/archive_log2  
  36.  
  37. Oldest online log sequence     2  
  38.  
  39. Next log sequence to archive   4  
  40.  
  41. Current log sequence           4  
  42.  
  43. SQL> select destination from v$archive_dest;  --查看归档日志位置  
  44.  
  45. DESTINATION  
  46.  
  47. --------------------------------------------------------------------------------  
  48.  
  49. /oracle/10g/oracle/log/archive_log  
  50.  
  51. /oracle/10g/oracle/log/archive_log2  
  52.  
  53. 10 rows selected. 

 

还可以配置归档进程个数

 

  1. alter system set log_archive_max_processes=n 

 

三、修改为非归档模式

 

  1. SQL> startup mount  
  2.  
  3. ORACLE instance started.  
  4.  
  5. Total System Global Area  528482304 bytes  
  6.  
  7. Fixed Size                  1220360 bytes  
  8.  
  9. Variable Size             167772408 bytes  
  10.  
  11. Database Buffers          352321536 bytes  
  12.  
  13. Redo Buffers                7168000 bytes  
  14.  
  15. Database mounted.  
  16.  
  17. SQL> alter database noarchivelog;  
  18.  
  19. Database altered.  
  20.  
  21. SQL> alter system set log_archive_dest_1='';  
  22.  
  23. System altered.  
  24.  
  25. SQL> alter system set log_archive_dest_2='';  
  26.  
  27. System altered.  
  28.  
  29. SQL>  alter system set log_archive_dest_10='location=USE_DB_RECOVERY_FILE_DEST'; --恢复为原来  
  30.  
  31. System altered.  
  32.  
  33. SQL> archive log list  
  34.  
  35. Database log mode              No Archive Mode  
  36.  
  37. Automatic archival             Disabled  
  38.  
  39. Archive destination            USE_DB_RECOVERY_FILE_DEST  
  40.  
  41. Oldest online log sequence     6  
  42.  
  43. Current log sequence           8  
  44.  
  45. SQL> shutdown immediate  
  46.  
  47. ORA-01109: database not open  
  48.  
  49. Database dismounted.  
  50.  
  51. ORACLE instance shut down.  
  52.  
  53. SQL> startup mount  
  54.  
  55. ORACLE instance started.  
  56.  
  57. Total System Global Area  528482304 bytes  
  58.  
  59. Fixed Size                  1220360 bytes  
  60.  
  61. Variable Size             167772408 bytes  
  62.  
  63. Database Buffers          352321536 bytes  
  64.  
  65. Redo Buffers                7168000 bytes  
  66.  
  67. Database mounted.  
  68.  
  69. SQL> archive log list  
  70.  
  71. Database log mode              No Archive Mode  
  72.  
  73. Automatic archival             Disabled  
  74.  
  75. Archive destination            USE_DB_RECOVERY_FILE_DEST  
  76.  
  77. Oldest online log sequence     6  
  78.  
  79. Current log sequence           8 

 

关于Oracle 数据库归档模式与非归档模式的设置就介绍这么多,如果您想了解更多关于Oracle数据库的知识,可以看一下这里的文章:http://database.51cto.com/oracle/,相信一定可以带给您收获的!

【编辑推荐】

  1. Oracle数据库基于用户管理的备份与恢复
  2. SQL Server 2008的BI组件SSAS使用详解
  3. Oracle数据库如何增加scott用户与相关的表
  4. Oracle数据库排序ORDER BY子句的使用总结篇
  5. SQL Server数据同步Merge的一个BUG及解决方法
责任编辑:赵鹏 来源: CSDN博客
相关推荐

2010-04-30 16:34:43

Oracle数据库

2010-10-29 15:14:36

Oracle自动归档

2017-06-06 08:10:00

Oracle

2011-08-24 17:08:28

Oracle数据库归档模式

2010-05-10 09:59:47

Oracle手动归档模

2010-10-29 15:07:33

oracle日志

2010-05-07 16:01:21

Oracle归档模式

2010-10-29 14:57:12

Oracle归档模式

2010-05-07 16:13:07

Oracle归档模式

2011-03-28 15:44:45

惠普数据库Oracle数据库

2011-08-02 11:16:08

Oracle数据库归档日志

2010-04-30 16:42:08

Oracle归档模式

2010-04-09 16:40:01

Oracle数据库

2010-11-19 13:28:13

2010-04-02 15:25:40

云归档

2011-03-23 09:31:26

归档日志文件数据库恢复

2021-05-20 08:23:13

Oracle数据库rac启用

2010-10-29 13:30:33

Oracle归档日志

2010-10-29 14:44:35

ORACLE归档日志

2010-04-14 16:09:51

Oracle 10g归
点赞
收藏

51CTO技术栈公众号