? ? ?
Redis
是 key-value 的NOSQL、獨愛那些
小而熱
的數(shù)據(jù)、典型"蘿莉控"
? ? ?至于啥叫 key-value 呢?用RDBMS的觀點、一言以辟之:
? ? ?所謂 key:主鍵列
? ? ?所謂 value:其他列
? ? ?Redis 近幾年很火、火到抬頭不見、低頭見
? ? ?抬頭望國外:著名成人網(wǎng)站 youporn 采用 100% Redis 每天 1億 PV、解決了無數(shù)屌絲 YY 問題
? ? ?低頭思國內:新浪微博走的 Redis 之路、那叫一把眼淚一把辛酸呀
? ? ?
? ? ?千里之行、始于安裝、Let's 談談一次簡單的安裝步驟
?
? ? ? ㈠ 安裝 Redis
?
?
# wget https://redis.googlecode.com/files/redis-2.6.13.tar.gz # tar -zxv -f redis-2.6.13.tar.gz # cd redis-2.6.13 # cd src # make # mkdir /etc/redis/ # cp redis.conf /etc/redis/redis.conf # echo "1" > /proc/sys/vm/overcommit_memory # make install
?
? ? ? ㈡ 設置 Redis 為后臺守護進程
?
?
# cat /etc/redis/redis.conf | grep -in --color=auto 'daemonize' 16:# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. 17:daemonize yes
?
? ? ? ㈢ 啟動 Redis
?
?
# redis-server /etc/redis/redis.conf # ps aux | grep redis root 32111 0.0 0.0 31496 1500 ? Ssl 16:38 0:00 redis-server /etc/redis/redis.conf root 32122 0.0 0.0 5128 676 pts/2 R+ 16:39 0:00 grep redis
?
? ? ? ㈣ 測試 Redis
?
?
# redis-cli redis 127.0.0.1:6379> set name "David Lin" OK redis 127.0.0.1:6379> get name "David Lin" redis 127.0.0.1:6379> hset 192.168.1 David David@redis (integer) 1 redis 127.0.0.1:6379> hget 192.168.1 David "David@redis" redis 127.0.0.1:6379> hset 192.168.1 root root@redis (integer) 1 redis 127.0.0.1:6379> hget 192.168.1 root "root@redis" redis 127.0.0.1:6379> hkeys 192.168.1 1) "David" 2) "root" redis 127.0.0.1:6379> hvals 192.168.1 1) "David@redis" 2) "root@redis" redis 127.0.0.1:6379> hgetall 192.168.1 1) "David" 2) "David@redis" 3) "root" 4) "root@redis" redis 127.0.0.1:6379> type name string redis 127.0.0.1:6379> type 192.168.1 hash redis 127.0.0.1:6379> quit
?
? ? ? ㈤ 關閉 Redis?
?
?
# redis-cli shutdown
?
? ? ? ㈥ 可能的錯誤
? ? ? ??
? ? ? ? 安裝過程、或許您可能會有幸遇見:
?
?
zmalloc.o: In function `zmalloc_used_memory': /root/redis/redis-2.6.13/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4' collect2: ld 返回 1 make[1]: *** [redis-server] 錯誤 1 make[1]: Leaving directory `/root/redis/redis-2.6.13/src' make: *** [all] 錯誤 2
?
? ? ?大概是內核有點老了、跟不上最新的Redis
?
?
[root@odd ~]# uname -r 2.6.18-308.el5xen
?
? ? ?解決方案:
? ? ?安裝最新版的Tcl
?
# wget http://nchc.dl.sourceforge.net/project/tcl/Tcl/8.6.0/tcl8.6.0-src.tar.gz # tar -zxv -f tcl8.6.0-src.tar.gz # cd tcl8.6.0 # cd unix # ./configure # make # make test # make install
?
? ? ?之后再做 2 件事:
? ? ?① 在src/Makefile開頭加 CFLAGS= -march=i686
? ? ?② 編輯src/.make-settings里的OPT,改為OPT=-O2 -march=i686
?
? ? ?行文至此、接近尾聲、安裝過程并不復雜、至于測試的命令嘛、下回更精彩 +_+
? ? ?
? ? ?Good Luck
? ? ?2013-05-30
? ? ?By David Lin?
?
更多文章、技術交流、商務合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
