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/zookeeper
압축 해제
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`
사육사 서비스 상태에 대한 액세스 테스트:
vim test_zookeeper.php
class Zookeeper_instance extends Zookeeper {
function connect_cb($type, $event, $string) {
if ($event == Zookeeper::CONNECTED_STATE) {
$ acl=array(
“perms”=>0x1f,
“scheme”=>”world”,
“id”=>”누구나”
)
}
}
}
$zk=new Zookeeper_instance();
echo "instance okn"
$zk->connect("127.0.0.1:2181", 배열 ($ 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
결과:
인스턴스 확인
connect ok
string(65) " 20165@namenode1.dd.comnamenode1.dd.com,60000,1429518731888"
int(3)
array(2) {
[0]= >
int(165782755280355365)
[1]=>
string(18) " ? .L[ ?c6. "
}
array(2) {
[0] =>
array(11) {
["czxid"]=>
float(227633267014)
["mzxid"]=>
float(227633267014)
["ctime "]=>
float(1429518733469)
["mtime"]=>
float(1429518733469)
["version"]=>
int(0)
[" cversion"]=>
int(0)
["aversion"]=>
int(0)
["ephemeralOwner"]=>
float(2.3780011668065 E+17)
["dataLength"]=>
int(65)
["numChildren"]=>
int(0)
["pzxid"]=>
float(227633267014)
}
[1]=>
array(1) {
[0]=>
array(3) {
["perms"]= >
int (31)
["scheme"]=>
string(5) "world"
["id"]=>
string(6) "anyone"
}
}
}
int(40000)