Redis 環境的安裝與測試

jopen 11年前發布 | 14K 次閱讀 Redis NoSQL數據庫

     Redis 是 key-value 的NOSQL、獨愛那些小而熱的數據、典型"蘿莉控"
     至于啥叫 key-value 呢?用RDBMS的觀點、一言以辟之:
     所謂 key:主鍵列
     所謂 value:其他列
     Redis 近幾年很火、火到抬頭不見、低頭見
     抬頭望國外:著名成人網站 youporn 采用 100% Redis 每天 1億 PV、解決了無數屌絲 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 </pre>


     ㈡ 設置 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</pre>

     ㈢ 啟動 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</pre>

     ㈣ 測試 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</pre>

     ㈤ 關閉 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 </pre>


     之后再做 2 件事:

     ① 在src/Makefile開頭加 CFLAGS= -march=i686
     ② 編輯src/.make-settings里的OPT,改為OPT=-O2 -march=i686


     行文至此、接近尾聲、安裝過程并不復雜、至于測試的命令嘛、下回更精彩 +_+


     

來自:http://blog.csdn.net/linwaterbin/article/details/8996029

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!