• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

memcached部署

mysql 搞代码 4年前 (2022-01-09) 20次浏览 已收录 0个评论

wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gzwget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gzwget http://pecl.php.net/get/memcache-2.2.5.tgztar zxvf libevent-1.4.13-stable.tar.gztar zxvf memcached-1.4.4.

wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gzwget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gzwget http://pecl.php.net/get/memcache-2.2.5.tgztar zxvf libevent-1.4.13-stable.tar.gztar zxvf memcached-1.4.4.tar.gzcd libevent-1.4.13-stable./configure --prefix=/usrmakemake installln -s /usr/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2cd memcached-1.4.4./configure --prefix=/home/memcached --enable-64bitmakemake install/home/memcached/bin/memcached -d -m 1024 -p 11211 -u root

参数说明: -d 启动为守护进程 -m 分配给Memcached使用的内存数量,单位是MB,默认为64MB -u 运行Memcached的用户,仅当作为root运行时 -l 监听的服务器IP地址,默认为环境变量INDRR_ANY的值 -p 设置Memcached监听的端口,最好是1024以上的端口 -c 设置最大并发连接数,默认为1024 -P 设置保存Memcached的pid文件,与-d选择同时使用

cd memcache-2.2.5/home/php/bin/phpize./configure --prefix=/home/phpmemcache --with-php-config=/home/php/bin/php-configmakemake installsed –i ‘<a style="color:transparent">本文来源gao($daima.com搞@代@#码(网5</a>s:./:/home/php/lib/php/extensions/no-debug-zts-20060613/:g’ /home/php/lib/php.inised –i ‘/zip.dll/aextension=memcache.so’ /home/php/lib/php.inicat >> /cache/data/test.php addServer('127.0.0.1', 11211);$memcache->addServer('192.168.0.2', 11212);$version = $memcache->getVersion();echo "Server's version: ".$version."n";$tmp_object = new stdClass;$tmp_object->str_attr = 'test';$tmp_object->int_attr = 123;$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");echo "Store data in the cache (data will expire in 10 seconds)n";$get_result = $memcache->get('key');echo "Data from the cache:n";var_dump($get_result);?>EOF

curl http://localhost/test.phServer's version: 1.4.4Store data in the cache (data will expire in 10 seconds)Data from the cache:object(stdClass)#3 (2) {["str_attr"]=>string(4) "test"["int_attr"]=>int(123)}# telnet localhost 11211

Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.statsSTAT pid 3015STAT uptime 3185???????????????????????????????? memcached运行的秒数STAT time 1267090234STAT version 1.4.4STAT pointer_size 64STAT rusage_user 0.000000STAT rusage_system 0.000000STAT curr_connections 10STAT total_connections 18STAT connection_structures 11STAT cmd_get 3?????????????????????????????????? 查询缓存的次数STAT cmd_set 5???????????????????????????????????设置key=>value的次数STAT cmd_flush 0STAT get_hits 3??????????????????????????????????? 缓存命中的次数STAT get_misses 0STAT delete_misses 0STAT delete_hits 0STAT incr_misses 0STAT incr_hits 0STAT decr_misses 0STAT decr_hits 0STAT cas_misses 0STAT cas_hits 0STAT cas_badval 0STAT auth_cmds 0STAT auth_errors 0STAT bytes_read 2697STAT bytes_written 1150STAT limit_maxbytes 1073741824STAT accepting_conns 1STAT listen_disabled_num 0STAT threads 4STAT conn_yields 0STAT bytes 1255STAT curr_items 2STAT total_items 5STAT evictions 0END

完成~~~以上仅为试验,如果只是一个小web单机环境的话,只需要php+eaccelerator(或者apc/xcache等)就足够了。用php+memcached+mysql-proxy+mysql是大型网站架构的事情~~


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:memcached部署
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址