Home Database Mysql Tutorial archive log文件大小与redo log文件大小关系探究

archive log文件大小与redo log文件大小关系探究

Jun 07, 2016 pm 03:21 PM
redo log

首先我们来看下什么是archive log file,oracle 11g 的concept中是这样定义的:When you enable archiving of the online redo l

首先我们来看下什么是archive log file,Oracle 11g 的concept中是这样定义的:When you enable archiving of the online redo logs, Oracle Database copies the online redo log files to another location before they are overwritten. These copied files are referred to as archived redo log files. 那么根据这个定义,archive log file就是redo log file的拷贝,既然是拷贝,在排除压缩的情况下,两种文件的大小应该是一致的。但是我们在真实环境中看到的archive log file就是redo log file却不是一样大,真实情况是archive log file比redo log file小,极端情况下,甚至会小非常多。

引起archive log file就是redo log file大小不一致的原因大致有如下几种:

一、人为操作类型

1、SQL>alter system switch logfile;

2、SQL>alter system archive log current;

3、RMAN>backup archive log all;

4、RMAN>backup database plus archivelog;

二、参数设置类型

archive_lag_target:日志切换的强制时间间隔,即只要到达该参数设置的时间间隔,无论redo 文件是否写满,都会进行日志切换。

三、oracle bug类型

BUG 9272059、BUG 10354739、BUG 12317474、BUG 5450861、BUG 7016254

下面对archive log file就是redo log file大小不一致的原因进行分析,首先,如果redo log file中是以空白结尾,那么,archive log file中会将末尾的空白去除,这就样就会出现archive log比redo log file小,具体小多少,就根据归档时redo log file末尾的空白大小决定。这种情形常见于前面提到的认为操作类型和参数设置类型。因为在进行强制切换日志的时候,redo log file是没有被写满的,文件的末尾必然存在空白。

另外,日志切换并不是发生redo log file 100%满的时候,这是由于oracle的内部算法决定的,这样做的主要目的是处于性能的考虑。所以redo log file始终不会被100%的写满,在进行归档的时候,末尾的空白会被丢弃,所以就导致了archive log file小于redo log file。影响redo log切换时间的因素有:LOG_BUFFER_SIZE参数设置、系统负载、log file size、logfile 空间分配算法。

CUP_COUNT值会影响logfile空间分配算法,所以,如果出现日志频繁切换且归档日志远小于redo log file的情况,请检查CUP_COUNT是否符合系统的实际情况。

再次,如果是RAC环境,如果各节点的负载不一致,为了保证数据库的可恢复性,空闲节点会进行一些的日志切换,主要是为了增进redo 日志的FIRST_CHANGE#,空闲节点产生的归档日志大小会与redo file大小有较大差距。下面进行验证:


--查看redo file大小
 
SQL> select thread#,group#,bytes/1024/1024 "size" from v$log order by 1,2;

  THREAD# GROUP# size

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

    1 1 50

    1 2 50

    2 3 50

    2 4 50

  --在节点1上建立测试表

 SQL> create table darren(id number,item varchar2(2));

 --查看当前的归档情况和redo log的FRIST_CHANGE#

 SQL> select thread#,name,blocks*block_size/1024/1024 "size" from v$archived_log order by 1,2;

  THREAD#                            NAME                                          size

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

    1          +DATADG01/gyl/archivelog/2014_10_23/thread_1_seq_10.268.861729569 1.4453125

    1          +DATADG01/gyl/archivelog/2014_10_23/thread_1_seq_11.270.861730475 49.9980469

    1          +DATADG01/gyl/archivelog/2014_10_23/thread_1_seq_12.271.861730509 49.9980469

    1          +DATADG01/gyl/archivelog/2014_10_23/thread_1_seq_13.272.861730545 49.9980469

    1          +DATADG01/gyl/archivelog/2014_10_23/thread_1_seq_14.274.861730573 49.9980469

    1          +DATADG01/gyl/archivelog/2014_10_23/thread_1_seq_15.275.861730601 49.9980469

    1          +DATADG01/gyl/archivelog/2014_10_24/thread_1_seq_16.276.861788401 35.8242188

    2          +DATADG01/gyl/archivelog/2014_10_23/thread_2_seq_2.269.861729571 2.37207031

    2          +DATADG01/gyl/archivelog/2014_10_23/thread_2_seq_3.273.861730551 .008300781

    2          +DATADG01/gyl/archivelog/2014_10_24/thread_2_seq_4.277.861788403 .567871094

 SQL> select GROUP#,THREAD#,SEQUENCE#,STATUS,FIRST_CHANGE# from v$log order by 2;

    GROUP#    THREAD#  SEQUENCE#      STATUS    FIRST_CHANGE#

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

    1            1        17          CURRENT        794878

    2            1        16          INACTIVE      700672

    3            2        5          CURRENT        794876

    4            2        4          INACTIVE      517670

--在节点1上进行事务,由于是测试环境,节点2上完全没事务,是空闲实例

begin

  for i in 1..500000 loop

  insert into darren values(1,'aa');

  commit;

  end loop;

end;

 --查看归档情况和redo log 的FRIST_CHANGE#

SQL> select thread#,name,blocks*block_size/1024/1024 "size" from v$archived_log order by 1,2;

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles