下載zookeeper依賴函式庫:
http://apache.fayea.com/zookeeper/zookeeper-3.4.6/
解壓縮
tar -zxf zookeeper-3.4.6.tar.gz
tar -zxf zookeeper-3.4.6.tar.gz
tar -zxf zookeeper-3.4.6.tar.gz
c
安裝
./configure --prefix=/usr/local/zookeeper/zookeeper-3.4.6/
make & make install
下載PHPzookeeper擴充庫:
解壓縮
tar -zxvf zookeeper-3.4.6.tar.gz
安裝
/usr/local/php5.4/bin/phpize
./configure --with-php-config=/php5/local/phpize
./configure --with-php-config=/phpusr/local/config=/php. 4/bin/php-config --with-libzookeeper-dir=/usr/local/zookeeper/zookeeper-3.4.6/
make & make install
編輯設定php
vim /usr/local/ /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
if ($event == Zookeeper::CONNECTED_STATE) {
"perms"=>0x1f,
"scheme"=>"world",
"id"=>"anyone"
$zk=new zookeeper_instance();
echo "instance okn";
$zk->connect("127.0.0.1:2181" , array($zk, 'connect_cb'),200000);
echo "connect okn";
$zkm=$zk->get("/hbase/master");
var_dump($zk->get("/hbase/master");
var_dump($zk->getState()) ;
var_dump($zk->getClientId());
var_dump($zk->getAcl("/hbase/master"));
var_dump($zk->getRecvkmTimeout());
var_dump($zk->getRecvkm7());
var_dump($zTime);
echo "nr";
運行:
php "nr";
運行:
php test_zookeeper.php
結果:
instance
connect ok01
string(65) "instance oknodno165001650.com 731888"
int(3)
array(2) {
[0]=>
int(165782755280355365)
[1]=>
string(18) "
. array(2) {
[0]=>
array(11) {
["czxid"]=>
float(227633267014)] f (227633267014)
["ctime"]= >
float(1429518733469)
["mtime"]=>
float(1429518733469) )
["cversion"]=>
int(0)
["aversion" ]=>
int(0)
["ephemeralOwner"]=>
float(2.3780011668065E+17)
(2.3780011668065E+17)
(2.3780011668065E+17) 🜠
["numChildren"]=>
int(0)
["pzxid"]=>
["pzxid"]=>
float(227633267014)
}
[1]=>
["perms"]=>
int( 31)
["scheme"]=>
string(5) "world"
["idany> }
}
int(40000)