linux php安装zookeeper扩展
linux php安装zookeeper扩展
tags:php zookeeper linux ext
前言:
zookeeper提供很犀利的命名服务,并且集群操作具有原子性,所以在我的多个项目中被采用。
在原项目总,服务器集群的状态统一上报到zookeeper集群中,然后通过客户端来访问zookeeper,实时观察集群的状态(当然了,你要做成配置同步也可以)。但是客户端跨平台不方便,开发一个手机客户端又太egg pain了,所以打算采用PHP来读取zookeeper中。
以下是安装php的zookeeper扩展的步骤。多次使用,如有问题请反馈。转载请注明出处。
环境:
|
1
2
3
4
5
|
centos : 6.4 zookeeper : 3.4.5 php : 5.5.10 nginx : 1.5php zookeeper扩展 :0.2.2 |
1、如果没有安装nginx,先安装nginx,可参照:http://hi.baidu.com/solohac/item/081e97e54868403f86d9deff
确保先把nginx配置好,再往下
2、如果没有安装php,先安装php(先把nginx的php支持配置好了之后,再去安装zookeeper的扩展)
下载
wget http://hk2.php.net/distributions/php-5.5.10.tar.gz
解压
tar zxvf php-5.5.10.tar.gz
生成、安装
cd php-5.5.10
|
1
|
./configure --prefix=/usr/local/php5.5.10 --with-config-file-path=/usr/local/php5.5.10/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 |
make && make install
配置php
|
1
2
|
cp php.ini-production /usr/local/php5.5.10/etc/php.inicp /usr/local/php5.5.10/etc/php-fpm.conf.default /usr/local/php5.5.10/etc/php-fpm.conf |
启动
|
1
|
/usr/local/php5.5.10/sbin/php-fpm |
查看端口是否监听
netstat -lnt | grep 9000
编辑nginx配置文件
|
1
2
3
4
5
6
7
8
9
10
11
|
location ~ .*\.(php)?${expires -1s;try_files $uri =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;include fastcgi_params;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_pass 127.0.0.1:9000;} |
nginx重新加载配置
nginx -s reload
测试php访问
cd /usr/local/nginx/html/
vim aa.php
写入内容
|
1
2
3
|
<?phpecho "test php";?> |
如果php能正常访问了,继续下面的安装,如果不行,先回头把php的支持弄好。
2、安装zookeeper
下载
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.5/zookeeper-3.4.5.tar.gz
解压(随便你放在哪个目录,记得就行)
tar zxfv zookeeper-3.4.5.tar.gz
启动zookeeper服务器
|
1
2
3
4
|
cd zookeeper-3.4.5/confcp zoo_sample.cfg zoo.cfgcd ../bin./zkServer.sh start |
这里最好确认一下是否期待成功,./zkServer.sh status
我这里是单台,所以结果为:
|
1
2
3
4
|
[root@localhost bin]# ./zkServer.sh statusJMX enabled by defaultUsing config: /root/zookeeper-3.4.5/bin/../conf/zoo.cfgMode: standalone |
编译zookeeper库,给php用的
|
1
2
3
|
cd ../src/c./configure --prefix=/usr/local/zookeeperlibmake && make install |
3、安装php的zookeeper扩展
下载
wget http://pecl.php.net/get/zookeeper-0.2.2.tgz
解压(解压出来的package.xml不用去管他)
tar zxvf zookeeper-0.2.2.tgz
把他放到/root/php-5.5.10/ext中
mv zookeeper-0.2.2 /root/php-5.5.10/ext/
cd /root/php-5.5.10/ext/
改目录名字
mv zookeeper-0.2.2 zookeeper
回到php-5.5.10目录
cd ..
./buildconf --force
./configure -h|grep zookeeper
查看configure是否已经支持了zookeeper
|
1
2
3
|
--enable-zookeeper Enable zookeeper support--disable-zookeeper-session Disable zookeeper session handler support--with-libzookeeper-dir=DIR Set the path to libzookeeper install prefix. |
如果显示如上,说明已经支持了,继续往下
cd ext/zookeeper
生成configure
/usr/local/php5.5.10/bin/phpize
生成makefile
|
1
2
3
4
|
./configure --with-php-config=/usr/local/php5.5.10/bin/php-config --with-libzookeeper-dir=/usr/local/zookeeperlib注意上面的路径:--with-php-config是php安装的路径--with-libzookeeper-dir是第一步中install zookeeper库的路径 |
编译安装
make && make install
结果为,这个结果接下来的配置要用到
Installing shared extensions: /usr/local/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/
添加ext路径和文件名
|
1
2
3
4
|
vim /usr/local/php5.5.10/etc/php.iniextension_dir="/usr/local/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/"extension=zookeeper.so |
4、重新编译php
进入Php的源码文件夹,不要进错了。我的源码文件夹是/root/php-5.5.10,安装目录是/usr/local/php5.5.10
cd /root/php-5.5.10
rm -rf autom4te.cache/ configure
./buildconf --force
./configure -h|grep zookeeper
查看configure是否已经支持了zookeeper
如果已经支持了,继续往下
./configure --prefix=/usr/local/php5.5.10 --with-config-file-path=/usr/local/php5.5.10/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-zookeeper --with-libzookeeper-dir=/usr/local/zookeeperlib --enable-sockets
make && make install
到这里,已经安装好支持了,来测试下是否正常
在zookeeper-0.2.2.tgz中(也就是Php的zookeeper扩展),有examples/Zookeeper_Example.php文件,可以用来测试
|
1
2
|
cp /root/php-5.5.10/ext/zookeeper/examples/Zookeeper_Example.php /usr/local/nginx/html//usr/local/php5.5.10/bin/php /usr/local/nginx/html/Zookeeper_Example.php |
看是否能打印出如下结果
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
string(0) ""array(1) { [0]=> string(9) "zookeeper"}NULLstring(3) "abc"array(2) { [0]=> string(7) "test123" [1]=> string(9) "zookeeper"}NULLNULLarray(2) { [0]=> string(3) "001" [1]=> string(3) "002"} |
重启php-fpm
killall php-fpm
/usr/local/php5.5.10/sbin/php-fpm
现在就可以通过浏览器访问支持zookeeper扩展的php了
如果还有别的问题,请检查:
1、iptables
2、selinux
linux php安装zookeeper扩展的更多相关文章
- linux下安装opcache扩展
linux下安装opcache扩展 参考:http://www.php.net/manual/zh/opcache.installation.php 1 2 3 4 5 6 7 wget http ...
- Linux上安装Zookeeper以及一些注意事项
最近打算出一个系列,介绍Dubbo的使用. 分布式应用现在已经越来越广泛,Spring Could也是一个不错的一站式解决方案,不过据我了解国内目前貌似使用阿里Dubbo的公司比较多,一方面这个框架也 ...
- 总结 Linux 下安装 PHP 扩展步骤
总结一下 Linux 下安装 PHP 扩展步骤,这里以安装 PHP 的 redis 扩展为例. 一.拿到扩展包下载地址,下载扩展包 pecl 上搜索 redis wget http://pecl.ph ...
- Linux下安装Zookeeper
Zookeeper是一个协调服务,可以用它来作为配置维护.名字服务.分布式部署: 下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路. 一.Zookeeper下载 [ro ...
- linux 下安装php扩展
linux下安装php扩展 步骤: 1.在扩展解压包目录执行 phpize 2.执行 ./configure --with-php-config=/usr/local/php/bin/php-conf ...
- Linux php安装zip扩展
Linux php安装zip扩展 2018.07.22 22:40 1165浏览 #wget http://pecl.php.net/get/zip-1.12.4.tgz #tar zxfv zi ...
- Linux上安装ZooKeeper并设置开机启动(CentOS7+ZooKeeper3.4.10)
1下载Zookeeper 2安装启动测试 2.1上载压缩文件并解压 2.2新建 zookeeper配置文件 2.3安装JDK 2.4启动zookeeper 2.5查看zookeeper的状态 3将Zo ...
- linux centos7 安装zookeeper
linux 系统下 zookeeper 安装教程 1.下载安装包 1)进入安装目录 cd /home/install/ 2)下载 wget http://mirror.bit.edu.cn/apach ...
- php win/linux/mac 安装redis扩展或者扩展报错 zend_smart_str.h file not found
1 windows 安装reids 扩展 根据phpinfo 查看php信息.在pecl.php.net 下载对应的redis扩展版本,放如扩展目录,在php.ini 配置扩展信息,重启服务 2 li ...
随机推荐
- js的捕捉事件,冒泡事件
冒泡事件可以查询上个随笔, 捕捉事件正好和冒泡时间正反着 所以这代码我把冒泡事件注释, html和css的内容 <style type="text/css"> #box ...
- LA3027 合作网络-并查集压缩路径
有N个结点 一次 I u v 操作表示把结点u的父结点设为v,距离为|u-v|%1000.输入保证执行指令前u没有父结点 一次E u 操作表示询问u到根结点的距离 O操作表示结束 #include&l ...
- 在Windows程序中启用console输出-2016.01.04
在某些时候,我们可能需要在Win32窗口应用程序中打开控制台窗口,打印一些消息,或者作为当前程序的另外一个人机交互界面,或者为了帮助调试程序.为了达到这种效果,需要了解函数AllocConsole和C ...
- WP8_ListBox的用法
在Windows Phone 7 Tips (5) 中曾经提到,在Windows Phone 7 中页面的布局一般分为:Panoramic.Pivot.List和Full Screen.而通常List ...
- Windows Phone开发(12):认识一下独具个性的磁贴(转)
对"磁贴"的理解是一点也不抽象的,为什么呢?只要你愿意启动WP系统,无论你是在模拟器中还是在真机中,是的,桌面上那一块块像地板的玩意儿,就是磁贴了.(图:磁贴) 在上图中,我们很直 ...
- 4种kill某个用户所有进程的方法
在linux系统管理中,我们有时候需要kill掉某个用户的所有进程,初学者一般先查询出用户的所有pid,然后一条条kill掉,或者写好一个脚本,实际上方法都有现成的,这边有4种方法,我们以kill用户 ...
- frame和iframe的区别
转自:http://blog.csdn.net/lyr1985/article/details/6067026 CSDN 1.frame不能脱离frameSet单独使用,iframe可以 ...
- 基于s5pv210嵌入式linux系统sqlite3数据库移植
基于s5pv210嵌入式linux系统sqlite3数据库移植 1.下载源码 http://www.sqlite.org/download.html 最新源码为3080100 2.解压 tar xvf ...
- Mysql的ssl主从复制+半同步主从复制
Mysql的ssl主从复制+半同步主从复制 准备工作 1.主从服务器时间同步 [root@localhost ~]# crontab -e */30 * * * * /usr/sbin/ntpdate ...
- jquery animate 动画效果使用说明
animate( params, [duration], [easing], [callback] ) 用于创建自定义动画的函数. 这个函数的关键在于指定动画形式及结果样式属性对象.这个对象中每个属性 ...