【发布时间】:2020-07-18 04:37:45
【问题描述】:
当通过 cluster->connect() 连接到集群时,PHP 脚本挂起。
虽然我用 nodejs 驱动程序尝试这个:
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({
contactPoints: ['127.0.0.1'],
localDataCenter: 'datacenter1',
keyspace: 'test'
});
const query = 'SELECT * FROM mytable';
client.execute(query).then(console.log).catch( console.log );
我们得到以下输出:
ResultSet {
info: {
queriedHost: '127.0.0.1:9042',
triedHosts: { '127.0.0.1:9042': null },
speculativeExecutions: 0,
achievedConsistency: 10,
traceId: undefined,
warnings: undefined,
customPayload: undefined,
isSchemaInAgreement: true
},
rows: [ Row { id: 'test' } ],
rowLength: 1,
columns: [ { name: 'id', type: [Object] } ],
pageState: null,
nextPage: undefined,
nextPageAsync: undefined
}
当我们使用 PHP 执行此操作时,它会挂起:
<?php
$cluster = \Cassandra::cluster()
->withContactPoints( '127.0.0.1' )
->withPort( 9042 )
->build();
// This will happen immediately
// var_dump( 'Built!' );exit;
$session = $cluster->connect( 'test' );
// This hangs. It never dumps 'Connected!'.
var_dump( 'Connected!' );exit;
var_dump( $session->execute( new \Cassandra\SimpleStatement( 'select * from mytable' ), array() ) );
下面附上所需的文件。
index.php -> https://pastebin.com/iihpJfpW
Vagrantfile -> https://pastebin.com/BkPwynxy
cassandra.repo -> https://pastebin.com/LbraCY3f
index.js -> https://pastebin.com/TSPc0bLm
- 新建文件夹“cassandraTest”
- 将 Vagrantfile 放入文件夹中
- 在“cassandraTest”中创建名为“provision”的新目录
- 把 cassandra.repo 放在那里
- 流浪
注意:
这不是 Vagrant 问题,因为在我们运行 CentOS 7.6 的 Stage 环境中也会出现同样的问题
环境:
CentOS 7.6
卡桑德拉 3.11.6 原生协议 v4
NodeJs 12 NodeJs Cassandra 驱动程序 4.5.0
PHP 7.2 PHP Cassandra 驱动程序(最新,通过 yum install -y php72-php-pecl-cassandra.x86_64 from remi 安装)
流浪者 2.2.7 Oracle VirtualBox 版本 6.1.4 r136177 (Qt5.6.2)
【问题讨论】:
-
您使用的是哪个版本的
cassandra-cpp-driver?这可能是在最新版本中修复的bug。 -
你有什么解决办法吗?我经常遇到这个问题/我只能通过降级或升级到特定版本的 libuv、cassandra-cpp-driver 和 cassandra 来解决它。我在 debian 9 和 debian 10 上使用 php-7.4 /(我第一次遇到 php7.2 的问题)
-
你能提供你的 cassandra.so 的 ld (/usr/bin/ld) 吗?
标签: php cassandra cassandra-php-driver