Oracle 12c引入了一些大量的新特性,数据库隐藏参数12.2比11.2就多了2000多个, 同时对之前版本的结构也发生了一些变化,虽然不如有些特性像temporary undo\immemory\多租户那么受人重视.如DB_WRITER_PROCESSES DBWR最大进程数从10GR2的20到11gr2的36再到12C R2的100,Archiver Process进程数也从10增加到了30, 还有本篇要讲的Listenr的注册进程的改变. 在12c以前的版本中服务注册一直都是PMON进程负责, 从12c起引入了LREG (listener registration)后台进程接管了这部分工作减轻PMON的工作,同样如果LREG 进程死了实例也会crash.
As with PMON in pre-12c versions, LREG (during registration) process provides the listener with information about the following:
* Names of the database services provided by the database
* Name of the database instance associated with the services and its current and maximum load
* Service handlers (dispatchers and dedicated servers) available for the instance, including their type, protocol addresses, and current and maximum load (for LBA)
listener没有启动LREG进程不能注册服务,LREG但是会每60秒尝试注册,如果local_listener没有配置,LREG会尝试连接默认的1521端口,直到监听进程启动, 如果Listener启动后LREG周期注册前,同样也可以使用”alter system register”立即注册服务.litener的注册信息可以使用listener_registration event dump在lreg trace中.
测试版本 oracle 12.2 EE on OEL6
alter system set events = 'immediate trace name listener_registration level 3';
查看lreg trace文件.
— 未启动listener时 —
*** 2017-02-22T15:58:04.665213+08:00 (CDB$ROOT(1)) kmlwait: status: succ=0, wait=0, fail=1 kmmlrl: listener failure retry: 6002 kmmlrl: 48 processes kmmlrl: instance load 1 kmmlrl_network_hdlr_state: update kmmlrl_network_hdlr_state: update for network '-oracledefault-' kmmlrl_network_hdlr_state: beq handler: load=48, max=299, flag=0x80002002, upd=0x2 kmmlrl: nsgr update returned 0 kmmlrl: nsgr register returned 0 kmlwait: LREG woken up to process network events after 0 cs kmlwait: status: succ=0, wait=0, fail=1 *** 2017-02-22T15:58:07.666581+08:00 (CDB$ROOT(1)) kmlwait: status: succ=0, wait=0, fail=1 ... kmlwait: status: succ=0, wait=0, fail=1 *** 2017-02-22T15:58:58.683514+08:00 (CDB$ROOT(1)) kmlwait: status: succ=0, wait=0, fail=1 *** 2017-02-22T15:59:01.683720+08:00 (CDB$ROOT(1)) kmlwait: status: succ=0, wait=0, fail=1 *** 2017-02-22T15:59:04.684796+08:00 (CDB$ROOT(1)) kmlwait: status: succ=0, wait=0, fail=1 kmmlrl: listener failure retry: 6001 kmmlrl: 48 processes kmmlrl: instance load 1 kmmlrl_network_hdlr_state: update kmmlrl_network_hdlr_state: update for network '-oracledefault-' kmmlrl_network_hdlr_state: beq handler: load=48, max=299, flag=0x80002002, upd=0x2 kmmlrl: nsgr update returned 0 kmmlrl: nsgr register returned 0 kmlwait: LREG woken up to process network events after 0 cs kmlwait: status: succ=0, wait=0, fail=1
# 启动了LISTENRE后
*** 2017-02-22T16:00:04.699377+08:00 (CDB$ROOT(1)) kmlwait: status: succ=0, wait=0, fail=1 kmmlrl: listener failure retry: 6002 kmmlrl: 46 processes kmmlrl: instance load 0 kmmlrl_network_hdlr_state: update kmmlrl_network_hdlr_state: update for network '-oracledefault-' kmmlrl_network_hdlr_state: beq handler: load=46, max=299, flag=0x80002002, upd=0x2 kmmlrl: nsgr update returned 0 kmmlrl: nsgr register returned 0 kmlwait: LREG woken up to process network events after 8 cs kmlwait: status: succ=0, wait=1, fail=0 kmlwait: LREG woken up to process network events after 11 cs kmlwait: status: succ=0, wait=1, fail=0 kmlwait: LREG woken up to process network events after 11 cs kmlwait: status: succ=0, wait=1, fail=0 kmlwait: LREG woken up to process network events after 18 cs kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:00:07.701048+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:00:10.703823+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:00:13.704938+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 ... *** 2017-02-22T16:01:10.723033+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:01:13.724132+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:01:16.725179+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 kmmlrl_disp_check: update for time delta: 60025 kmmlrl: 49 processes kmmlrl: node load 10 kmmlrl_network_hdlr_state: update for network '-oracledefault-' kmmlrl_network_hdlr_state: beq handler: load=49, max=299, flag=0x80002002, upd=0x2 kmmlrl_disp_update_hdlr: D000 load 0 kmmlrl: nsgr update returned 0 kmlwait: LREG woken up to process network events after 0 cs kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:01:19.727075+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 *** 2017-02-22T16:01:22.727602+08:00 (CDB$ROOT(1)) kmlwait: status: succ=1, wait=0, fail=0 Last update: 318704 (14 seconds ago) Flag: 0x4, 0x0 State: succ=1, wait=0, fail=0 CDB: root pdb 1 last pdb 4098 open max pdb 2 Dispatcher configuration index: cur 1 max 1 Network '-oracledefault-' pdb 1 : Local listeners: 0 - (ADDRESS=(PROTOCOL=TCP)(HOST=anbob.com)(PORT=1521)) pdb 1 dci 0 state=1, err=0 nse[0]=0, nse[1]=0, nte[0]=0, nte[1]=0, nte[2]=0 ncre=0 endp=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=anbob.com)(PORT=1521))) flg=0x80000000 nse=0 pri=0x7f4d5ed876f0 hdlr flg=0x4 hdlr map count=0 eflg=0x4 pri=0x7f4d5ed88d98 Remote listeners: Handlers: Dedicated flg=0x80002002, upd=0x2, srvl=3 services=anbob.com, pdbanbob.com, 465fa0ab8243396ae0530338a8c0fc9e.com hdlr load=49, max=299 nam=DEDICATED inf=LOCAL SERVER pri=0x7f4d5ed87208 Local listener 0 pdb 1 flg=0x2, upd=0x8, srvl=3 services=anbob.com, pdbanbob.com, 465fa0ab8243396ae0530338a8c0fc9e.com hdlr load=0, max=0 nam=DEDICATED adr=(ADDRESS=(PROTOCOL=TCP)(HOST=anbob.com)(PORT=1521)) inf=REMOTE SERVER pri=0x7f4d5ed87808 chidx=3 flg=0x1 ccflag=0x0 chidx=2 flg=0x1 ccflag=0x0 chidx=1 flg=0x1 ccflag=0x0 chidx=0 flg=0x1 ccflag=0x0 Listeners: Instance: anbob (PDB 1 flag 0x1 state 1) flg=0x0, upd=0xa info=(INF=(HOST=anbob)(REGION=)(DB_NAME=anbob)(VINST_NAME=)) node load=10, max=5120 inst load=1, max=472 pri=0x7f4d5ed87028 Instance: anbob (PDB 2 flag 0x1 state 1) flg=0x0, upd=0xa info=(INF=(HOST=anbob)(REGION=)(DB_NAME=anbob)(VINST_NAME=)) node load=10, max=5120 inst load=1, max=472 pri=0x7f4d5ed889f0 0 - anbob.com flg=0x104, upd=0x2, pdb=1 goodnes=0, delta=1, pri=0x7f4d5ed871a8 1 - pdbanbob.com flg=0x104, upd=0x0, pdb=3 goodnes=0, delta=0, pri=0x7f4d5ed88ab0 2 - 465fa0ab8243396ae0530338a8c0fc9e.com flg=0x104, upd=0x0, pdb=3 goodnes=0, delta=0, pri=0x7f4d5ed88a50 3 - anbobXDB.com flg=0x105, upd=0x2, pdb=1 goodnes=0, delta=1, pri=0x7f4d5ed87148 Inactive Services: Deleted Services: Service ACLs: Dump ACLs: Handlers: 0 - Dedicated flg=0x2002, upd=0x2, srvl=4 services=anbob.com, pdbanbob.com, 465fa0ab8243396ae0530338a8c0fc9e.com hdlr load=49, max=299 nam=DEDICATED adr=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=/u02/app/oracle/product/12.2.0/db_1/bin/oracle)(ARGV0='oracleanbob')(ARGS='(LOCAL=NO)')) inf=LOCAL SERVER pri=0x7f4d5ed870e8 Dispatcher Handlers: 0 - D000(1) addr=(ADDRESS=(PROTOCOL=tcp)(HOST=anbob.com)(PORT=24297)) inf=DISPATCHER flg=0x1004, upd=0x2, srvl=1 services=anbobXDB.com hdlr load=0, max=1022 nam=D000 adr=(ADDRESS=(PROTOCOL=tcp)(HOST=anbob.com)(PORT=24297)) inf=DISPATCHER pri=0x7f4d5ed87b58 CMON Handlers for Listener Networks: Listen Endpoints: flg=0x80000000, nse=0 lad=, lflg=0x73 pre=HTTPS, sta=12541 mrg=(ADDRESS=(PROTOCOL=TCP)(HOST=anbob.com)(PORT=1521)) pri=0x7f4d5ed88c80 CONH Stats Current: chidx=0, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 chidx=1, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 chidx=2, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 chidx=3, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 CONH Stats Global: chidx=0, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 chidx=1, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 chidx=2, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 chidx=3, num_conn=0, max_num_conn=0 num_disc=0, num_acc=0, num_handlers=0 Per PDB State: pdb 1 state 1 sserv 1 rootparam 0 rootmap 0 pdb 2 state 1 sserv 1 rootparam 1 rootmap 1 pdb 3 state 0 sserv 1 rootparam 1 rootmap 1 ---------------------------- End Registration Information ---------------------------- *** 2017-02-22T16:01:33.929347+08:00 (CDB$ROOT(1))
# 查看1521端口的进程信息
[oracle@anbob trace]$ lsof -iTCP:1521 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ora_lreg_ 4008 oracle 12u IPv4 18960 0t0 TCP anbob.com:45857->anbob.com:ncube-lm (ESTABLISHED) tnslsnr 5255 oracle 8u IPv6 18775 0t0 TCP *:ncube-lm (LISTEN) tnslsnr 5255 oracle 14u IPv6 18961 0t0 TCP anbob.com:ncube-lm->anbob.com:45857 (ESTABLISHED)
Which statement is true about Oracle Net Listener?
A. It acts as the listening endpoint for the Oracle database instance for all local and nonlocal user connections.
B. A single listener can service only one database instance and multiple remote client connections.
C. Service registration with the listener is performed by the process monitor (LREG) process of each database instance.
D. The listener.ora configuration file must be configured with one or more listening protocol addresses to allow remote users to connect to a database instance.
E. The listener.ora configuration file must be located in the ORACLE_HOME/network/admin directly.
【题意简述】
考察了Oracle 12c新特性——LREG进程负责监听器的注册(Listener Registration)。
【考点分析】
Oracle监听器 Net Listener 是一个重要的数据库服务器组件,在整个 Oracle 体系结构中,扮演着重要的作用。它负责管理Oracle 数据库和客户端之间的通讯,它在一个特定的网卡端口 (默认是TCP 1521端口)上监听连接请求,并将连接转发给数据库。
Oracle监听器主要负责下面的几方面功能:
l 监听客户端请求。
l 为客户端请求分配 Server Process
l 注册实例服务
l 错误转移 failover
l 负载均衡
其中,failover和负载均衡都是RAC架构下的功能。
本质上讲,Listener是建立实例和客户端进程之间联系的桥梁。 Listener 与实例之间的联系,就是通过注册的过程来实现的。注册的过程就是实例告诉监听器,它的数据库实例名称instance_name和服务名 service_names。监听器注册上这样的信息,对客户端请求根据监听的注册信息,找到正确的服务实例名称。目前 Oracle提供动态注册和静态注册两种方式。
静态注册就是实例启动时读取 listener.ora 文件的配置,将实例和服务注册到监听程序。无论何时启动一个数据库,默认地都有两条信息注册到监听器中:数据库服务器对应的实例和服务。
动态注册的动作是监听器所在主机上数据库实例完成。实例的后台进程每隔一段时间就会将实例的参 数信息注册到监听器上,实现动态注册。
大家都知道,在Oracle Database 11g以及之前版本,PMON进程负责注册实例服务。而在Oracle Database 12c中,大量新的后台进程被引入进来,其中就包括专门负责注册实例服务的LREG后台进程。
我们节选官方文档中关于PMON 和LREG 的定义,其中专门提到了12c 和之前版本的区别:
“
……
Process Monitor Process (PMON)
The process monitor (PMON) monitors the other background processes and performs process recovery when a server or dispatcher process terminates abnormally.
PMON is responsible for cleaning up the database buffer cache and freeing resources that the client process was using. For example, PMON resets the status of the active transaction table , releases locks that are no longer required, and removes the process ID from the list of active processes.
Listener Registration Process (LREG)
The listener registration process (LREG) registers information about the database instance and dispatcher processes with the Oracle Net Listener. When an instance starts, LREG polls the listener to determine whether it is running. If the listener is running, then LREG passes it relevant parameters. If it is not running, then LREG periodically attempts to contact it.
Note:
In releases before Oracle Database 12c, PMON performed the listener registration.
…… ”
【答案剖析】
A, 监听器负责监听非本地用户的连接请求。例如我们熟知的sqlplus / as sysdba 命令是操作系统用户验证登录方式,通过OS本地的IPC可以直接连接到实例,而IPC由本地OS提供,允许各种进程在主机内进行通信,所以不需要listener也可以连接到实例。所以A错误。
B, 监听器运行在数据库服务器之上,可以与一个 或多个 Oracle 实例相关联,所以 B 错误 。
C, 本质上讲,Listener 是建立实例和客户端进程之间联系的桥梁。 Listener 与实例之间的联系,就是通过注册的过程来实现的。从12c 版本开始,LREG 后台进程负责注册实例服务。所以C正确。
D, 在配置listener.ora时会遇到Host参数,该参数作用就是指定连接的主机地址。我们可以选择IP地址和主机服务器名称。两种方法下,Oracle监听器是采用不同的策略方法。当使用HOST主机名的时候,Oracle监听器会对该计算机上所有的IP地址开启监听动作;如果使用IP地址,监听程序只能监听对应的IP地址。所以D错误。
E, 默认情况下,listener.ora 配置文件存放在ORACLE_HOME/network/admin目录下,但是我们可以修改配置文件的存放路径。以Windows环境为例,我们可以通过定义TNS_ADMIN环境变量来指定listener.ora、tnsnames.ora等配置文件的默认存放路径。所以E错误。
【答案】C
在Oracle Database 12c中,大量新的后台进程被引入进来,很多新特性的实现都和新的进程有关。如:
- Oracle 12c实现了多LGWR管理,这就引入了LG00-LG99一系列的后台进程;
- Oracle 12c扩展了多DBWR支持,BW36~BW99,这一列进程都会提高DBWR的写并行;
- Oracle 12c的多进程多线程模式 - MPMT,引入SCMN进程作为线程监听进程;
下表对这些进程做了一定的梳理和说明,供大家参考。
进程名 | 全名 | 简要描述 | 详细描述 | 组件范畴 |
AQPC | AQ Process Coordinator | Per instance AQ global coordinator | AQPC is responsible for performing administrative tasks for AQ Master Class Processes including commands like starting, stopping, and other administrative tasks. This process is automatically started on instance startup. | Database instances Advanced Queueing |
ARSn | ASM Recovery Slave Process(进程范围 ARS0-ARS9) | Recovers ASM transactional operations | The ASM RBAL background process coordinates and spawns one or more of these slave processes to recover aborted ASM transactional operations. These processes run only in the Oracle ASM instance. | Oracle ASM instances |
BWnn | Database Writer Process | Writes modified blocks from the database buffer cache to the data files | See the Long Description for the DBWn process in this table for more information about the BWnn process. | Database instances |
FENC | Fence Monitor Process | Processes fence requests for RDBMS instances which are using Oracle ASM instances | CSS monitors RDBMS instances which are connected to the Oracle ASM instance and constantly doing I/Os. When the RDBMS instance terminates due to a failure, all the outstanding I/O's from the RDBMS instance should be drained and any new I/O's rejected. FENC receives and processes the fence request from CSSD. | Oracle ASM instances |
GCRn | Global Conflict Resolution Slave Process | Performs synchronous tasks on behalf of LMHB | GCRn processes are transient slaves that are started and stopped as required by LMHB to perform synchronous or resource intensive tasks. | Database instances, Oracle ASM instances, Oracle RAC |
IPC0 | IPC Service Background Process | Common background server for basic messaging and RDMA primitives based on IPC (Inter-process communication) methods. | IPC0 handles very high rates of incoming connect requests, as well as, completing reconfigurations to support basic messaging and RDMA primitives over several transports such as UDP, RDS, InfiniBand and RC. | Oracle RAC |
LDDn | Global Enqueue Service Daemon Helper Slave | Helps the LMDn processes with various tasks | LDDn processes are slave processes spawned on demand by LMDn processes. They are spawned to help the dedicated LMDn processes with various tasks when certain workloads start creating performance bottlenecks. These slave processes are transient as they are started on demand and they can be shutdown when no longer needed. There can be up to 36 of these slave processes (LDD0-LDDz). | Database instances, Oracle ASM instances, Oracle RAC |
LGnn | Log Writer Worker | Writes redo log | On multiprocessor systems, LGWR creates worker processes to improve the performance of writing to the redo log. LGWR workers are not used when there is a SYNC standby destination. Possible processes include LG00-LG99. | Database instances |
LREG | Listener Registration Process | Registers the instance with the listeners | LREG notifies the listeners about instances, services, handlers, and endpoint. | Database instances, Oracle ASM instances, Oracle RAC |
OFSD | Oracle File Server Background Process | Serves file system requests submitted to an Oracle instance | This background process listens for new file system requests, both management (like mount, unmount, and export) and I/O requests, and executes them using Oracle threads. | Database instances, Oracle RAC |
QMnn | AQ Master Class Process | Per instance per AQ Master Class Process | Each of this type of process represents a single class of work item such as AQ notification, queue monitors, and cross process. | Database instances Advanced Queueing |
RM | RAT Masking Slave Process | Extracts and masks bind values from workloads like SQL tuning sets and DB Replay capture files | This background process is used with Data Masking and Real Application Testing. | Database instances |
RMON | Rolling Migration Monitor Process | Manages the rolling migration procedure for an Oracle ASM cluster | The RMON process is spawned on demand to run the protocol for transitioning an ASM cluster in and out of rolling migration mode. | Oracle ASM instance, Oracle RAC |
RPOP | Instant Recovery Repopulation Daemon | Responsible for re-creating and/or repopulating data files from snapshot files and backup files | The RPOP process is responsible for re-creating and repopulating data files from snapshots files. It works with the instant recovery feature to ensure immediate data file access. The local instance has immediate access to the remote snapshot file's data, while repopulation of the recovered primary data files happens concurrently. Any changes in the data are managed between the instance's DBW processes and RPOP to ensure the latest copy of the data is returned to the user. | Database instances |
SAnn |
SGA Allocator (SA00 ~ SAzz) |
Allocates SGA | A small fraction of SGA is allocated during instance startup. The SAnn process allocates the rest of SGA in small chunks. The process exits upon completion of SGA allocation. | Database instances |
SCCn | ASM Disk Scrubbing Slave Check Process | Performs Oracle ASM disk scrubbing check operation | SCCn acts as a slave process for SCRB and performs the checking operations. The possible processes are SCC0-SCC9. | Oracle ASM instances |
SCRB | ASM Disk Scrubbing Master Process | Coordinates Oracle ASM disk scrubbing operations | SCRB runs in an Oracle ASM instance and coordinates Oracle ASM disk scrubbing operations. | Oracle ASM instances |
SCRn | ASM Disk Scrubbing Slave Repair Process | Performs Oracle ASM disk scrubbing repair operation | SCRn acts as a slave process for SCRB and performs the repairing operations. The possible processes are SCR0-SCR9. | Oracle ASM instances |
SCVn | ASM Disk Scrubbing Slave Verify Process | Performs Oracle ASM disk scrubbing verify operation | SCVn acts as a slave process for SCRB and performs the verifying operations. The possible processes are SCV0-SCV9. | Oracle ASM instances |
TTnn | Redo Transport Slave Process | Ships redo from current online and standby redo logs to remote standby destinations configured for ASYNC transport | TTnn can run as multiple processes, where nn is 00 to ZZ. | Database instances, Data Guard |
VUBG | Volume drive Umbilicus Background | Relays messages between Oracle ASM instance and Oracle ASM Proxy instance that is used by ADVM (for ACFS) | Oracle ASM instances, Oracle ASM Proxy instances |
12c 新后台进程 (文档 ID 2102856.1)
Oracle 在线文档提供了完整的后台进程列表:
https://docs.oracle.com/database/121/REFRN/GUID-86184690-5531-405F-AA05-BB935F57B76D.htm#REFRN104
详细信息
* BWnn 可以有1到100个数据库写进程。前36个数据库写进程是 DBW0-DBW9和DBWa-DBWz。第37到100个数据库写进程是 BW36-BW99。数据库为 DB_WRITER_PROCESSES 参数选择一个恰当的默认配置或者基于 CPU 和处理器组的个数调整用户指定的配置。
* FENC (Fence Monitor Process) 为使用 Oracle ASM 实例的 RDBMS 实例处理 fence 请求。
* IPC0 (IPC Service Background Process) 常见后台服务器的基本消息和基于 IPC (进程间通信)方式的 RDMA 原语。
* LDDn (Global Enqueue Service Daemon Helper Slave) 帮助 LMDn 进程处理各种任务。
* LGnn (Log Writer Worker) 在多处理器系统中,LGWR 创建工作进程来提高写重做日志的性能。当存在一个同步备用目的地的时候,不会使用 LGWR 工作进程。可能的进程包括 LG00-LG99。
*LREG (Listener Registration Process) 使用监听器注册实例。
*OFSD (Oracle File Server Background Process) 向 Oracle 实例提交文件系统请求服务。
* RPOP (Instant Recovery Repopulation Daemon) 负责从快照和备份文件中重建 并且/或者 重新填充数据文件。
* SAnn (SGA Allocator) 分配 SGA,SAnn 进程以块分配 SGA。该进程在 SGA 分配完成后退出。
* SCRB (ASM Disk Scrubbing Master Process) 协调 Oracle ASM 磁盘清理操作。
* SCRn (ASM Disk Scrubbing Slave Repair Process) 执行 Oracle ASM 磁盘清理修复操作。
* SCVn (ASM Disk Scrubbing Slave Verify Process) 执行 Oracle ASM 磁盘清理验证操作。