Unix/Linux中oracle数据库进程采用多进程模式,如我们可以在系统进程列表中看到pmon,smon,dbwr,lgwr,ckpt等oracle系统进程。随着oracle数据库功能增多,进程数量也随之增加,创建进程的开销以及进程上下文切换的开销也越来越大(进程状态切换 switching 是要直接硬件CPU资源),多线程结构中,线程切换在用户空间通过库函数实现,开销不在一个量级。所以,在oracle 12c中,有一个关于多线程的参数:threaded_execution,默认为false。启用的话,将其设置为true。启用之后,有如下变化:
1.进程数变少:
之前:
[oracle@ol6-121-rac2 diag]$ ps -ef |grep ora_ oracle 7562 1 0 14:54 ? 00:00:00 ora_pmon_cdbrac_1 oracle 7564 1 0 14:54 ? 00:00:00 ora_psp0_cdbrac_1 oracle 7567 1 4 14:54 ? 00:00:20 ora_vktm_cdbrac_1 oracle 7571 1 0 14:54 ? 00:00:00 ora_gen0_cdbrac_1 oracle 7573 1 0 14:54 ? 00:00:00 ora_mman_cdbrac_1 oracle 7577 1 0 14:54 ? 00:00:00 ora_diag_cdbrac_1 oracle 7579 1 0 14:54 ? 00:00:00 ora_dbrm_cdbrac_1 oracle 7581 1 0 14:54 ? 00:00:00 ora_ping_cdbrac_1 oracle 7583 1 0 14:54 ? 00:00:00 ora_acms_cdbrac_1 oracle 7585 1 0 14:54 ? 00:00:01 ora_dia0_cdbrac_1 oracle 7587 1 0 14:54 ? 00:00:00 ora_lmon_cdbrac_1 oracle 7589 1 0 14:54 ? 00:00:04 ora_lmd0_cdbrac_1 oracle 7591 1 0 14:54 ? 00:00:03 ora_lms0_cdbrac_1 oracle 7595 1 0 14:54 ? 00:00:00 ora_rms0_cdbrac_1 oracle 7597 1 0 14:54 ? 00:00:00 ora_lmhb_cdbrac_1 oracle 7599 1 0 14:54 ? 00:00:02 ora_lck1_cdbrac_1 oracle 7601 1 0 14:54 ? 00:00:00 ora_dbw0_cdbrac_1 oracle 7603 1 0 14:54 ? 00:00:00 ora_lgwr_cdbrac_1 oracle 7605 1 0 14:54 ? 00:00:00 ora_ckpt_cdbrac_1 oracle 7607 1 0 14:54 ? 00:00:00 ora_smon_cdbrac_1 oracle 7609 1 0 14:54 ? 00:00:00 ora_reco_cdbrac_1 oracle 7611 1 0 14:54 ? 00:00:00 ora_lreg_cdbrac_1 oracle 7613 1 0 14:54 ? 00:00:00 ora_rbal_cdbrac_1 oracle 7615 1 0 14:54 ? 00:00:00 ora_asmb_cdbrac_1 oracle 7617 1 0 14:54 ? 00:00:01 ora_mmon_cdbrac_1 oracle 7621 1 0 14:54 ? 00:00:00 ora_gcr0_cdbrac_1 oracle 7623 1 0 14:54 ? 00:00:00 ora_mmnl_cdbrac_1 oracle 7625 1 0 14:54 ? 00:00:00 ora_d000_cdbrac_1 oracle 7627 1 0 14:54 ? 00:00:00 ora_s000_cdbrac_1 oracle 7629 1 0 14:54 ? 00:00:00 ora_lck0_cdbrac_1 oracle 7634 1 0 14:54 ? 00:00:00 ora_rsmn_cdbrac_1 oracle 7644 1 0 14:54 ? 00:00:00 ora_ppa7_cdbrac_1 oracle 7668 1 0 14:54 ? 00:00:00 ora_mark_cdbrac_1 oracle 8033 1 0 14:55 ? 00:00:00 ora_o000_cdbrac_1 oracle 8038 1 0 14:56 ? 00:00:00 ora_tmon_cdbrac_1 oracle 8040 1 0 14:56 ? 00:00:00 ora_tt00_cdbrac_1 oracle 8042 1 0 14:56 ? 00:00:00 ora_gcr1_cdbrac_1 oracle 8044 1 0 14:56 ? 00:00:00 ora_smco_cdbrac_1 oracle 8046 1 0 14:56 ? 00:00:00 ora_w000_cdbrac_1 oracle 8049 1 0 14:56 ? 00:00:00 ora_gtx0_cdbrac_1 oracle 8054 1 0 14:56 ? 00:00:00 ora_rcbg_cdbrac_1 oracle 8101 1 0 14:56 ? 00:00:00 ora_aqpc_cdbrac_1 oracle 8126 1 3 14:56 ? 00:00:11 ora_p000_cdbrac_1 oracle 8188 1 0 14:56 ? 00:00:00 ora_o001_cdbrac_1 oracle 8247 1 1 14:56 ? 00:00:04 ora_p001_cdbrac_1 oracle 8249 1 0 14:56 ? 00:00:00 ora_p002_cdbrac_1 oracle 8251 1 0 14:56 ? 00:00:00 ora_p003_cdbrac_1 oracle 8302 1 0 14:56 ? 00:00:00 ora_qm02_cdbrac_1 oracle 8304 1 0 14:56 ? 00:00:00 ora_qm05_cdbrac_1 oracle 8306 1 0 14:56 ? 00:00:00 ora_q002_cdbrac_1 oracle 8310 1 0 14:56 ? 00:00:00 ora_q004_cdbrac_1 oracle 8327 1 0 14:56 ? 00:00:00 ora_ppa6_cdbrac_1 oracle 8663 1 1 14:56 ? 00:00:02 ora_cjq0_cdbrac_1 oracle 8708 1 0 14:56 ? 00:00:00 ora_p004_cdbrac_1 oracle 8710 1 0 14:56 ? 00:00:00 ora_p005_cdbrac_1 oracle 9052 1 0 14:58 ? 00:00:00 ora_q003_cdbrac_1 oracle 9118 1 0 14:59 ? 00:00:00 ora_p006_cdbrac_1 oracle 9120 1 0 14:59 ? 00:00:00 ora_p007_cdbrac_1 oracle 9294 7647 0 15:01 pts/0 00:00:00 grep ora_ [oracle@ol6-121-rac2 diag]$
之后:
[oracle@ol6-121-rac1 admin]$ ps -ef |grep ora_ oracle 10514 1 0 14:59 ? 00:00:00 ora_pmon_cdbrac_1 oracle 10516 1 0 14:59 ? 00:00:00 ora_psp0_cdbrac_1 oracle 10548 1 3 14:59 ? 00:00:13 ora_vktm_cdbrac_1 oracle 10552 1 2 14:59 ? 00:00:07 ora_u004_cdbrac_1 oracle 10558 1 7 14:59 ? 00:00:28 ora_u005_cdbrac_1 oracle 10563 1 0 14:59 ? 00:00:00 ora_ping_cdbrac_1 oracle 10569 1 0 14:59 ? 00:00:02 ora_u010_cdbrac_1 oracle 10578 1 0 14:59 ? 00:00:00 ora_dbw0_cdbrac_1 oracle 11244 9828 0 15:05 pts/0 00:00:00 grep ora_ [oracle@ol6-121-rac1 admin]$
2. 必须网络登录,不能本地验证:
[oracle@ol6-121-rac1 admin]$ sqlplus "sys/oracle@CDBRAC as sysdba" SQL*Plus: Release 12.1.0.1.0 Production on Wed Dec 9 15:04:33 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Advanced Analytics and Real Application Testing options SQL> SQL>
3. 可以不同实例不同值:
SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- cdbrac_1 SQL> show parameter thread NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ parallel_threads_per_cpu integer 2 thread integer 0 threaded_execution boolean TRUE SQL> SQL> select instance_name from v$instance; INSTANCE_NAME ---------------- cdbrac_2 SQL> show parameter thread NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ parallel_threads_per_cpu integer 2 thread integer 0 threaded_execution boolean FALSE SQL>
4. listener相关修改:
当threaded_execution这个字被设置成true后,在listener.ora文件中,需要加上:
DEDICATED_THROUGH_BROKER_[listener-name]=ON。
参考:
http://docs.oracle.com/database/121/REFRN/GUID-7A668A49-9FC5-4245-AD27-10D90E5AE8A8.htm#REFRN10335
http://docs.oracle.com/database/121/CNCPT/process.htm#CNCPT1245