当前位置:   article > 正文

Php连接Cassandra慢问题解决方案(Using Cassandra with PHP)_cassandra extension for php8

cassandra extension for php8

https://wiki.fourkitchens.com/display/PF/Using+Cassandra+with+PHP

1、Down the Thrift code.

http://incubator.apache.org/thrift/download/

2、Building the PHP client
2.1 Configure and build Thrift.

./configure
make

2.2 Build the PHP Thrift interface for Cassandra:

./compiler/cpp/thrift -gen php ../PATH-TO-CASSANDRA/interface/cassandra.thrift


2.3 Copy the include files to a useful place (per the Cassandra “Getting Started” guide):

mkdir -p /usr/share/php/Thrift
cp -R gen-php/ /usr/share/php/Thrift/packages/
cp -R lib/php/src/* /usr/share/php/Thrift/

3、Building and installing the native PHP extension

Installing and using the native PHP extension provides approximately a ten-fold performance boost on writing data.

3.1 Change to PATH-TO-THRIFT/lib/php/src/ext/thrift_protocol.
3.2 Install support for building PHP extensions:

/usr/local/webserver/php/bin/phpize
./configure --enable-thrift_protocol --with-php-config=/usr/local/webserver/php/bin/php-config
make

3.3 Copy the extension’s .so to the extensions directory.

cp modules/thrift_protocol.so /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/

3.4 Enable the module.

edit php.ini and add:
extension=thrift_protocol.so

3.5 Then restart php-fpm
4、Checking the connection
4.1 Copy in the PHP from the Cassandra client examples page to /var/www/cassandra-test.php.
4.2 Visit http://localhost/cassandra-test.php in the browser.
4.3 On the first load, the array output should be empty. On the second, there should be content.

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/126230
推荐阅读
  

闽ICP备14008679号