salebab / phpkafka

PHP extension for Apache Kafka
MIT License
17 stars 66 forks source link

Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0 #6

Open yunkaiyueming opened 9 years ago

yunkaiyueming commented 9 years ago

when i 'make' phpkafka, it occured the followed issue:

[root@OA-test phpkafka]# make test Build complete. Don't forget to run 'make test'.

PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/root/phpkafka/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

how can i solve it??? please help me

yunkaiyueming commented 9 years ago

when i use phpkafka function in my php file:

" Fatal error: Class 'Kafka' not found in /usr/local/www/kafka-php/test_kafka.php on line 5 "

I know i havn't install phpkafka into php_extension rightly, how can i solve it?

the100rabh commented 9 years ago

Running following commands to load the shared library folder in env variables solved this for me

 LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
yunkaiyueming commented 9 years ago

@the100rabh : thanks for your answer, i have solved this problem, i have compiled the 'phpkafka' into php_extension, when i use the next code into my php file:

test_phpkafka.php <?php ini_set('display_errors',TRUE); error_reporting(E_ALL); set_time_limit(0);

$kafka = new Kafka("localhost:9092"); $kafka->produce("topic_name", "message content"); $kafka->consume("topic_name", 1172556); ?>

new 'Kafka' is ok, var_dump($kafka) is : object(Kafka)#1 (0) { } but '$kafka->produce' and '$kafka->consume' give nothing ,untile nginx server response 502, what's wrong?

the100rabh commented 9 years ago

I too tried using consume function thats the one that gives the issue. produce works fine.

EVODelavega commented 9 years ago

@yunkaiyueming The problem is that this extension, ATM still requires you to specify what partition to consume from. I'm working on a fix for that, though. for now, you can use my fork (consume-with-meta branch), which adds a couple of methods like getPartitionsForTopic that enable you to set the partition correctly before consuming

EVODelavega commented 9 years ago

salebab's repo has been abandoned, I've forked it and I'm developing it further. Currently, the consume-with-meta branch is the one that is most up-to-date. If you have any issues/suggestions, you can create an issue on my fork, as my changes will probably not get merged (there's a PR ready and waiting, but the owner, salebab, hasn't merged them, instead, he's updated the README file, linking to my fork).

If you want, you can use my fork for testing, mind you, it's far from being stable

On Tue, Apr 7, 2015 at 11:48 PM, eparisca notifications@github.com wrote:

@EVODelavega https://github.com/EVODelavega Do you have an estimate on when you will merge that fork's features? Thank you very much!

— Reply to this email directly or view it on GitHub https://github.com/salebab/phpkafka/issues/6#issuecomment-90742146.

siyuanmami commented 8 years ago

@EVODelavega Hi EVODelavega, I installed phpkafka in CentOS 6.5 by these commands: ldconfig /usr/bin/phpize ./configure --enable-kafka --with-php-config=/usr/bin/php-config make make install

then I can see kafka.so under /usr/lib64/php/modules.

but when I executed 'service php-fpm restart', it told me: Starting php-fpm: [16-Oct-2015 17:07:23] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/kafka.so' - librdkafka.so.1: cannot open shared object file: No such file or directory in Unknown on line 0

I have tried export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib as well, but it still not work.

Could you give me some suggestion about it? Thanks!

EVODelavega commented 8 years ago

@siyuanmami Not sure, I know there were some issues with building librdkafka on CentOS some time ago, so maybe you want to check the issues on edenhill's librdkafka repo. So far, I've only tested the extension on debian, Slackware, mint and ubuntu. I haven't seen the issue you're reporting on any of those systems, though

siyuanmami commented 8 years ago

@EVODelavega Thanks for your help. I have confirmed with edenhill about it, I should have installed librdkafka library correctly. Not sure if it is because I am using php-fpm. I used to install this extension on ubuntu worked with apache, it is fine.

Thanks!

EVODelavega commented 8 years ago

@siyuanmami php-fpm shouldn't be an issue. AFAIK, it handles the MINIT, RINIT, RSHUTDOWN and MSHUTDOWN cycles in exactly the same way, and as it stands, there's very little in the module init and shutdown functions that could trip PHP up. But having said that: what version are you currently using? What repo, what branch?

edenhill commented 8 years ago

@EVODelavega This seems to come up quite often, librdkafka.so.1 not being in the library search for the PHP invociation and people dont really know how to fix it, so may I suggest you add some instructions in README?

siyuanmami commented 8 years ago

@EVODelavega Thanks you for you help! I have installed the php extension successfully after I updated /etc/ld.so.conf to include /usr/local/lib !

EVODelavega commented 8 years ago

@edenhill Done, added some instructions that should be rather dummy-proof to the README on current master

kaustavha commented 8 years ago

Thanks @the100rabh your solution helped me get kafkacat working.

abdollahpour commented 8 years ago

I fixed it finally on CentOS 7!! For both CLI and FPM

echo '/usr/local/lib' > /etc/ld.so.conf.d/kafka.conf
echo 'export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib64/php/modules:/usr/local/lib"' >> /etc/profile
ldconfig
amitlokulwar commented 3 years ago

@abdollahpour I had tried above command that you told but that is also not working. Still I am getting same error. Could you please tell me what else step you taken to resolve that issue. Thank You!!! kafka