当前位置: 首页 > 工具软件 > HandlerSocket > 使用案例 >

handlersocket php,handlersocket安装配置

戈巴英
2023-12-01

一、安装 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);

?>

 类似资料: