ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle Shared Server 和Oracle Dedicated Server的使用和配置

Oracle Shared Server 和Oracle Dedicated Server的使用和配置

原创 Linux操作系统 作者:Hongdba 时间:2013-10-10 20:53:13 1 删除 编辑

专用服务器(dedicated server

专用服务器进程

用户进程和服务器进程是分开的。

每个用户进程都有自己的服务器进程。

用户进程和服务器进程可在不同的机器上运行,以利用分布式处理的优势。

用户进程和服务器进程的比率是1 1

即使用户进程不发出数据库请求,专用服务器也存在,只是保持空闲状态。

此处所用的程序接口取决于用户进程和专用服务器进程是否在同一台机器上。如果在同一

机器上,进程间的程序接口将使用主机操作系统的交互进程通信(IPC) 机制。

何时使用专用服务器

提交批作业(预计很少有或没有空闲时间)

sysdba 身份连接以启动、关闭或执行恢复

要请求使用专用服务器,必须在tnsnames.ora 文件内的Oracle Net TNS 连接字符串中

包含SERVER=DEDICATED 子句。

注:对于大多数平台来说,如果您的机器有足够的内存支持专用服务器,则应使用专用服

务器。这样性能可能更好些。

但也有例外,例如Windows NT,在该系统中,由于共享服务器体系结构的异步特性,使

Oracle Shared Server 配置性能可能会有所提高

如何连接专用服务器

在客户端服务器中的tnsnames.ora文件里进行设置:

 

dedicated =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.99)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = hong)

      (server = dedicated) 

    )

 

共享服务器(shared server

Oracle Shared Server 的优点

减少针对某一例程的进程数目

增加可服务的用户数

实现负载平衡

减少空闲服务器进程的数目

减少内存占用和系统开

如何连接共享服务器

在客户端服务器中的tnsnames.ora文件里进行设置:

 

shared =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.2.99)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = hong)

      (server = sharde) 

    )

  )

 

 

查询参数dispatchersshared_servers

配置shared_server必需的初始化参数,查询如下:

SQL> show parameter dispatc

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

dispatchers                          string

max_dispatchers                      integer     5

mts_dispatchers                      string

mts_max_dispatchers                  integer     5

SQL> show parameter shar

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cursor_sharing                       string      EXACT

hi_shared_memory_address             integer     0

max_shared_servers                   integer     20

shared_memory_address                integer     0

shared_pool_reserved_size            big integer 5872025

shared_pool_size                     big integer 117440512

shared_server_sessions               integer     0

shared_servers                       integer     0

如上所示,表中dispatchersshared_servers均未设置,那我们需设置参数。

 

修改初始化参数dispatchersshared_server

因未设置该参数,所以我们需要在pfile文件中设置该参数。

创建pfile文件

create spfile from pfile;

查询dbs目录,编辑pfile文件

[oracle@localhost dbs]$ vi inithong.ora

 

a.audit_file_dest='/home/oracle/admin/hong/adump'

*.background_dump_dest='/home/oracle/admin/hong/bdump'

*.compatible='9.2.0.4.0'

*.control_files='/home/oracle/oradata/hong/control01.ctl'

*.core_dump_dest='/home/oracle/admin/hong/cdump'

*.db_block_size=8192

*.db_cache_size=80M

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='hong'

*.dispatchers='(PROTOCOL=TCP)(SERVICE=hongXDB)(dispatchers=3)'

*.instance_name='hong'

*.job_queue_processes=10

*.log_archive_dest_1='location=/home/oracle/archive'

*.open_cursors=300

*.pga_aggregate_target=20971520

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.resource_limit=TRUE

*.service_names='hong'

*.shared_pool_size=100M

*.sort_area_size=65536

*.undo_management='AUTO'

*.undo_retention=700

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/home/oracle/admin/hong/udump'

~

关闭数据库 创建spfile文件重新启动

先将dbs下原有的spfile文件mv

mv spfilehong.ora /tmp

创建spfile文件启动数据库,

修改shared_servers参数

alter system set shared_servers=3;

 

再次查询,结果如下:

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

dispatchers                          string      (protocol=tcp)(dispatchers=3)

max_dispatchers                      integer     5

mts_dispatchers                      string      (protocol=tcp)(dispatchers=3)

mts_max_dispatchers                  integer     5

 

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

hi_shared_memory_address             integer     0

max_shared_servers                   integer     20

shared_memory_address                integer     0

shared_pool_reserved_size            big integer 5872025

shared_pool_size                     big integer 117440512

shared_server_sessions               integer     165

shared_servers                       integer     3

 

如上所示,我们已经配置了dispatchers参数,如需更改输入命令

alter system set dispatchers=’(protocol=tcp)(dispatchers=4)’;即可。

 

验证设置

发出下列命令以验证启动例程时是否已向监听程序注册

$ lsnrctl services

[oracle@localhost dbs]$ lsnrctl services

 

LSNRCTL for Linux: Version 9.2.0.4.0 - Production on 27-JUL-2013 20:52:50

 

Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(PORT=1521))

Services Summary...

Service "hong" has 1 instance(s).

  Instance "hong", status READY, has 5 handler(s) for this service...

    Handler(s):

      "DEDICATED" established:0 refused:0 state:ready

         LOCAL SERVER

      "D001" established:1 refused:0 current:1 max:1002 state:ready

         DISPATCHER

         (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=37361))

      "D000" established:1 refused:0 current:0 max:1002 state:ready

         DISPATCHER

         (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=37359))

      "D002" established:1 refused:0 current:0 max:1002 state:ready

         DISPATCHER

         (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=37363))

      "D003" established:1 refused:0 current:0 max:1002 state:ready

         DISPATCHER

         (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=37364))

Service "hongXDB" has 1 instance(s).

  Instance "hong", status READY, has 0 handler(s) for this service...

The command completed successfully

如上所示,可以看出,已有4个调度程序向监听程序注册。

 

调度程序:

通过建立一次连接验证您是否已通过共享服务器连接,

然后查询V$CIRCUIT 视图以显示每个共享服务器连接

的一个条目。

 

SQL> desc v$circuit;

 Name                                      Null?    Type

 ----------------------------------------- -------- ----------------------------

 CIRCUIT                                            RAW(4)

 DISPATCHER                                         RAW(4)

 SERVER                                             RAW(4)

 WAITER                                             RAW(4)

 SADDR                                              RAW(4)

 STATUS                                             VARCHAR2(16)

 QUEUE                                              VARCHAR2(16)

 MESSAGE0                                           NUMBER

 MESSAGE1                                           NUMBER

 MESSAGE2                                           NUMBER

 MESSAGE3                                           NUMBER

 MESSAGES                                           NUMBER

 BYTES                                              NUMBER

 BREAKS                                             NUMBER

 PRESENTATION                                       VARCHAR2(256)

 PCIRCUIT                                           RAW(4)

 

做如下查询:

SQL> select circuit,dispatcher,status from v$circuit;

 

no rows selected

此时,我们并未连接共享服务器。当我们连接共享服务器时:

C:\Users\Hong>sqlplus system/oracle@shared

 

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 10 10 13:44:41 2013

 

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

 

 

连接到:

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production

With the Partitioning, OLAP and Oracle Data Mining options

JServer Release 9.2.0.4.0 - Production

 

SQL>

 

再做上述查询,

 

SQL> select circuit,dispatcher,status from v$circuit;

 

CIRCUIT  DISPATCH STATUS

-------- -------- ----------------

58F05828 58290058 NORMAL

我们就可以看出已连接上共享服务器。

查看服务器端的网络情况

连接到服务器端的网络情况,

[oracle@localhost ~]$ netstat -anp | more

(Not all processes could be identified, non-owned process info

 will not be shown, you would have to be root to see it all.)

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  

tcp        0      0 0.0.0.0:37359               0.0.0.0:*                   LISTEN      22836/ora_d000_hong

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      -                  

tcp        0      0 0.0.0.0:624                 0.0.0.0:*                   LISTEN      -                  

tcp        0      0 0.0.0.0:37361               0.0.0.0:*                   LISTEN      22838/ora_d001_hong

tcp        0      0 0.0.0.0:1521                0.0.0.0:*                   LISTEN      21913/tnslsnr      

tcp        0      0 0.0.0.0:37363               0.0.0.0:*                   LISTEN      22874/ora_d002_hong

tcp        0      0 0.0.0.0:37364               0.0.0.0:*                   LISTEN      22876/ora_d003_hong

tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      -                  

tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      -                  

tcp        0      0 127.0.0.1:37360             127.0.0.1:1521              ESTABLISHED 22820/ora_pmon_hong

tcp        0      0 127.0.0.1:1521              127.0.0.1:37360             ESTABLISHED 21913/tnslsnr      

tcp        0      0 192.168.2.99:1521           192.168.2.2:50747           ESTABLISHED 22876/ora_d003_hong

tcp        0      0 :::22                       :::*                        LISTEN      -                  

tcp        0      0 ::ffff:192.168.2.99:22      ::ffff:192.168.2.2:49234    ESTABLISHED -                  

udp        0      0 127.0.0.1:41488             0.0.0.0:*                               22844/ora_s001_hong

udp        0      0 127.0.0.1:3104              0.0.0.0:*                               22834/ora_s000_hong

udp        0      0 0.0.0.0:38576               0.0.0.0:*                               22872/oraclehong   

udp        0      0 127.0.0.1:32820             0.0.0.0:*                               22838/ora_d001_hong

udp        0      0 127.0.0.1:21565             0.0.0.0:*                               22846/ora_s002_hong

udp        0      0 0.0.0.0:18380               0.0.0.0:*                               22842/oraclehong   

udp        0      0 127.0.0.1:57322             0.0.0.0:*                               22836/ora_d000_hong

udp        0      0 0.0.0.0:618                 0.0.0.0:*                               -                  

udp        0      0 0.0.0.0:621                 0.0.0.0:*                               -                  

 

如上所示,我们的客户端192.168.2.2 与服务器端192.168.2.99 端口1521 进行了连接,负责连接的进程是ora_d003_hong

[oracle@localhost ~]$ ps -ef | grep 22876

oracle   22876     1  0 12:31 ?        00:00:00 ora_d003_hong

oracle   22922 22900  0 13:10 pts/4    00:00:00 grep 22876

动态性能视图

了解以下视图有助于配置服务器:

V$CIRCUIT

V$SHARED_SERVER

V$DISPATCHER

V$SHARED_SERVER_MONITOR

V$QUEUE

V$SESSION

 

希望以上内容能对初学者有所帮助。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29239083/viewspace-774122/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2013-10-10

  • 博文量
    2
  • 访问量
    16620