zookeeper的php扩展安装及使用
2015-09-29 08:43
806 查看
一、安装libzookeeper cd /usr/local/src/ wget http://mirror.bit.edu.cn/apache//zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz tar -xf zookeeper-3.4.5.tar.gz cd zookeeper-3.4.5/src/c ./configure –prefix=/usr/local/zookeeper/zookeeper-3.4.5/ make && make install 二、安装php zookeeper扩展 cd /usr/local/src/ wget ‘http://pecl.php.net/get/zookeeper-0.2.2.tgz’ tar zxvf zookeeper-0.2.2.tgz cd zookeeper-0.2.2 phpize ./configure –with-php-config=/usr/local/php/bin/php-config –with-libzookeeper-dir=/usr/local/zookeeper/zookeeper-3.4.5/ make && make install vim /usr/local/php/etc/php.ini 查找:extension_dir=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/” 添加:extension=zookeeper.so 三注意:php-config libzookeeper-di路径一定要正确 三、扩展的使用 // 获取单条配置 $path = '/' . trim($path, '/'); $zookeeper = new \Zookeeper('address:2181'); if ($zookeeper->exists($path)) { $value = $zookeeper->get($path); } //创建节点 if (!$zookeeper->exists($path)) { $zookeeper->create($path, $value, array(array( 'perms' => 31, 'scheme' => 'world', 'id' => 'anyone' ))); } //更新节点 if ($zookeeper->exists($path)) { $zookeeper->set($path, $value); } //删除一个节点 if ($zookeeper->exists($path)) { $zookeeper->delete($path); } //获取所有子节点名称 if ($zookeeper->exists($path)) { $value = $zookeeper->getChildren($path); } //获取acl if ($zookeeper->exists($path)) { $zookeeper->getAcl($path); } //设置acl if ($zookeeper->exists($path)) { $acl = $zookeeper->getAcl($path); $version = isset($acl['0']['aversion']) ? $acl['0']['aversion'] : 0; $zookeeper->setAcl($path, $version, array(array( 'perms' => 31, 'scheme' => 'world', 'id' => 'anyone' ))); }
相关文章推荐
- Laravel 5.1 Ajax上传图片方法
- LAMP编译安装只PHP以模块化的方式工作
- (转)CGI、FastCGI、PHP-FPM
- 四个PHP非常实用的功能
- PHP比较运算符的详细介绍
- PHP类的封装与继承详解
- PHP代码优化技巧小结
- php猜单词游戏
- php正则匹配文章中的远程图片地址并下载图片至本地
- 解决php表单重复提交实现方法
- php乱码的解决方法
- symfony权威指南(1)symfony的安装
- 第 十 七 天 : 安 装 php 遇 到 的 错 误 汇 总
- getAttribute()与getParameter的区别
- ThinkPHP--后台登录页面搭建
- PHP复习笔记
- ThinkPHP--项目分组设置(前后台分组)
- 利用ContentProvider实现查看、添加系统联系人
- (php)mysql的int和float
- PHP画图之GD库的使用——略缩图(二)