Oracle体系结构学习笔记
Oracle体系结构学习笔记,oracle database 最重要的是online redo log,ldquo;写rdquo;:检查点进程计算工作负载,来定检查点,
体系结构和备份恢复原理
1 Oracle database 最重要的是online redo log
类比法
controlfile :公司高管
datafile :生产车间
online redo log:财务处
注释:
system表空间是第一生产车间;
当公司高管换了,财务处也需要换;
2 shared pool主要包括:
library cache:放代码(sql,pl/sql,java)
data dictionary cache:放数据字典
注释:
在空间分配上,数据字典是男孩,代码是女孩,oracle server有重男轻女思想,若cache命中率低,要看的是女孩,而非男孩。因为会先给男孩喂奶水。
最近最少使用到代码会被销隐掉,否则,不断的代码进来,shared pool会内存不足。
3 large pool
下列场景需要用到large pool:
用rman备份与恢复;
并行sql;
异步I/O;
共享服务器模式;
注释:
large pool是shared pool的助理,若没有large pool,则会池迁移到shared pool。
4 java pool
是个跑马场,不是放java代码的地方
5 database buffer cache和redo log buffer
1)二者关系:
redo log buffer 画家(描述者)
database buffer cache 模特(被描述者)
2)LGWR只能有一个;DBWR可以有多个
3)oracle爱写日志,不爱写数据块。因为日志的单位是项(200个字节左右),而数据块的单位是块。
4)redo log buffer要么全写,要么全不写;而database buffer cache则悠着点,一次写一点
5)什么时候写日志?
每3秒写
1/3满写
commit的时候写
n M脏数据的时候写
DBWR写之前写
6)什么时候写数据块?
完全检查点事件发生
超时发生(增量检查点)
脏块达到域值(增量检查点)
没有free buffer的时候(对上面一条到补充)
6 oracle是个交易系统,,其交易发生在database buffer cache里。
具体交易:
“读”:server process去data dictionary cache查询,将需要的读到database buffer cache,然后,在PGA构造游标(结果集的指针),每一根指针都指向一个rowid,如果需要排序,连接,一致性读,则只需要对指针进行操作。所以,PGA是用户最直接的使用体验。
“改”: 申请TADDR
记日志
动两边事务槽,加行头锁
“写”:检查点进程计算工作负载,来定检查点,在检查点时,发生检查点事件,当检查点事件发生时逼着DBWRn按块第一次变脏的顺序写出一部份,由于这一部分脏块的写出,会在日志文件产生检查点位置。
7 RBA指针后有日志项,原因有二:
1)整个表空间级下线
2)按块第一次变脏的顺序写
8 用户不直接和oracle server打交道,而是和server process扛上了。
类比:
server process 导购小姐
user process 客人
9 “一根骨头挂点肉”
这俗语可以形容server process 和PGA的关系
骨头:server process
肉 :PGA
“一条绳上的两个蚂蚱”
蚂蚱:SADDR,TADDR
这话是说,新值在写的时候,旧值会跟着被写,同呼吸,共命运。所以,读上来8k,写下去便是16k,总共I/O为24k。
10 透过现象看本质
提交的本质:释放锁,写日志,事务槽进入倒计时
正常关机的本质:
1)关闭JAVA进程(oracle大战java)
2)写检查点
a)将current_scn冻结
b)把data block写下
c)让checkpoint_change#等于current_scn
注释:
select resetlogs_change# a,checkpoint_change# b,current_scn c
from v$database
其中,a a:建库的时间原点
b:写数据块的界,写后,内存中的所有数据块多比b来得大。所以,增量检查点这个会被延迟标识,因为,还没有全部下来。
11 system表空间
1)存放数据字典表
2)包,过程,函数和触发器等pl/sql对象
12 sysaux表空间
1)90%用来收集工作负载
2)10%存放sysman到东西
类比:
生活中,水表,电表,煤气表,这些表上面的度数,都是“逝者如斯夫”,为了比较,合理开支,需要抄表。
13 buffer的四种状态
free:写下去的时候
clean:刚读上来
pinned:特殊的clean,被加了latch,正要用
dirty:被改了
14 RBA指针的碎碎念
方向:总是无缝下移
出生地:控制文件
指向地:日志文件
过帐:对应的数据块已写到数据文件中
active :被RBA覆盖的日志(RBA只有一根)
完全检查点会直接把RBA干到重做日志组的最后一条
15 断电本质:SGA突然没有了,实力崩溃
与断电本质一致的是:
干掉SMON进程(kill -9 PID)
shutdown abort
16 在mount阶段,由SMON去读控制文件,并比较:
1)上次关机的SCN A
上次关机的checkpoint B
2)日志组最后一条的记录 C
RBA指针的位置 D
若正常关机,则 A=B C=D
若不正常关机,则 A>B D>C
这时,就需要派SMON去前滚,按重做日志的记录在内存中重做一遍,直到C=D。
更多Oracle相关信息见Oracle 专题页面 ?tid=12

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

Analysis of the basic principles of the MySQL database management system MySQL is a commonly used relational database management system that uses structured query language (SQL) for data storage and management. This article will introduce the basic principles of the MySQL database management system, including database creation, data table design, data addition, deletion, modification, and other operations, and provide specific code examples. 1. Database Creation In MySQL, you first need to create a database instance to store data. The following code can create a file named "my

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

PHP is a back-end programming language widely used in website development. It has powerful database operation functions and is often used to interact with databases such as MySQL. However, due to the complexity of Chinese character encoding, problems often arise when dealing with Chinese garbled characters in the database. This article will introduce the skills and practices of PHP in handling Chinese garbled characters in databases, including common causes of garbled characters, solutions and specific code examples. Common reasons for garbled characters are incorrect database character set settings: the correct character set needs to be selected when creating the database, such as utf8 or u
