DRCP连接池从5.3(PECL OCI8 1.3)
PHP支持Oracle数据库驻留连接池(DRCP)。 DRCP允许更高效地使用数据库机器内存并提供高可扩展性。使用DRCP不需要或者很少的应用程序更改。
DRCP适用于使用少量数据库模式连接并使数据库连接在短时间内保持打开状态的应用程序。其他应用程序应使用Oracle的默认专用数据库服务器进程,或使用共享服务器。
DRCP有利于所有三种连接功能,但在使用oci_pconnect()创建连接时提供最高的可扩展性。
对于OCI8中可用的DRCP,PHP使用的Oracle客户端库和Oracle数据库版本必须均为11g或更高。
有关DRCP的文档可以在几个Oracle手册中找到。例如,请参阅»在Oracle文档中配置数据库驻留连接池以获取使用信息。 »DRCP白皮书包含关于DRCP的背景信息。
要使用DRCP,与OCI8 1.3(或更高版本)的扩展和Oracle 11g(或更高版本)库编译PHP,然后按照下列步骤操作:
As a privileged database administrator, use a program like SQL*Plus to start the connection pool in the database:
SQL> execute dbms_connection_pool.start_pool;
Optionally use dbms_connection_pool.alter_param() to configure DRCP settings. The current pool settings can be queried from the DBA_CPOOL_INFO view.
Update the connection strings used. For PHP applications that currently connect using a Network Connect Name like MYDB:
$c = oci_pconnect("myuser", "mypassword", "MYDB");
modify the tnsnames.ora file and add a (SERVER=POOLED) clause, for example:
MYDB = (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=myhost.dom.com)
(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=sales)
(SERVER=POOLED)))
Alternatively, modify the Easy Connect syntax in PHP and add :POOLED after the service name:
$c = oci_pconnect("myuser", "mypassword", "myhost.dom.com:1521/sales:POOLED");
Edit php.ini and choose a connection class name. This name indicates a logical division of the connection pool and can be used to isolate pooling for separate applications. Any PHP applications with the same user name and connection class value will be able to share connections in the pool, giving greater scalability.
oci8.connection_class = "MY_APPLICATION_NAME"
Run the application, connecting to the 11g (or later) database.
这看起来像一个很好的起点。谢谢 – magowan90
@ magowan90我的荣幸! http://php.net/manual/en/oci8.connection.php –
当DB主机没有足够的内存来处理工作负载时,DRCP用于可扩展性。 @ magowan90的问题没有任何迹象表明这是问题。 –