Home Database Mysql Tutorial x$kccle视图深入剖析

x$kccle视图深入剖析

Jun 07, 2016 pm 03:56 PM
Analyze go deep view

今天是2014-05-27,实在无聊顺便研究一下x$kccle的内容吧。如下全部是自己分析和实验结果,真实可靠。 1、如何获得v$log的底层表?我们可以通过autotrace完成查看如: SQL set autotrace trace expSQL set linesize 200SQL select * from v$log;Execution Pl

今天是2014-05-27,实在无聊顺便研究一下x$kccle的内容吧。如下全部是自己分析和实验结果,真实可靠。

1、如何获得v$log的底层表?我们可以通过autotrace完成查看如:

SQL> set autotrace trace exp
SQL> set linesize 200
SQL> select * from v$log;

Execution Plan
----------------------------------------------------------
Plan hash value: 2536105608

--------------------------------------------------------------------------------------------
| Id  | Operation                | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT         |                 |     1 |   197 |     0   (0)| 00:00:01 |
|   1 |  NESTED LOOPS            |                 |     1 |   197 |     0   (0)| 00:00:01 |
|*  2 |   FIXED TABLE FULL       | X$KCCLE         |     1 |   148 |     0   (0)| 00:00:01 |
|*  3 |   FIXED TABLE FIXED INDEX| X$KCCRT (ind:1) |     1 |    49 |     0   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("LE"."LEDUP"<>0 AND "LE"."INST_ID"=USERENV(&#39;INSTANCE&#39;))
   3 - filter("RT"."INST_ID"=USERENV(&#39;INSTANCE&#39;) AND "LE"."LETHR"="RT"."RTNUM")

SQL> 
Copy after login

可以知道当我们在查看v$log视图的时候,其实就是查看的x$kccle视图字段信息。查看该视图如下:

SQL> desc x$kccle
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ADDR                                               RAW(8)
 INDX                                               NUMBER
 INST_ID                                            NUMBER  实例号
 LENUM                                              NUMBER  类似group_number
 LESIZ                                              NUMBER  logfile的size,是操作系统的blocks数目
 LESEQ                                              NUMBER  v$log中的SEQUENCE# 
 LEHWS                                              NUMBER
 LEBSZ                                              NUMBER  block size(操作系统的块)
 LENAB                                              NUMBER
 LEFLG                                              NUMBER  表示日志的状态信息
 LETHR                                              NUMBER  v$log中的THREAD# 
 LELFF                                              NUMBER  下一个logfile
 LELFB                                              NUMBER  前一个logfile
 LELOS                                              VARCHAR2(16) low scn类似v$log FIRST_CHANGE#
 LELOT                                              VARCHAR2(20) low time类似v$log  FIRST_TIME
 LENXS                                              VARCHAR2(16) nex scn 类似v$log中下一个logfile的low FIRST_CHANGE#相同
 LENXT                                              VARCHAR2(20) nex time类似v$log中下一个logfile的low FIRST_TIME 相同
 LEPVS                                              VARCHAR2(16) prev scn, 与上一个logfile的low scn 
 LEARF                                              NUMBER  archive link forward 
 LEARB                                              NUMBER   archive link backward 
 LEFNH                                              NUMBER
 LEFNT                                              NUMBER
 LEDUP                                              NUMBER 等同于v$log中members

SQL> 
Copy after login

下面对比一下:

SQL> select * from v$log;    

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
         1          1       2944  104857600          1 YES INACTIVE             121424676 21-MAY-14
         2          1       2945  104857600          1 NO  CURRENT              121427428 21-MAY-14
         3          1       2943  104857600          1 YES INACTIVE             121421889 21-MAY-14

SQL> 

SQL>  select inst_id,lenum,lesiz,leseq,lehws,lebsz,lebsz*lesiz log_size,lenab,leflg,lethr,lelff,lelfb,lelos from x$kccle;

   INST_ID      LENUM      LESIZ      LESEQ      LEHWS      LEBSZ   LOG_SIZE      LENAB      LEFLG      LETHR      LELFF      LELFB LELOS
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------------
         1          1     204800       2944          2        512  104857600     190256          1          1          2          0 121424676
         1          2     204800       2945          1        512  104857600 4294967295          8          1          3          1 121427428
         1          3     204800       2943          2        512  104857600     190256          1          1          0          2 121421889

SQL> 
SQL>  select inst_id,lenum,leseq,lethr,lelot,lenxs,lenxt,lepvs,learf,learb,lefnh,lefnt,ledup from x$kccle;

   INST_ID LENUM LESEQ      LETHR LELOT                LENXS            LENXT                LEPVS                 LEARF      LEARB      LEFNH      LEFNT      LEDUP
---------- ----- ----- ---------- -------------------- ---------------- -------------------- ---------------- ---------- ---------- ---------- ---------- ----------
         1     1  2944          1 05/21/2014 11:26:42  121427428        05/21/2014 11:26:55  121421889                 0          0          1          1          1
         1     2  2945          1 05/21/2014 11:26:55  281474976710655                       121424676                 0          0          2          2          1
         1     3  2943          1 05/21/2014 11:26:30  121424676        05/21/2014 11:26:42  121419052                 0          0          3          3          1

SQL> 
Copy after login

现在单独关注一下leflg字段,当该值为8说明是正在使用的logfile group:

dump出控制文件中的log file信息如下:

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
         1          1         19   52428800        512          2 NO  CURRENT                1013368 27-MAY-14   2.8147E+14
         2          1         17   52428800        512          2 NO  ACTIVE                 1013348 27-MAY-14      1013365 27-MAY-14
         3          1         18   52428800        512          2 NO  ACTIVE                 1013365 27-MAY-14      1013368 27-MAY-14

SQL> oradebug setmypid
Statement processed.
SQL> oradebug dump controlf 12 
Statement processed.
Copy after login


注意:也可以使用alter system set events ‘immediate trace name controlf level 12';完成控制文件的dump操作:

LOG FILE RECORDS
***************************************************************************
 (size = 72, compat size = 72, section max = 16, section in-use = 3,
  last-recid= 17, old-recno = 0, last-recno = 0)
 (extent = 1, blkno = 10, numrecs = 16)
LOG FILE #1:
  name #5: /u01/app/oracle/oradata/RHYS/onlinelog/o1_mf_1_9r1z70w0_.log
  name #6: /u01/app/oracle/fast_recovery_area/RHYS/onlinelog/o1_mf_1_9r1z70z2_.log
 Thread 1 redo log links: forward: 2 backward: 0
 siz: 0x19000 seq: 0x00000013 hws: 0x1 bsz: 512 nab: 0xffffffff flg: 0x8 dup: 2
 Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.000f7675
 Low scn: 0x0000.000f7678 05/27/2014 17:54:08
 Next scn: 0xffff.ffffffff 01/01/1988 00:00:00
LOG FILE #2:
  name #3: /u01/app/oracle/oradata/RHYS/onlinelog/o1_mf_2_9r1z726s_.log
  name #4: /u01/app/oracle/fast_recovery_area/RHYS/onlinelog/o1_mf_2_9r1z7291_.log
 Thread 1 redo log links: forward: 3 backward: 1
 siz: 0x19000 seq: 0x00000011 hws: 0x2 bsz: 512 nab: 0x14 flg: 0x0 dup: 2
 Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.000f75ec
 Low scn: 0x0000.000f7664 05/27/2014 17:54:01
 Next scn: 0x0000.000f7675 05/27/2014 17:54:05
LOG FILE #3:
  name #1: /u01/app/oracle/oradata/RHYS/onlinelog/o1_mf_3_9r1z73jf_.log
  name #2: /u01/app/oracle/fast_recovery_area/RHYS/onlinelog/o1_mf_3_9r1z73lp_.log
 Thread 1 redo log links: forward: 0 backward: 2
 siz: 0x19000 seq: 0x00000012 hws: 0x2 bsz: 512 nab: 0x4 flg: 0x0 dup: 2
 Archive links: fwrd: 0 back: 0 Prev scn: 0x0000.000f7664
 Low scn: 0x0000.000f7675 05/27/2014 17:54:05
 Next scn: 0x0000.000f7678 05/27/2014 17:54:08
Copy after login

对应一下:

SQL> select inst_id,lenum,leseq,lethr,lelot,lenxs,lenxt,lepvs,learf,learb,lefnh,lefnt,ledup from x$kccle;

   INST_ID LENUM LESEQ      LETHR LELOT                LENXS            LENXT                LEPVS                 LEARF      LEARB      LEFNH      LEFNT      LEDUP
---------- ----- ----- ---------- -------------------- ---------------- -------------------- ---------------- ---------- ---------- ---------- ---------- ----------
         1     1    19          1 05/27/2014 17:54:08  281474976710655                       1013365                   0          0          5          6          2
         1     2    17          1 05/27/2014 17:54:01  1013365          05/27/2014 17:54:05  1013228                   0          0          3          4          2
         1     3    18          1 05/27/2014 17:54:05  1013368          05/27/2014 17:54:08  1013348                   0          0          1          2          2

SQL>  select inst_id,lenum,lesiz,leseq,lehws,lebsz,lebsz*lesiz log_size,lenab,leflg,lethr,lelff,lelfb,lelos from x$kccle;

   INST_ID LENUM      LESIZ LESEQ      LEHWS      LEBSZ   LOG_SIZE      LENAB      LEFLG      LETHR      LELFF      LELFB LELOS
---------- ----- ---------- ----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------------
         1     1     102400    19          1        512   52428800 4294967295          8          1          2          0 1013368
         1     2     102400    17          2        512   52428800         20          0          1          3          1 1013348
         1     3     102400    18          2        512   52428800          4          0          1          0          2 1013365

SQL> 
Copy after login

拿group3做一个分析:如下:

LOG FILE #3:(代表第三个group)
name #1: /u01/app/oracle/oradata/RHYS/onlinelog/o1_mf_3_9r1z73jf_.log(第一个日志文件)
name #2: /u01/app/oracle/fast_recovery_area/RHYS/onlinelog/o1_mf_3_9r1z73lp_.log(第二个日志文件)
Thread 1(线程1x$kccle.lethr) redo log links: forward: 0(对应x$kccle的LELFF为0) backward: 2(对应x$kccle的lelfb为2)
siz: 0x19000(对应x$kccle的lesiz转为10进制正好是102400): seq: 0x00000012(转为10进制为18对应x$kccle的leseq): hws: 0x2(对应x$kccle的lehws为2) bsz: 512(数据块对应x$kccle的lebsz)
nab: 0x4(对应lenab为4) flg: 0x0(对应x$kccle的leflg) dup: 2(对应x$kccle的ledup)
Archive links: fwrd: 0(前一个链表x$kccle的learf) back: 0 (对应x$kccle的learb)Prev scn: 0x0000.000f7664(转为10进制scn为1013348,对应lepvs)
Low scn: 0x0000.000f7675 05/27/2014 17:54:05(对应x$kccle的lelos)
Next scn: 0x0000.000f7678 05/27/2014 17:54:08(对应x$kccle的lenxt)

由此可知x$kccle正式抓取的是控制文件中的内容,这也是为什么数据块在mount状态下,可以查看v$log的原因了。

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 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)

iOS 17's standby mode turns a charging iPhone into a home hub iOS 17's standby mode turns a charging iPhone into a home hub Jun 06, 2023 am 08:20 AM

In iOS 17 Apple is introducing Standby Mode, a new display experience designed for charging iPhones in a horizontal orientation. In this position, the iPhone is able to display a series of full-screen widgets, turning it into a useful home hub. Standby mode automatically activates on an iPhone running iOS 17 placed horizontally on the charger. You can view time, weather, calendar, music controls, photos, and more. You can swipe left or right through the available standby options and then long press or swipe up/down to customize. For example, you can choose from analog view, digital view, bubble font, and daylight view, where the background color changes based on time as time passes. There are some options

How to implement editable tables in Vue How to implement editable tables in Vue Nov 08, 2023 pm 12:51 PM

Tables are an essential component in many web applications. Tables usually have large amounts of data, so tables require some specific features to improve user experience. One of the important features is editability. In this article, we will explore how to implement editable tables using Vue.js and provide specific code examples. Step 1: Prepare the data First, we need to prepare the data for the table. We can use a JSON object to store the table's data and store it in the data property of the Vue instance. In this case

Understand the differences and comparisons between SpringBoot and SpringMVC Understand the differences and comparisons between SpringBoot and SpringMVC Dec 29, 2023 am 09:20 AM

Compare SpringBoot and SpringMVC and understand their differences. With the continuous development of Java development, the Spring framework has become the first choice for many developers and enterprises. In the Spring ecosystem, SpringBoot and SpringMVC are two very important components. Although they are both based on the Spring framework, there are some differences in functions and usage. This article will focus on comparing SpringBoot and Spring

How to use CodeIgniter4 framework in php? How to use CodeIgniter4 framework in php? May 31, 2023 pm 02:51 PM

PHP is a very popular programming language, and CodeIgniter4 is a commonly used PHP framework. When developing web applications, using frameworks is very helpful. It can speed up the development process, improve code quality, and reduce maintenance costs. This article will introduce how to use the CodeIgniter4 framework. Installing the CodeIgniter4 framework The CodeIgniter4 framework can be downloaded from the official website (https://codeigniter.com/). Down

Laravel development: How to generate views using Laravel View? Laravel development: How to generate views using Laravel View? Jun 14, 2023 pm 03:28 PM

Laravel is one of the most popular PHP frameworks currently, and its powerful view generation capabilities are impressive. A view is a page or visual element displayed to the user in a web application, which contains code such as HTML, CSS, and JavaScript. LaravelView allows developers to use a structured template language to build web pages and generate corresponding views through controllers and routing. In this article, we will explore how to generate views using LaravelView. 1. What

What are the views in Word? What are the views in Word? Mar 19, 2024 pm 06:10 PM

I guess that many students want to learn the typesetting skills of Word, but the editor secretly tells you that before learning the typesetting skills, you need to understand the word views clearly. In Word2007, 5 views are provided for users to choose. These 5 views include pages. View, reading layout view, web layout view, outline view and normal view, let’s learn about these 5 word views with the editor today. 1. Page view Page view can display the appearance of the print result of the Word2007 document, which mainly includes headers, footers, graphic objects, column settings, page margins and other elements. It is the page view closest to the print result. 2. Reading layout view Reading layout view displays Word2007 documents and Office in the column style of a book

In-depth analysis of MySQL password encryption method In-depth analysis of MySQL password encryption method Jun 15, 2023 pm 09:24 PM

With the development of the Internet, MySQL, as an open source relational database management system, is widely used in various applications. One of the important security issues is the encryption and storage of MySQL user passwords. So, what are the methods for MySQL password encryption? This article will give you an in-depth analysis. How MySQL passwords are stored Before understanding the MySQL password encryption method, let’s first understand how MySQL passwords are stored. Before MySQL version 5.7, the one-way hash algorithm (S

Concise and easy to understand: in-depth analysis of the meaning of pip protocol Concise and easy to understand: in-depth analysis of the meaning of pip protocol Feb 02, 2024 pm 01:10 PM

To deeply analyze the meaning of the pip protocol, specific code examples are required. Introduction: In the Python world, pip (i.e. pipinstall) is our preferred way to install and manage third-party libraries. It is a Python package management tool. It is widely used in the development process because of its simplicity, efficiency, ease of use and convenience. This article will deeply analyze the meaning of the pip protocol, demonstrate the important role and usage of pip through specific code examples, and help readers better understand and use pip. 1. pip protocol

See all articles