ÔÚLinuxÉÏ°²×°Memcached·þÎñ(º¬libeventµÄ°²×°)
LinuxÏÂMemcache·þÎñÆ÷¶ËµÄ°²×°
·þÎñÆ÷¶ËÖ÷ÒªÊÇ°²×°memcache·þÎñÆ÷¶Ë£¬Ä¿Ç°µÄ×îа汾ÊÇ memcached-1.3.0 ¡£
ÏÂÔØ£ºhttp://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
ÁíÍ⣬MemcacheÓõ½ÁËlibeventÕâ¸ö¿âÓÃÓÚSocketµÄ´¦Àí£¬ËùÒÔ»¹ÐèÒª°²×°libevent£¬libeventµÄ×îа汾ÊÇlibevent-1.3¡££¨Èç¹ûÄãµÄϵͳÒѾ°²×°ÁËlibevent£¬¿ÉÒÔ²»Óð²×°£©
¹ÙÍø£ºhttp://www.monkey.org/~provos/libevent/
ÏÂÔØ£ºhttp://www.monkey.org/~provos/libevent-1.3.tar.gz
ÓÃwgetÖ¸ÁîÖ±½ÓÏÂÔØÕâÁ½¸ö¶«Î÷.ÏÂÔØ»ØÔ´Îļþºó¡£
1.ÏÈ°²×°libevent¡£Õâ¸ö¶«Î÷ÔÚÅäÖÃʱÐèÒªÖ¸¶¨Ò»¸ö°²×°Â·¾¶£¬¼´./configure ¨Cprefix=/usr£»È»ºómake£»È»ºómake install£»
2.ÔÙ°²×°memcached£¬Ö»ÊÇÐèÒªÔÚÅäÖÃʱÐèÒªÖ¸¶¨libeventµÄ°²×°Â·¾¶¼´./configure ¨Cwith-libevent=/usr£»È»ºómake£»È»ºómake install£»
ÕâÑù¾ÍÍê³ÉÁËLinuxÏÂMemcache·þÎñÆ÷¶ËµÄ°²×°¡£ÏêϸµÄ·½·¨ÈçÏ£º
1.·Ö±ð°ÑmemcachedºÍlibeventÏÂÔØ»ØÀ´£¬·Åµ½ /tmp Ŀ¼Ï£º
# cd /tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz2.ÏÈ°²×°libevent£º
# tar zxvf libevent-1.2.tar.gz
# cd libevent-1.2
# ./configure ¨Cprefix=/usr
# make
# make install3.²âÊÔlibeventÊÇ·ñ°²×°³É¹¦£º
# ls -al /usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3
-rw-r¨Cr¨C 1 root root 454156 11?? 12 17:38 libevent.a
-rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3
»¹²»´í£¬¶¼°²×°ÉÏÁË¡£4.°²×°memcached£¬Í¬Ê±ÐèÒª°²×°ÖÐÖ¸¶¨libeventµÄ°²×°Î»Öãº
# cd /tmp
# tar zxvf memcached-1.2.0.tar.gz
# cd memcached-1.2.0
# ./configure ¨Cwith-libevent=/usr
# make
# make install
Èç¹ûÖмä³öÏÖ±¨´í£¬Çë×Ðϸ¼ì²é´íÎóÐÅÏ¢£¬°´ÕÕ´íÎóÐÅÏ¢À´ÅäÖûòÕßÔö¼ÓÏàÓ¦µÄ¿â»òÕß·¾¶¡£
°²×°Íê³Éºó»á°Ñmemcached·Åµ½ /usr/local/bin/memcached £¬5.²âÊÔÊÇ·ñ³É¹¦°²×°memcached£º
# ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug
°²×°MemcacheµÄPHPÀ©Õ¹
1.ÔÚhttp://pecl.php.net/package/memcache Ñ¡ÔñÏàÓ¦ÏëÒªÏÂÔصÄmemcache°æ±¾¡£
2.°²×°PHPµÄmemcacheÀ©Õ¹
tar vxzf memcache-2.2.1.tgz
cd memcache-2.2.1
/usr/local/php/bin/phpize
./configure ¨Cenable-memcache ¨Cwith-php-config=/usr/local/php/bin/php-config ¨Cwith-zlib-dir
make
make install
3.ÉÏÊö°²×°Íêºó»áÓÐÀàËÆÕâÑùµÄÌáʾ£º
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
4.°Ñphp.iniÖеÄextension_dir = ¡°./¡±ÐÞ¸ÄΪ
extension_dir = ¡°/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/¡±
5.Ìí¼ÓÒ»ÐÐÀ´ÔØÈëmemcacheÀ©Õ¹£ºextension=memcache.so
memcachedµÄ»ù±¾ÉèÖãº
1.Æô¶¯MemcacheµÄ·þÎñÆ÷¶Ë£º
# /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid
-dÑ¡ÏîÊÇÆô¶¯Ò»¸öÊØ»¤½ø³Ì£¬
-mÊÇ·ÖÅä¸øMemcacheʹÓõÄÄÚ´æÊýÁ¿£¬µ¥Î»ÊÇMB£¬ÎÒÕâÀïÊÇ10MB£¬
-uÊÇÔËÐÐMemcacheµÄÓû§£¬ÎÒÕâÀïÊÇroot£¬
-lÊǼàÌýµÄ·þÎñÆ÷IPµØÖ·£¬Èç¹ûÓжà¸öµØÖ·µÄ»°£¬ÎÒÕâÀïÖ¸¶¨ÁË·þÎñÆ÷µÄIPµØÖ·192.168.0.200£¬
-pÊÇÉèÖÃMemcache¼àÌýµÄ¶Ë¿Ú£¬ÎÒÕâÀïÉèÖÃÁË12000£¬×îºÃÊÇ1024ÒÔÉϵĶ˿ڣ¬
-cÑ¡ÏîÊÇ×î´óÔËÐеIJ¢·¢Á¬½ÓÊý£¬Ä¬ÈÏÊÇ1024£¬ÎÒÕâÀïÉèÖÃÁË256£¬°´ÕÕÄã·þÎñÆ÷µÄ¸ºÔØÁ¿À´É趨£¬
-PÊÇÉèÖñ£´æMemcacheµÄpidÎļþ£¬ÎÒÕâÀïÊDZ£´æÔÚ /tmp/memcached.pid£¬
2.Èç¹ûÒª½áÊøMemcache½ø³Ì£¬Ö´ÐУº
# kill `cat /tmp/memcached.pid`
Ò²¿ÉÒÔÆô¶¯¶à¸öÊØ»¤½ø³Ì£¬²»¹ý¶Ë¿Ú²»ÄÜÖظ´¡£
3.ÖØÆôapache£¬service httpd restart
Memcache»·¾³²âÊÔ£ºÔËÐÐÏÂÃæµÄphpÎļþ£¬Èç¹ûÓÐÊä³öThis is a test!£¬¾Í±íʾ»·¾³´î½¨³É¹¦¡£¿ªÊ¼ÁìÂÔMemcacheµÄ÷ÈÁ¦°Ñ£¡
< ?php $mem = new Memcache; $mem->connect(¡±127.0.0.1¡å, 11211); $mem->set(¡¯key¡¯, ¡®This is a test!¡¯, 0, 60); $val = $mem->get(¡¯key¡¯); echo $val; ?>
ÍƼöÐÅÏ¢
- linuxÃüÁîѧϰ±Ê¼Ç£¨11£©£ºnlÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨5£©£ºrmÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨4£©£ºmkdirÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨1£©£ºlsÃüÁî
- ½«CentosµÄyumÔ´¸ü»»Îª¹úÄڵİ¢ÀïÔÆÔ´
- ʹÓÃNginxÌí¼Óheader·ÀÖ¹ÍøÒ³±»frame
- linuxϼÓËÙscp´«Êä´óÎļþµÄËÙ¶È
- linuxϵͳÉ϶ÔnginxÈÕÖ¾·Ö¸î´¦Àí
- lnmp/nginxϵͳÕæÕýÓÐЧµÄͼƬ·ÀµÁÁ´ÍêÕûÉèÖÃÏê½â
- Í»ÆÆÊ®Íò²¢·¢µÄNginxµÄÅäÖü°ÓÅ»¯
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- ²éÕÒ²¢É¾³ý.svnĿ¼Îļþ
- redis ÆßÖÖÊý¾ÝÀàÐ͵ÄʹÓó¡¾°
- linux ÏÂÎļþ¸´ÖƵ½windowsÏÂÂÒÂëµÄ½â¾ö°ì·¨
- nginx³öÏÖ502 upstream sent too big he....
- linuxÏÂsudoÅäÖÃÏê½â
- linuxÃüÁîѧϰ±Ê¼Ç£¨15£©£ºtailÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨14£©£ºheadÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨13£©£ºlessÃüÁî
- linuxÃüÁîѧϰ±Ê¼Ç£¨12£©£ºmoreÃüÁî
- ¼ÓÃÜËã·¨±È½Ï3DES AES RSA ECC MD5 SHA1µÈ
ÆÀÂÛ