LinuxϱàÒëredisºÍphpredisµÄ·½·¨

5年以前  |  阅读数:372 次  |  编程语言:PHP 

±¾ÎĽ²ÊoÁËLinuxϱaÒeredisºÍphpredisµÄ½¨¡£*ÖÏi¸ø´o¼Ò¹(C)´o¼Ò²Î¿¼£¬¾ßÌaÈçÏ£º

1¡¢×¼±¸¹¤×÷

ÏÂÔØÈi¼þ£º±¾Õ¾ÏÂÔصØÖ*¡£
²Ù×÷ϵͳ£ºCentOS 5.5
redis °ae±¾£ºredis-2.6.9

2¡¢±aÒe°²×°


    tar zxvf redis-2.6.9.tar.gz //½aѹ 
    cd redis-2.6.9 
    make  //±aÒe 

Èç¹u³oÏÖÈçÏ´iÎo£º

zmalloc.o: In function zmalloc_used_memory': /data/redis-2.6.9/src/zmalloc.c:223: undefined reference to__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: [redis-server] Error 1
make[1]: Leaving directory `/data/redis-2.6.9/src'
make:
[all] Error 2

½a¾o½¨£º


    make CFLAGS="-march=i686" 

µ±¿´¼u¡°Hint: To run 'make test' is a good idea ;)¡± ˵Ã÷±aÒe³É¹¦¡£


    make install  //°²×° 

˵Ã÷£ºÆaʵ make install ¾ÍÊÇ£º


    cp -p redis-server /usr/local/bin
    cp -p redis-benchmark /usr/local/bin
    cp -p redis-cli /usr/local/bin
    cp -p redis-check-dump /usr/local/bin
    cp -p redis-check-aof /usr/local/bin

ÕaÑu£¬redis ¾Í°²×°³É¹¦ÁË¡£

½ÓÏÂÀ´¾ÍÊÇÆo¶¯RedisÁË, ÉÏÃae±aÒeºoÉu³ÉµÄÄÇÐ(C)¿ÉÖ´ÐÐÎļþ¿½±´µ½ÁË/usr/local/binĿ¼ÏÂÃae, ËuÃǵÄ×÷ÓÃ*Ö±ðÊÇ£º

redis-server£ºRedis*þÎñÆ÷µÄdaemonÆo¶¯³ÌÐo
redis-cli£ºRedisÃuÁiÐвÙ×÷¹¤¾ß¡£µ±È»£¬ÄaÒ²¿ÉÒÔÓà telnet ¸u¾ÝÆa´¿Îı¾Ð­ÒeÀ´²Ù×÷
redis-benchmark£ºRedisÐÔÄܲaÊÔ¹¤¾ß£¬²aÊÔRedisÔÚÄaµÄϵͳ¼°ÄaµÄÅaÖÃϵĶÁдÐÔÄÜ

Æo¶¯ Redis ½ø³ÌÖ»ÐeÒªÖ´ÐÐÕa¸o /usr/local/bin/redis-server /path-to/redis.conf

Æo¶¯µÄʱºoºoÃaeÒª¸uÉÏ redis µÄÅaÖÃÎļþ£¬ ÕaÑuRedis¾Í˳ÀuÆo¶¯ÁË.

3¡¢Æo¶¯ redis »a³oÏÖµÄÎÊÌa

Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.

½a¾o½¨£ºÐÞ¸ÄÅaÖÃÎļþ redis.conf ½« maxmemory ÉeÖÃΪ maxmemory 1024000000 #*ÖÅa256MÄÚ´ae

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

½a¾o½¨£º¾¯¸ae£º¹ýÁ¿Ê¹ÓÃÄÚ´aeÉeÖÃΪ0£¡ÔÚµÍÄÚ´ae»*¾³Ï£¬ºǫ±£´ae¿ÉÄÜʧ°Ü¡£ÎªÁËÐÞÕýÕa¸oÎÊÌa£¬ÇeÔÚ/etc/sysctl.conf Ìi¼ÓÒ»Ïi 'vm.overcommit_memory = 1' £¬È»ºoÖØÆo£¨»oÕßÔËÐÐÃuÁi'sysctl vm.overcommit_memory=1' £(C)ʹÆaÉuЧ¡£

µ±Æo¶¯µÄʱºoûÓÐÈκÎÐÅÏ¢£¬±iÃ÷Æo¶¯³É¹¦¡£Ò²¿ÉÒÔʹÓà "netstat -tnl" ²e¿´6379¶Ë¿ÚÊÇ*ñÆo¶¯¡£

4¡¢¿ªÆoºÍ¹Ø±Õ redis

redis-server /usr/local/redis-2.6.9/redis.conf ¿ªÆo£¬×¢£ºÐeÒªÖ¸¶¨ redis µÄÅaÖÃÎļþ

pkill redis-server ֹͣ redis
redis-cli shutdown ֹͣ redis

5¡¢redis.conf µÄ²ÎÊýÐÅÏ¢

¹ØÓÚredis¼°Æa²ÎÊýÐÅÏ¢¿É²Î¿¼±¾Õ¾¡¶Redis»u±¾ÖªÊ¶¡¢°²×°¡¢²¿Êð¡¢ÅaÖñʼǡ*

6¡¢±aÒe phpredis


    unzip phpredis-master.zip
    cd phpredis-master
    /usr/local/php/bin/phpize
    ./configure ¨Cwith-php-config=/usr/local/php/bin/php-config
    make && make install

ÐÞ¸Ä php.ini Îļþ¡£¼ÓÔØ redis.so Ä£¿e£¬ÖØÆo Apache £¡

¸u¶a¹ØÓÚPHPÏa¹ØÄÚÈݸÐÐËȤµÄ¶ÁÕ߿ɲe¿´±¾Õ¾×¨Ìa£º¡¶php curlÓÃ*¨×ܽa¡¡¢¡¶[PHPÔËËaÓeÔËËauÓè×ܽa](http://www.jb51.net/Special/357.htm)¡¡¢¡¶PHPÍøÂç±a³Ì¼¼ÇÉ×ܽa¡¡¢¡¶[PHP»u±¾Ói¨ÈeÃŽ̳Ì](http://www.jb51.net/Special/348.htm)¡¡¢¡¶php²Ù×÷officeÎĵµ¼¼ÇÉ×ܽa(°uÀ¨word,excel,access,ppt)¡¡¢¡¶phpÈÕÆÚÓeʱ¼aÓÃ*¨×ܽa¡¡¢¡¶phpÃaeÏo¶ÔÏo³ÌÐoÉe¼ÆÈeÃŽ̡̳¡¢¡¶php×Öu´®(string)Óè×ܽa¡¡¢¡¶php+mysqlÊý¾Ý¿a²Ù×÷ÈeÃŽ̡̳¼°¡¶php³£¼uÊý¾Ý¿a²Ù×÷¼¼ÇÉ»a×Ü¡*

Ï£Íu±¾ÎÄËuÊo¶Ô´o¼ÒPHP³ÌÐoÉe¼ÆÓÐËu°iÖu¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例