下載zookeeper依賴函式庫:
http://apache.fayea.com/zookeeper/zookeeper-3.4.6/
解壓縮
tar -zxf zookeeper-3.4.6.tar.gz
cd zookeeper-3.4.6/src/c
安裝
./configure --prefix=/usr/local/zookeeper/zookeeper-3.4.6/
make & make install
下載PHPzookeeper擴充函式庫:
http://pecl.php.net/package/zphpook
tar -zxvf zookeeper-3.4.6.tar.gz
安裝
/usr/local/php5.4/bin/phpize
./configure --with-php-config=/usr/local/php5.4/bin /php-config --with-libzookeeper-dir=/usr/local/zookeeper/zookeeper-3.4.6/
make & make install
編輯設定php
vim /usr/local/conf/php5.4/php.ini
/usr/local/php5.4/bin/php -m
l /usr/local/php5.4/lib/php/extensions/no-debug-non-zts-20100525
重啟fpm
kill -USR2 `cat /usr/local/php5.4/var/run/php-fpm.pid`
測試存取zookeeper服務狀態:
vim test_zookeeper.php
class zookeeper_instance extends Zookeeper {
class zook , $string) {
if ($event == Zookeeper::CONNECTED_STATE) {
$acl.
"scheme"=>"world",
"
);
}
}
}
$zk=new zookeeper_instance(); 81", array($zk, 'connect_cb') ,200000);
echo "connect okn";
$zkm=$zk->get("/hbase/master");
var_dump($zk->getState());
var_dump($zk->getClientId( ));
var_dump($zk->getAcl("/hbase/master"));
var_dump($zk->getRecvTimeout());
var_dump($zkm);
echo "nr";
運行:
php test_zookeeper.php
結果:
instance ok
connect ok
string(65) "? 20165@namenode1.dd.comnamenode1.dd.com,60000,1429518731888" 0]=>
int(165782755280355365)
[1]=>
string(18) " ? .L[ ?c6. "
}
array(2) {
> array(11) {
["czxid"]=>
float(227633267014)
["mzxid"]=>
. float(1429518733469)
["mtime"] =>
float(1429518733469)
["version"]=>
int(0)
int(0)
["ephemeralOwner "]=>
float(2.3780011668065E+17)
["dataLength"]=>
int(65)
. xid"]=>
float(227633267014 )
}
[1]=>
array(1) {
[0]=>
array(3) {
scheme"]=>
string (5) "world"
["id"]=>
string(6) "anyone"
}
}
}
int(40000)
以上就介紹了使用php存取zookeeper服務,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。