handlersocket php,handlersocket安装配置

一、安装 handlersocket

下载地址 :https://nodeload.github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/tarball/master

tar xf ahiguti-HandlerSocket-Plugin-for-MySQL-1.0.6-88-gefd9972.tar.gz

cd ahiguti-HandlerSocket-Plugin-for-MySQL-efd9972/

./autogen.sh

./configure  --prefix=/usr/local/mysql/HandlerSocket-Plugin --with-mysql-source=/usr/local/src/mysql-5.1.57 --with-mysql-bindir=/usr/local/mysql/bin

make && make install

加载handlersocket 模块

mysql> install plugin handlersocket soname 'handlersocket.so';

Query OK, 0 rows affected (0.03 sec)

查看模块是否加载成功

mysql> show plugins

-> ;

+---------------+--------+----------------+------------------+---------+

| Name          | Status | Type           | Library          | License |

+---------------+--------+----------------+------------------+---------+

| binlog        | ACTIVE | STORAGE ENGINE | NULL             | GPL     |

| CSV           | ACTIVE | STORAGE ENGINE | NULL             | GPL     |

| MEMORY        | ACTIVE | STORAGE ENGINE | NULL             | GPL     |

| InnoDB        | ACTIVE | STORAGE ENGINE | NULL             | GPL     |

| MyISAM        | ACTIVE | STORAGE ENGINE | NULL             | GPL     |

| MRG_MYISAM    | ACTIVE | STORAGE ENGINE | NULL             | GPL     |

| handlersocket | ACTIVE | DAEMON         | handlersocket.so | BSD     |

+---------------+--------+----------------+------------------+---------+

修改my.cnf

添加

[mysqld]

#邦定端口

loose_handlersocket_port = 9998

loose_handlersocket_port_wr = 9999

#开启读线程数

loose_handlersocket_threads = 16

#开启写线程数

loose_handlersocket_threads_wr = 1

#允许打开文件数

open_files_limit = 65535

——————————————————————————————

二、安装php-handlersocket

wget  http://php-handlersocket.googlecode.com/files/php-handlersocket-0.2.0.tar.gz

tar xf php-handlersocket-0.2.0.tar.gz

cd php-handlersocket

/usr/local/php/bin/phpize

./configure --with-handlersocket --with-php-config=/usr/local/php/bin/php-config  --with-handlersocket-includedir=/usr/local/mysql/HandlerSocket-Plugin/include/handlersocket/

make LDFLAGS='-L/usr/local/mysql/HandlerSocket-Plugin/lib/'

make install

修改php.ini文件

添加如下内容

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"

extension = handlersocket.so

三、测试

创建数据表

| hand1 | CREATE TABLE `hand1` (

`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,

`user_name` varchar(50) DEFAULT NULL,

`user_email` varchar(255) DEFAULT NULL,

`created` datetime DEFAULT NULL,

PRIMARY KEY (`user_id`),

KEY `index_01` (`user_name`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 |

$host = '192.168.100.2';

$port = 9998;

$port_wr = 9999;

$dbname = 'wdj';

$table = 'hand1';

//INSERT

$hs = new HandlerSocket($host,$port_wr);

if (!($hs->openIndex(3,$dbname,$table, HandlerSocket::PRIMARY,'user_id,user_name,user_email,created')))

{

echo $hs->getError(),PHP_EOL;

die();

}

if ($hs->executeInsert(3,array('','testhand','hand@test.com','2012-12-24')) === false)

{

echo $hs->getError(), PHP_EOL;

}

//GET

$hs = new HandlerSocket($host,$port);

if (!($hs->openIndex(1,$dbname,$table,'','user_id,user_name,user_email,created')))

{

echo $hs->getError(),PHP_EOL;

die();

}

$retval = $hs->executeSingle(1,'=',array('0'),1,20000);

var_dump($retval);

$retval = $hs->executeMulti(

array(array(1, '=',array('1'),1,0),

array(1, '=',array('2'),1,0)));

var_dump($retval);

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值