分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]
  [文章作者:张宴 本文版本:v1.0 最后修改:2009.01.13 转载请注明原文链接:http://blog.zyan.cc/post/392/]

  PHPSH 是 Facebook 团队开发的一款交互式 PHP Shell,可以方便地进行PHP命令行测试。

  网址:http://www.phpsh.org/

  安装方法:
cd /opt/
wget http://www.phpsh.org/phpsh-latest.tgz
tar zxvf phpsh-latest.tgz
cd phpsh/
sed -i "s#php -q#/usr/local/webserver/php/bin/php -q#g" phpsh
chmod +x phpsh
ln -s /opt/phpsh/phpsh /bin/phpsh

  注意:上述安装方法中的“/usr/local/webserver/php/bin/php”为您的PHP可执行文件路径。


  使用示例:
[root@localhost ~]# phpsh
I can't find a tags file for you.  To enable tab completion in phpsh,
go to the root directory of your php code and run 'ctags -R',
(or whatever the analagous command is with your version of ctags,)
then run phpsh from that directory or a subdirectory of that directory.

Commandline: /usr/local/webserver/php/bin/php -q /opt/phpsh/phpsh.php
phpsh (c)2006 by Charlie Cheever and Dan Corson and Facebook, Inc.
type 'h' or 'help' to see instructions & features

New Feature: You can use the -c option to turn off coloring
php> = 3 + 4
7
php> = md5("ZhangYan")
28f91f3a4b62ce57b7a533e742e8aae1
php> echo date("Y-m-d H:i:s")
2009-01-13 15:28:19
php> $var = "blog.zyan.cc"
php> echo $var
blog.zyan.cc
php> $array = array(array(1,2,3), array("a" => "b", "c" => "d", "e" => "f"), 'g', 'h')
php> = $array
Array
(
    [0] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

    [1] => Array
        (
            [a] => b
            [c] => d
            [e] => f
        )

    [2] => g
    [3] => h
)

php> q

[root@localhost ~]# phpsh

Tags: , , ,
  [文章作者:张宴 本文版本:v1.0 最后修改:2008.11.30 转载请注明原文链接:http://blog.zyan.cc/post/384/]

  首先,需要了解Memcached协议,如果不清楚可参考《Memcached 协议中英文对照》。

  1、数据存储(假设key为zhangyan,value为12345)
printf "set zhangyan 0 0 5\r\n12345\r\n" | nc 127.0.0.1 11211
 STORED

  2、数据取回(假设key为zhangyan)
printf "get zhangyan\r\n" | nc 127.0.0.1 11211
 VALUE zhangyan 0 5
 12345
 END


  3、数值增加1(假设key为zhangyan,并且value为正整数)
printf "incr zhangyan 1\r\n" | nc 127.0.0.1 11211
 12346
Tags: ,
  [文章作者:张宴 本文版本:v1.0 最后修改:2008.07.24 转载请注明原文链接:http://blog.zyan.cc/post/359/]

  写了一个shell脚本,可以在同一台Linux服务器的不同端口,运行多个MySQL服务的情况下,快捷启动、停止、重启、杀死指定端口的MySQL进程。

vi /usr/local/bin/mysql.sh

  输入以下内容(因各服务器的MySQL配置不同,可能需要修改的部分已用红色标注):
#!/bin/sh

mysql_port=$2
mysql_username="root"
mysql_password="123456"

function_start_mysql()
{
    printf "Starting MySQL...\n"
    /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &
}

function_stop_mysql()
{
    printf "Stoping MySQL...\n"
    /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -h localhost -P ${mysql_port} shutdown
}

function_restart_mysql()
{
    printf "Restarting MySQL...\n"
    function_stop_mysql
    function_start_mysql
}

function_kill_mysql()
{
    kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port} | awk '{printf $2}')
    kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port} | awk '{printf $2}')
}

if [ "$1" = "start" ]; then
    function_start_mysql
elif [ "$1" = "stop" ]; then
    function_stop_mysql
elif [ "$1" = "restart" ]; then
    function_restart_mysql
elif [ "$1" = "kill" ]; then
    function_kill_mysql
else
    printf "Usage: mysql.sh {start|stop|restart|kill}\n"
fi


  赋予脚本可执行权限:
chmod +x /usr/local/bin/mysql.sh


  脚本执行方法:
mysql.sh start 3306
mysql.sh stop 3306
mysql.sh restart 3306
mysql.sh kill 3306

Tags: , , , ,
  [文章作者:张宴 本文版本:v1.0 最后修改:2008.06.25 转载请注明原文链接:http://blog.zyan.cc/read.php/354.htm]

  最近,在我原有的“Linux服务器系统监控程序”基础上,完善了HTTP、TCP、MySQL主动监控与MSN、E-mail、手机短信报警。监控程序以shell和PHP程序编写,以下为主要框架与部分代码:

  一、系统监控接口程序(interface.php)具有的报警方式
  1、MSN实时报警
  ①、监控程序每次检测到故障存在、或者故障恢复,都会发送短消息到管理员的MSN。
  点击在新窗口中浏览此图片
Tags: , , , ,
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]