Architecture & Connection

来源:互联网 发布:vmware mac os 联网 编辑:程序博客网 时间:2024/05/21 00:50

 

 

oracle server - instance (sga, background process)

                      - database (control file, data file, redo log file)

grannle : 细粒度, 指 SGA 逻辑上分配的最小单位, 一般是 16M, 只有 SGA 小于 128M 时, 这个细粒度才是 4M.

1. server process :  when a user logs on to the oracle server , a process is created on the computer running the oracle server . ( 输入完用户名密码 ) (dedicated / shared )

2. session : A session is a specific connection of a user to an Oracle server . the session starts when the user is validated by the oracle server , and  it ends when the user

                      logs out or when there is an bonormal termination .

3. server process 与 session 区别 : 首先 session 是逻辑概念, 表示一个会话, 并不直接体现在进程中,  它可以借助 server process 体现在进程中, 一个server process

                                                                    可以对应多个session ( 即 多个 session 共用一个 server process )

4. database file : (1) data file (2)control file (3)on line redo log file (4) parameter file 存储一些参数关于instance的 (5) password file 存储谁有权限开启关闭数据库 ,

                               (6) Archived  redolog file 存储 offline copies of the redo log files

5. memory structure : SGA ( Allocated at instance startup ) PGA ( Allocated when the server process startup ) PGA 不属于 instance

6. shared pool (SGA) : is used to store the most recently executed SQL statments ( library cache ) and the most recently used data definitions (data dictionary cache).

    library cache : SQL area 和 PL/SQL area.

    data dictionary cache : (table, columns, users, privilege)

7. database buffer cache (SGA) : stores copies of data blocks ( disk ) that have been retrieved from the data files .

8. redo log buffer cache (SGA) : records all changes made to the database data blocks . ( primary purpose is recovery )

9. large pool ( opional ) (SGA) : only shared server , 用来存储区分session 等内容.


10 . dedicated server include (PGA) : 
        pga 是一块内存区域, 就跟 SGA 一样,但是同时,它是私有的,只能是对应的 server process 访问

        sort area : userd for any sorts that may be required to process the SQL statement

        Session information : includes user privileges and performance statistics for the session

        Cursor state : Indicates the stage in the processing of the SQL statements that are currently used by the session

        Stack space : contains other session variables

        一些上面说的内容存储在SGA中(如果是shared server ) , 如果有large pool 存储在 large pool中, 否则存储在 share pool中

 

 11. backgroud process ( optional ) :

        RECO : Recovever

        QMNn : Advanced Queuing

         ARCn : Archiver

         LCKn : RAC Lock Manager -- Instance Locks

         LMON : RAC DLM Monitor -- Global Locks

         LMDn : RAC DLM Monitor -- Remote Locks

         CJQ0 : Snapshot Refresh

          Dnnn : Dispatcher

          Snnn : Shared Server

          Pnnn : Parallel Query Slaves

           本次不讨论, 向后补充

        一个非常重要的process ( optional ) Archiver ( ARCn ) : is crucial to recovering a database after the loss of a disk . It automatically archives the online

        redo log before the log can be reused .

        如果选择了 NoArchivelog mode : 为了恢复时数据的完整性, LGWR does not overwrite a redo log group until the checkpoint for that group is complete , 要等待CKPT

        完成以后, LGWR才会重写该 redo log file . ( 等待啊。。等待 ) ( 推荐使用 Archivelog mode )

        这理解错了,即便是使用Archvelog mod模式,也要等待,只不过在覆盖之前,会先将该日志文件备份一遍。

 12. backgroud process ( main )

          DBWn : database writer ,

         

           LGWR : Log Writer .

        

           SMON : system monitor

       

           if the oracle instance fails, any information in the SGA that has not been written to disk is lost, the backgroud process SMON automatically performs instance

           recovery when the database is reopened . (1) 继续执行那些已经在redo log file中执行, 但是实际由于instance failer而没有写入datablock的内容

           (2)opening the database so that users can log on . (3) Rolling back uncommited transactions 以上是按照顺序执行

主要是为了 instance recovery

当 instance recovery 发生时,

1. 前滚, 参考 redo log file, 将已经 commit 的事务重做, 写到磁盘上.

2. 打开 database (所有没有被改动的数据都可以被访问)

3. 回滚 那些没有 commit 的事务, 要被撤销.

            PMON : process monitor The background process PMON cleans up after failed processes  在以下情况 :

                           Rolling back the user's current transaction

                           Releasing all currently held table or row locks

                           Freeing other resources currently reserved by the user

                           Restarts dead dispatchers


当一个用户的进程死掉了, 那么 pmon 就派上用处了.

1. rolling back 这个用户的提交的 tranaction

2. 释放相关的所有的锁.

3. 释放其他相关的资源.

4. 重启 dead dispatchers.           

Checkpoint ( CKPT ) : 检查点是指 DBWn 将所有的修改的 database buffers 中的内容( 包括脏的和干净的 ) 写入 data file时, 触发的一个事件(event )

             使用 Checkpoint的原因 : 1 由于oracle采用的是的算法(LRU) 就是最后被使用原则, 所以那些经常被使用的数据就会一直在内存中存在, 如果没有CKPT, 它们就不会被

                                                          写到磁盘中. 2因为检查点,所有的数据库修改的内容都要写到datafile, 这就有个好处, 就是当需要恢复的时候, 上一个检查点以前的内容不必

                                                          考虑, 因为它们必然都已经写到了 data file了.

             检查点的动作 :  Checkpoint number into the data file headers .

                                         Checkpoint number, log sequence number, archived log names, and system change numbers into thecontrol file.

              CKPT does not write data blocks to disk or redo blocks to the online redo logs .


check point 是为了确认一个标记, 即内存中的脏数据写到磁盘上的一个标记, 这样, 下次恢复时, 就可以从上一个 checkpoint 开始, 因为之前的数据全部都写到磁盘上了, 另外, 如果没有checkpoint 那么由于 buffercache 是最近最少被使用原则, 那么很可能存在这样的数据块, 它永远没有办法写到磁盘里.

checkpoint 写的流程 :

1. check point numbuer into datafile headers.

2. checkpint number log sequence number, archivelog name and system change number into the control file.

 

 13. Logical structure


       tablespaces -> segments -> extents -> blocks ( include )

备注1 :计算机进程连结 : 当是两台主机之间连接时,是通过物理网卡 eth0 来连接, tcp/ip 协议

              如果计算机内部的进程通信 : a . 是ipc 连接,即计算机内部进程之间直接的通信,是通过ipc直接连接。

                                                            b . 也是通过tcp/ip协议进行连接,是通过模拟的网卡 lo 进行的

备注2 : 连接

DML 操作语句的流程

1. 如果要修改的数据不在 databuffer cache 中, 那么 server process 在磁盘中找到该数据, 并拷贝一份到内存中.

2. server process 会给那些修改过的数据上锁, 回滚段内存中保存着修改前的数据, 这样, 如果操作失败, 也可回滚.

3. 改变这些数据为新的值.

4. 修改过的数据块, 在内存中标示为脏数据.

个人总结

本章的主要内容是: 各种概念的了解, 和对体系结构的把握.