Oracle11G_R2中共享服务器模式和专用服务器模式参数解释及设置

Posted ritchy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle11G_R2中共享服务器模式和专用服务器模式参数解释及设置相关的知识,希望对你有一定的参考价值。

sys@MYTESTDB> show parameter
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
shared_servers integer 1
max_shared_servers integer
processes integer 150
shared_server_sessions integer
dispatchers string (PROTOCOL=TCP) (SERVICE=MYTESTDBXDB)
max_dispatchers integer
circuits integer

shared_servers
指定了当instance 启动的时候 shared server process 启动的数量,不要将这个参数设置得太大,否者启动数据库instance 的时候就会花更多时间,Oracle启动过后会根据负载来动态调整shared_servers。如果为0,表示数据库没有启动共享服务模式。 这个参数是配置shared server 必须的,而且只有这个参数是必须的。
如果shared_servers=0,则数据库会运行在dedicated模式下。如果shared_servers>0,数据库会运行在shared模式下,如果没有指定dispatchers参数,则oracle自动根据每种protocol创建一个dispatcher。

max_shared_servers
ORACLE在同一个时刻最大能够使用的 shared server process.不要将这个参数设置小于 shared_servers,如果动态修改shared_servers大于max_shared_servers,ORACLE会覆盖max_shared_servers的值,此时你需要修改max_shared_servers.同时也不能大于processes。这个参数是为了给占用很大资源操作而设的(批处理),为了预留一些process 给DBA任务(rman备份)

shared_server_sesions
指定了总共允许的的 shared server session 的数量。如果设置了这个参数,那么就不要将这个值超过sessions,如果没有设置这个值,那么只要还有空闲的session,就可以被使用。设置这个值是为专有连接预留 user sessions.

dispatchers(调度进程)
配置 dispatcher process .如果不设置这个参数,只要设置了shared_servers,oracle 也会自动设置一个基于tcp协议的dispatcher。还需要查看操作系统支持一个dispatcher能处理多少个connections
SQL> select * from v$dispatcher;

max_dispatchers
设置同一时刻能够同时运行的dispatchers的数量,必须大于等于 dispatchers ,小于processes。这个参数也会被dispatchers覆盖。

关闭调度进程:
首先要查询到DISPATCHERS的NAME: SELECT NAME,NETWORK FROM V$DISPATCHER;
然后关闭调度进程:ALTER SYSTEM SHUTDOWN IMMEDIATE ‘D000‘;

circuits(虚拟回路):指定了virtual circuits 的总数量。
SQL> select * from V$CIRCUIT;

关闭共享模式
将 shared_servers 参数置为0(alter system set shared_servers=0;),那么所有以共享方式连接到数据库都不能成功,但是未释放的共享连接会继续 保持连接,直到断开。如果将 shared_servers 和 max_shared_servers 都设为0(alter system set max_shared_servers=0;),那么共享连接将被终结。所有的共享方式连接都断开了的话,就可以使用 alter system set dispatcher=‘‘; 将dispatcher清除,防止下次启动数据库又打开了共享连接方式。

查看shared_servers参数的值判断oracle是共享模式还是专用模式的方法
sys@MYTESTDB> select a.username, a.sid, a.serial#, a.server, a.paddr, a.status, b.program
2 from v$session a left join v$process b
3 on (a.paddr = b.addr)
4 where a.username = ‘SYS‘
5 /

USERNA SID SERIAL# SERVER PADDR STATUS PROGRAM
------ --- ------- --------- ---------------- ------ -----------------------------------
SYS 1 7 DEDICATED 000000008808AFD0 ACTIVE oracle@MYTEST.MYTEST.me (TNS V1-V3)

可以看到SERVER字段是DEDICATED,也就是专用服务器模式

另外
如果是dedicated server,则客户端只能创建dedicated server connection
如果是shared server,则客户端能创建dedicated server connection和shared server connection,只要在service name中指定server=dedicated or server=shared.

#############################################################################################################################################################
alter system set dispatchers=‘(protocol=TCP) (SERVICE=dbposXDB)‘,‘(ADDRESS=(PROTOCOL=TCP)(PORT=5001))‘ sid=‘*‘ scope=both;

ALTER SYSTEM SHUTDOWN IMMEDIATE ‘D000‘;

[oracle@rac1 ~]$ sql
SQL*Plus: Release 11.2.0.3.0 Production on 星期三 8月 28 11:26:28 2019
Copyright (c) 1982, 2011, Oracle. All rights reserved.
连接到: 
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> show parameter dispatcher

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (PROTOCOL=TCP) (SERVICE=testdb
XDB)
max_dispatchers integer
SQL> alter system set dispatchers=‘(protocol=TCP)‘,‘(ADDRESS=(PROTOCOL=TCP)(PORT=5001))‘ sid=‘*‘ scope=both;

alter system set dispatchers=‘(PROTOCOL=TCP) (SERVICE=testdbXDB)‘ sid=‘*‘ scope=both;

系统已更改。

SQL> show parameter dispatcher

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dispatchers string (protocol=TCP), (ADDRESS=(PROT
OCOL=TCP)(PORT=5001))
max_dispatchers integer
SQL>

关闭DISPATCH进程
1 确定要关闭的进程
SELECT NAME, NETWORK FROM V$DISPATCHER;
2 ALTER SYSTEM SHUTDOWN IMMEDIATE ‘D002‘(DISPATCH NAME);

########################################################################################################################################

Shared server模式中,发现dispatcher process可比Shared server process重要的多; kill一个shared server process,顶多只有attach那个进程的session受影响;如果kill一个dispatcher, 被分配给这个dispatcher的所有session都会自动断开。

查看 v$dispatcher可以看每个dispatcher负责多少session.

ORACLE@SQL> select name,OWNED from v$dispatcher;
NAME OWNED
—- ———-
D000 283
D001 285
D002 282

MTS连接,一直查询v$session.paddr,发现并不会变化,说明session自从创建开始就一直存在于该dispatcher的队列中。DISPATCHER的队列模式为 多对一 模式,多个”事务”,
一个CPU (Dispatcher)

通过查看busy rate和queue time,可以判断是否需要更多的dispatcher进程。

Select name, (busy / (busy + idle))*100
"Dispatcher % busy Rate"
From V$DISPATCHER;

NAME Dispatcher % busy Rate
—- ———————-
D000 3.82924217
D001 3.71514979

SELECT d.name,decode(totalq,0,‘No Responses‘,
wait/totalq) "Average Wait time"
FROM V$QUEUE q, V$DISPATCHER d
WHERE q.type = ‘DISPATCHER‘
AND q.paddr = d.paddr;

NAME Average Wait time (单位为1/100秒)
—- —————————————-
D001 .013183
D002 .013174

#########################################################################################################################################################
Sun Sep 01 06:00:06 2019
Errors in file /u01/app/oracle/diag/rdbms/testdb/testdb1/trace/testdb1_j000_14330.trc:
ORA-12012: error on auto execute of job "ORACLE_OCM"."MGMT_CONFIG_JOB_2_1"
ORA-29280: invalid directory path
ORA-06512: at "ORACLE_OCM.MGMT_DB_LL_METRICS", line 2436
ORA-06512: at line 1

解决方法2:
如果不使用OCM Collector, 可以从数据库中移除OCM的对象。
SQL> drop user ORACLE_OCM cascade;

OCM 是一个独立的工具,移除OCM 不影响数据库其他功能的使用。

如果不删除OCM 的对象,也可以禁用OCM的jobs,命令如下:
exec dbms_scheduler.disable(‘ORACLE_OCM.MGMT_CONFIG_JOB‘);
exec dbms_scheduler.disable(‘ORACLE_OCM.MGMT_STATS_CONFIG_JOB‘);

########################################################################################################################################################

Auto-tuning: Shutting down background process GTX1

Solution
1. Its normal for the database to automatically tune the number of these processes based on the workload of XA global transactions.If any application which using XA transaction and connecting to oracle RAC database, is it required.This a normal behavior and you do not have to worry about this error messages. Ignore Them
2. If you are sure that you are not using XA and want to stop these messages.You can disable the GTXn background processes,
then you must set GLOBAL_TXN_PROCESSES to 0 in your parameter file. Setting this parameter to 0 will disable the XA support on an Oracle RAC database.
Please refer -

Oracle? Database Reference
11g Release 2 (11.2)
Part Number E10820-02 -> GLOBAL_TXN_PROCESSES

#########################################################################################################################################################

106测试库出现大量的以下报错

Tue Dec 03 16:19:41 2019
opidcl aborting process unknown ospid (30182) as a result of ORA-2396
Tue Dec 03 16:19:41 2019
opidcl aborting process unknown ospid (30184) as a result of ORA-2396
Tue Dec 03 16:19:41 2019
opidcl aborting process unknown ospid (30186) as a result of ORA-2396
Tue Dec 03 16:21:06 2019
opidcl aborting process unknown ospid (30264) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30842) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30852) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30862) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30866) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30860) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30854) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30864) as a result of ORA-2396
Tue Dec 03 16:33:30 2019
opidcl aborting process unknown ospid (30850) as a result of ORA-2396

在$ORACLE_HOME/network/admin/sqlnet.ora文件中添加
SQLNET.INBOUND_CONNECT_TIMEOUT = 0
在$ORACLE_HOME/network/admin/listener.ora文件中添加
INBOUND_CONNECT_TIMEOUT_LISTENER = 0
进一步观察是否还有报错

############################################################################################################
session超时设置

在$ORACLE_HOME/network/admin/sqlnet.ora文件中添加

SQLNET.EXPIRE_TIME=60

TRACE_LEVEL_SERVER = 16 
TRACE_FILE_SERVER = SERVER 
TRACE_DIRECTORY_SERVER= /u01/app/oracle/network/trace 
TRACE_TIMESTAMP_ SERVER = ON 
TRACE_UNIQUE_SERVER = ON 
DIAG_ADR_ENABLED=OFF

##################################################################################################################

禁用11gr2的统计信息自动收集功能

SQL> select client_name,status from DBA_AUTOTASK_CLIENT;

CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection ENABLED
auto space advisor ENABLED
sql tuning advisor ENABLED

启动
begin
DBMS_AUTO_TASK_ADMIN.ENABLE(client_name => ‘auto optimizer stats collection‘,
operation => NULL,
window_name => NULL);
end;
/

关闭
begin
DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => ‘auto optimizer stats collection‘,
operation => NULL,
window_name => NULL);
end;
/

SQL> begin
2 DBMS_AUTO_TASK_ADMIN.DISABLE(client_name => ‘auto optimizer stats collection‘,
3 operation => NULL,
4 window_name => NULL);
5 end;
6 /

PL/SQL procedure successfully completed.

SQL> select client_name,status from DBA_AUTOTASK_CLIENT;

CLIENT_NAME STATUS
---------------------------------------------------------------- --------
auto optimizer stats collection DISABLED
auto space advisor ENABLED
sql tuning advisor ENABLED

SQL>

##############################################################################################################

Errors in file /u01/app/oracle/diag/rdbms/rac/rac1/trace/rac1_j001_17184.trc:
ORA-12012: error on auto execute of job "SYS"."BSLN_MAINTAIN_STATS_JOB"
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "DBSNMP.BSLN_INTERNAL", line 2073
ORA-06512: at line 1

看似是ORACLE 的作业没有运行,查了一圈发现由于 DBSNMP没有执行权限引起

解决方案:
查看dbsnmp是否拥有执行sys.dbms_job的权限
select * from dba_tab_privs where table_name=‘DBMS_JOB‘;

GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRANTABLE HIERARCHY
--------------- ---------- -------------------- ---------- ---------- --------- ---------
PUBLIC SYS DBMS_JOB SYS EXECUTE NO NO
EXFSYS SYS DBMS_JOB SYS EXECUTE NO NO
SYSMAN SYS DBMS_JOB SYS EXECUTE NO NO
APEX_030200 SYS DBMS_JOB SYS EXECUTE NO NO
OWBSYS SYS DBMS_JOB SYS EXECUTE NO NO

2.授予dbsnmp用户执行sys.dbms_job权限
GRANT EXECUTE ON sys.dbms_job to DBSNMP;

SQL> select * from dba_tab_privs where table_name=‘DBMS_JOB‘;
GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRANTABLE HIERARCHY
--------------- ---------- -------------------- ---------- ---------- --------- ---------
PUBLIC SYS DBMS_JOB SYS EXECUTE NO NO
DBSNMP SYS DBMS_JOB SYS EXECUTE NO NO
EXFSYS SYS DBMS_JOB SYS EXECUTE NO NO
SYSMAN SYS DBMS_JOB SYS EXECUTE NO NO
APEX_030200 SYS DBMS_JOB SYS EXECUTE NO NO
OWBSYS SYS DBMS_JOB SYS EXECUTE NO NO

以上是关于Oracle11G_R2中共享服务器模式和专用服务器模式参数解释及设置的主要内容,如果未能解决你的问题,请参考以下文章

Oracle数据库安装?

SUSE_11_X64_SP4环境下安装ORACLE_11G_R2

docker 安装 oracle_11g_r2 并实现数据持久化

oracle 11g_r2 创建数据库时 Enterprise Manager 配置失败

Linux(CentOS)安装Oracle_11g_r2数据库支持sqlplus上下翻页

linux中命令行安装oracle11g数据库