Home Database Mysql Tutorial Oracle 归档模式archivelog

Oracle 归档模式archivelog

Jun 07, 2016 pm 05:08 PM

Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日

查看Oracle数据库是否为归档模式

  1.select name,log_mode from v$database;
  NAME LOG_MODE
  ------------------ ------------------------

  QUERY NOARCHIVELOG


  2.使用ARCHIVE LOG LIST 命令
  Database log mode No Archive Mode
  Automatic archival Disabled
  Archive destination /data/oracle/product/10.2.0/db_1//dbs/arch
  Oldest online log sequence 739
  Current log sequence 741

什么是Oracle归档模式

Oracle数据库有联机重做日志,这个日志是记录对数据库所做的修改,比如插入,删除,更新数据等,对这些操作都会记录在联机重做日志里。一般数据库至少要有2个联机重做日志组。当一个联机重做日志组被写满的时候,就会发生日志切换,这时联机重做日志组2成为当前使用的日志,当联机重做日志组2写满的时候,又会发生日志切换,去写联机重做日志组1,就这样反复进行。


如果数据库处于非归档模式,联机日志在切换时就会丢弃. 而在归档模式下,当发生日志切换的时候,被切换的日志会进行归档。比如,当前在使用联机重做日志1,当1写满的时候,发生日志切换,开始写联机重做日志2,这时联机重做日志1的内容会被拷贝到另外一个指定的目录下。这个目录叫做归档目录,拷贝的文件叫归档重做日志。  

数据库使用归档方式运行时才可以进行灾难性恢复。

  1.归档日志模式和非归档日志模式的区别
  非归档模式只能做冷备份,并且恢复时只能做完全备份.最近一次完全备份到系统出错期间的数据不能恢复.
  归档模式可以做热备份,并且可以做增量备份,可以做部分恢复.
  用ARCHIVE LOG LIST 可以查看当前模式状态时归档模式还是非归档模式.

配置数据库的归档模式

  1.改变非归档模式到归档模式:
  1)SQL> conn / as sysdba (以DBA身份连接数据库)
  2)SQL> shutdown immediate; (立即关闭数据库)
  3)SQL> startup mount (启动实例并加载数据库,,但不打开)
  4)SQL> alter database archivelog; (更改数据库为归档模式)
  5)SQL> alter database open; (打开数据库)
  6)SQL> alter system archive log start; (启用自动归档)
  7)SQL> exit (退出)

  做一次完全备份,因为非归档日志模式下产生的备份日志对于归档模式已经不可用了.这一步非非常重要!


  2.改变归档模式到非归档模式:
  1)SQL>SHUTDOWN NORMAL/IMMEDIATE;
  2)SQL>STARTUP MOUNT;
  3)SQL>ALTER DATABASE NOARCHIVELOG;

  4)SQL>ALTER DATABASE OPEN;


  3.启用自动归档: LOG_ARCHIVE_START=TRUE
  归档模式下,日志文件组不允许被覆盖(重写),当日志文件写满之后,如果没有进行手动归档,那么系统将挂起,知道归档完成为止.
  这时只能读而不能写.
  运行过程中关闭和重启归档日志进程
  SQL>ARCHIVE LOG STOP

  SQL>ARCHIVE LOG START


  4.手动归档: LOG_ARCHIVE_START=FALSE
  归档当前日志文件
  SQL>ALTER SYSTEM ARCHIVE LOG CURRENT;
  归档序号为052的日志文件
  SQL>ALTER SYSTEM ARCHIVE LOG SEQUENCE 052;
  归档所有日志文件
  SQL>ALTER SYSTEM ARCHIVE LOG ALL;
  改变归档日志目标
  SQL>ALTER SYSTEM ARCHIVE LOG CURRENT TO '&PATH';
  5.归档模式和非归档模式的转换
  第4步的逆过程.
  6.配置多个归档进程
  Q:什么时候需要使用多个归档进程?
  A:如果归档过程会消耗大量的时间,那么可以启动多个归档进程,这是个动态参数,可以用ALTER SYSTEM动态修改.
  SQL>ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=10;
  Oracle9i中最多可以指定10个归档进程
  与归档进程有关的动态性能视图
  v$bgprocess,v$archive_processes
  7.配置归档目标,多归档目标,远程归档目标,归档日志格式
  归档目标 LOG_ARCHIVE_DEST_n
  本地归档目标:
  SQL>LOG_ARCHIVE_DEST_1 = "LOCATION=D:ORACLEARCHIVEDLOG";
  远程归档目标:
  SQL>LOG_ARCHIVE_DEST_2 = "SERVICE=STANDBY_DB1";
  强制的归档目标,如果出错,600秒后重试:
  SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_4 = "LOCATION=E:ORACLEARCHIVEDLOG MANDATORY REOPEN=600";
  可选的归档目标,如果出错,放弃归档:
  SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_3 = "LOCATION=E:ORACLEARCHIVEDLOG OPTIONAL";
  归档目标状态:关闭归档目标和打开归档目标
  关闭归档目标1
  SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_1 = DEFER
  打开归档目标2
  SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2 = ENABLE
  归档日志格式
  LOG_ARCHIVE_FORMAT
  8.获取归档日志信息
  V$ARCHIVED_LOG
  V$ARCHIVE_DEST
  V$LOG_HISTORY
  V$DATABASE
  V$ARCHIVE_PROCESSES
  ARCHIVE LOG LIST;

linux

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

See all articles