【发布时间】:2018-04-16 07:11:56
【问题描述】:
使用 PHP PDO 访问 Ignite 集群。
1) 使用 PHP PDO 脚本创建了一个表。
生成的缓存在 Ignite Web 控制台中可见。
可以从 Ignite Web 控制台发出 SQL SELECT/INSERT。
可以使用独立的 PHP PDO 发出 SQL INSERT。
所以 SQL 表/缓存看起来功能齐全,但是:
2) 从 PHP PDO 脚本内部选择失败。
PHP PDO 脚本与 Ignite 网站上提供的示例脚本基本相同。
<?php
try {
$dbh=new PDO('odbc:ApacheIgniteDSN');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$res=$dbh->query('SELECT id from Person');
// no errors up to here
//exit;
if ($res == FALSE)
print_r("Exception");
// the following results in errors
foreach($res as $row) {
print_r($row);
}
}
catch (PDOException $e) {
print "Error: " . $e->getMessage() . "\n";
exit;
}*
从命令行运行时,会生成:
错误:SQLSTATE[HYC00]:未实现可选功能:0 指定 不支持属性。 (SQLFetchScroll[0] 在 分机\pdo_odbc\odbc_stmt.c:543)
这不是很有帮助,但在 Ignite 节点上会记录以下内容:
[17:00:30,074][SEVERE][grid-nio-worker-client-listener-0-#30][ClientListenerProcessor] Failed to process selector key [ses=GridSelectorNioSessionImpl [worker=ByteBufferNioClientWorker [readBuf=java.nio.HeapByteBuffer[pos=0 lim=8192 cap=8192], super=AbstractNioClientWorker [idx=0, bytesRcvd=0, bytesSent=0, bytesRcvd0=0, bytesSent0=0, select=true, super=GridWorker [name=grid-nio-worker-client-listener-0, igniteInstanceName=null, finished=false, hashCode=1314397987, interrupted=false, runner=grid-nio-worker-client-listener-0-#30]]], writeBuf=null, readBuf=null, inRecovery=null, outRecovery=null, super=GridNioSessionImpl [locAddr=/100.96.3.26:10805, rmtAddr=/100.96.3.1:6733, createTime=1523811628969, closeTime=0, bytesSent=69, bytesRcvd=75, bytesSent0=69, bytesRcvd0=75, sndSchedTime=1523811629031, lastSndTime=1523811629031, lastRcvTime=1523811629020, readsPaused=false, filterChain=FilterChain[filters=[GridNioAsyncNotifyFilter, GridNioCodecFilter [parser=ClientListenerBufferedParser, directMode=false]], accepted=true]]]
java.io.IOException: Connection reset by peer
请注意,我使用 CREATE TABLE 命令(来自 PHP PDO 脚本)创建了 SQL 表,而不是使用 queryEntities 在缓存中明确指定它。但是,Web 控制台可以正确看到它,并且您可以在那里对其进行查询,因此人们会假设 PDO 中的 SELECT 也可以工作,但事实并非如此。
【问题讨论】:
-
你的 Ignite 版本是多少?
-
@isapego 2.4.0。使用 Kubernetes 部署。
image: apacheignite/ignite:2.4.0
标签: ignite