|
xdebug作为php中最为强大的调试和性能检测工具,几乎搞这领域开发是要熟练运用的;memcached作为php最为著名的三方缓存组件,由于数据结构较为单一,但是扩充方便,作为系统session管理首选载体,而不用像mysql管理session那样产生大量垃圾数据,只能重启才能清除memory引擎下的数据;xcache是opcache中很好用且稳定性很好的缓存组件,对于ZF这个庞大的框架,整体性能提升的不是一点点;ssdb是替代redis的首选方案,leveldb实现,已经测试过好几次真的很好用,速度快,占系统资源小,而且能回写磁盘,对于不是严谨性要求不是极度苛刻的实时数据采集更新是首选的组件,关键主从分布真的很方便,而且不用依赖第三方的库,谁用谁知道!废话不多说,写部署笔记!
1、xdebug部署
下载xdebug安装源码包,解压不多说
cd xdebug-2.2.5
/usr/local/php/bin/phpize
(如出现“Cannot find autoconf”,yum install m4,yum install autoconf)
./configure --prefix=/usr/local/phpxdebug --enable-xdebug \
--with-php-config=/usr/local/php/bin/php-config
make && make install
跟装其他扩展没什么区别
find / -name php.ini,搜到后添加以下内容
zend_extension = "xdebug.so"
xdebug.default_enable = 1
xdebug.force_display_errors = 0
xdebug.force_error_reporting = 0
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%R"
;xdebug.remote_enable = 0
;xdebug.remote_handler = "dbgp"
;xdebug.remote_host = "127.0.0.1"
xdebug.auto_trace = 1
xdebug.trace_format = 1
xdebug.trace_output_dir = "/tmp"
xdebug.trace_output_name = "trace.%t.%R"
xdebug.so具体位置也是搜索,/tmp注意写权限,然后service httpd restart,查看phpinfo,郁闷居然找不到xdebug!
最后发现是因为php.ini目录位置关系~~
[iyunv@kevin xdebug-2.2.5]# cp /usr/local/lib/php.ini /usr/local/php/etc
[iyunv@kevin xdebug-2.2.5]# mv /usr/local/lib/php.ini /usr/local/lib/php.ini.bak
[iyunv@kevin xdebug-2.2.5]# service httpd restart
终于看到了!!
当然也可以到这里http://www.xdebug.org/wizard.php逛逛,我最后是这里找到灵感的!
2、memcached安装部署
首先要搞到三个安装包分别是memcached源码包,libmemcached包,当然还有memcached的php扩展包。如图所示:

传到服务器,解压
a. 安装memcached
yum install libevent-devel
./configure --prefix=/usr/local/memcached
make && make install
启动memcahed: /usr/local/memcached/bin/memcached -m 64m -p 11211 -d -u root -P /var/run/memcached.pid -c 256 -vv
测试连通:telnet localhost 11211
退出测试链接:quit
将memcached加入防火墙访问规则中:vim /etc/sysconfig/iptables
加入:-A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT (注意位置:在prohibited前面)
重启iptables:service iptables restart
b.安装libmemcache
./configure --prefix=/usr/local/libmemcached --with-memcached
没有g++库:yum install gcc-c++
配置PHP扩展:
cd memcached-2.1.0
/usr/local/php/bin/phpize
(如出现“Cannot find autoconf”,yum install m4,yum install autoconf)
make && make install
c. 安装php扩展
./configure --prefix=/usr/local/phpmemcached --enable-memcached \
--with-php-config=/usr/local/php/bin/php-config \
--with-libmemcached-dir=/usr/local/libmemcached
vim修改php.ini,最后几行添加:extension=memcached.so,重启PHP查看phpinfo()是否加载memcached模块
现在要添加系统服务,这个shell脚本有点麻烦,网上找了半天,终于找到一个能用的了
cd /etc/init.d
vim memcached
chmod 755 memcached
chkconfig --add memcached
chkconfig memcached on
脚本如下
#!/bin/bash
# v.0.0.1
# create by snowolf at 2012.5.25
#
# memcached - This shell script takes care of starting and stopping memcached.
#
# chkconfig: - 90 10
# description: Memcache provides fast memory based storage.
# processname: memcached
memcached_path="/usr/local/memcached/bin/memcached"
memcached_pid="/var/run/memcached.pid"
memcached_memory="256"
# Source function library.
. /etc/rc.d/init.d/functions
[ -x $memcached_path ] || exit 0
RETVAL=0
prog="memcached"
# Start daemons.
start() {
if [ -e $memcached_pid -a ! -z $memcached_pid ];then
echo $prog" already running...."
exit 1
fi
echo -n $"Starting $prog "
# Single instance for all caches
$memcached_path -m $memcached_memory -l 0.0.0.0 -p 11211 -u root -d -P $memcached_pid
RETVAL=$?
[ $RETVAL -eq 0 ] && {
touch /var/lock/subsys/$prog
success $"$prog"
}
echo
return $RETVAL
}
# Stop daemons.
stop() {
echo -n $"Stopping $prog "
killproc -d 10 $memcached_path
echo
[ $RETVAL = 0 ] && rm -f $memcached_pid /var/lock/subsys/$prog
RETVAL=$?
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $prog
RETVAL=$?
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit $RETVAL
重启服务service memcached start测试,OK!!
注意脚本中的memcached的运行目录,内存大小;如果先前start过了注意删除那个僵尸进程memcached.pid,就这么简单。
3、部署opcache—xcache
/usr/local/php/bin/phpize
./configure --help
./configure --prefix=/usr/local/xcache \
--with-php-config=/usr/local/php/bin/php-config \
--enable-xcache \
--enable-xcache-optimizer
make && make install
vim /usr/local/php/etc/php.ini
***************************
[xcache]
extension=xcache.so
xcache.admin.enable_auth = "on"
xcache.admin.user = "kristoffer"
xcache.admin.pass = "1d42abef5a4a5748edf45448bc8d64c5" (通过echo md5('password')获取)
xcache.coredump_directory = "/tmp/"
xcache.size = "24M"
xcache.var_size = "8M"
拷贝htdoc目录到www下,命名为xcache-admin
4、源码安装ssdb
到官方博客下载源代码,直接make && make install 就可以了,Makefile已经设置了安装目录等参数了,可以自己修改,但是基本不用变。
然后设置系统服务
cd /etc/init.d
vim ssdb
chmod 755 ssdb
chkconfig --add ssdb
chkconfig ssdb on
netstat -ano | grep 8888
shell脚本为
# /bin/sh
#
# chkconfig:345 98 98
# description: SSDB is a fast NoSQL database for storing big list of billions of elements
# processname:ssdb
case "$1" in
'start')
/usr/local/ssdb/ssdb-server -d /usr/local/ssdb/ssdb.conf
echo "ssdb started."
;;
'stop')
kill `cat /usr/local/ssdb/var/ssdb.pid`
echo "ssdb stopped."
;;
'restart')
kill `cat /usr/local/ssdb/var/ssdb.pid`
echo "ssdb stopped."
sleep 0.5
/usr/local/ssdb/ssdb-server -d /usr/local/ssdb/
ssdb.conf
echo "ssdb started."
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
就此全部软体部署完毕,关于这些软体如何监控将在后面博客补充,运维这块还是要单独放出来。
版权声明:本文为博主原创文章,未经博主允许不得转载。 |
|
|
|
|
|
|