linux系統下安裝單台Redis


注意:搭建redis前一定要安裝gcc

redis安裝方式一

1.安裝gcc命令:yum install -y gcc

#安裝gcc [root@localhost src]# yum install -y gcc #出現如下信息則安裝成功 Installed: gcc.x86_64 0:4.4.7-17.el6 Dependency Installed: cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-17.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6 Complete #查看gcc方式1 [root@localhost src]# gcc -v Using built-in specs. Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info...... Thread model: posix gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) #查看gcc方式2 [root@localhost src]# rpm -q gcc gcc-4.4.7-17.el6.x86_64

2.下載網址

redis官網地址:http://www.redis.io/

redis下載地址:http://download.redis.io/releases/

3.以centos6.5系統,redis3.2.4版本為例,把下載好的redis壓縮包傳到linxu系統中,進行解壓.

[root@localhost redis]# tar zxvf redis-3.2.4.tar.gz

4.編譯安裝,執行命令 make

#執行命令 [root@localhost redis-3.2.4]# make #出現以下信息則表示安裝完成 Hint: It's a good idea to run 'make test' ;)
 make[1]: Leaving directory `/usr/redis/redis-3.2.4/src'

5.啟動redis

[root@localhost redis-3.2.4]# src/redis-server

6.安裝出現錯誤情況

(1)執行make命令出現如下錯誤,則沒有安裝gcc,按照上面安裝方法安裝gcc

[root@localhost redis]# cd redis-3.2.4/
[root@localhost redis-3.2.4]# make cd src && make all sh: ./mkreleasehdr.sh: Permission denied make[1]: Entering directory `/usr/redis/redis-3.2.4/src' rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html (cd ../deps && make distclean) make[2]: Entering directory `/usr/redis/redis-3.2.4/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd geohash-int && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) make[2]: Leaving directory `/usr/redis/redis-3.2.4/deps' (rm -f .make-*) echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings echo WARN=-Wall -W >> .make-settings echo OPT=-O2 >> .make-settings echo MALLOC=jemalloc >> .make-settings echo CFLAGS= >> .make-settings echo LDFLAGS= >> .make-settings echo REDIS_CFLAGS= >> .make-settings echo REDIS_LDFLAGS= >> .make-settings echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -O2 -g -ggdb -I../deps/geohash-int -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings (cd ../deps && make hiredis linenoise lua geohash-int jemalloc) make[2]: Entering directory `/usr/redis/redis-3.2.4/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd geohash-int && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) (echo "" > .make-ldflags) (echo "" > .make-cflags) MAKE hiredis cd hiredis && make static make[3]: Entering directory `/usr/redis/redis-3.2.4/deps/hiredis' gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c make[3]: gcc: Command not found make[3]: *** [net.o] Error 127 make[3]: Leaving directory `/usr/redis/redis-3.2.4/deps/hiredis' make[2]: *** [hiredis] Error 2 make[2]: Leaving directory `/usr/redis/redis-3.2.4/deps' make[1]: [persist-settings] Error 2 (ignored) CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/usr/redis/redis-3.2.4/src' make: *** [all] Error 2

 (2)執行maker出現如下錯誤,則沒有權限執行命令,要在 /src 目錄執行授權命令:chmod 777 mkreleasehdr.sh

#1.執行make報錯,則沒有權限執行命令 [root@localhost redis-3.2.4]# make cd src && make all sh: ./mkreleasehdr.sh: Permission denied make[1]: Entering directory `/usr/redis/redis-3.2.4/src'  CC adlist.o In file included from adlist.c:34: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory zmalloc.h:55:2: error: #error "Newer version of jemalloc required" make[1]: *** [adlist.o] Error 1 make[1]: Leaving directory `/usr/redis/redis-3.2.4/src' make: *** [all] Error 2 #2.授權 [root@localhost src]# chmod 777 mkreleasehdr.sh

 (3)執行make出現如下錯誤,則要配置變量

#1.錯誤信息 make[1]: Entering directory `/usr/redis/redis-3.2.4/src'  CC adlist.o In file included from adlist.c:34: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory zmalloc.h:55:2: error: #error "Newer version of jemalloc required" make[1]: *** [adlist.o] Error 1 make[1]: Leaving directory `/usr/redis/redis-3.2.4/src' make: *** [all] Error 2 #2.添加變量 [root@localhost src]# make MALLOC=libc

(4)執行 make MALLOC=libc 命令報錯 或 還有其他錯誤,建議刪除redis所有文件重新裝,或者按照下面的方式安裝.

 

redis安裝方式二

1.在線下載redis(默認下載 /root 文件下)

[root@localhost ~]# wget http://download.redis.io/releases/redis-3.2.4.tar.gz

#要是出現如下錯誤則沒有配置好linux環境變量
#bash:command not found

2.新建一個redis文件夾,移動到指定文件夾下,進行解壓

#在/usr下面新建redis文件夾
[root@localhost usr]# mkdir redis
#移動文件 [root@localhost
~]# mv /root/redis-3.2.4.tar.gz /usr/redis #解壓文件 [root@localhost ~]# tar -xzvf redis-3.2.4.tar.gz

3.執行make編譯

[root@localhost redis-3.2.4]# make #出現以下信息則安裝完成 Hint: It's a good idea to run 'make test' ;)
 make[1]: Leaving directory `/usr/redis/redis-3.2.4/src'

4.啟動redis

#啟動后不會在后台運行,按Ctrl+C就會停止 [root@localhost redis-3.2.4]# src/redis-server #加&符號啟動后在后台運行 [root@localhost redis]# src/redis-server &

5.啟動成功

6.查看redis版本號

進入redis的安裝目錄src下面

#方式1 [root@svr-zk src]# redis-cli -v redis-cli 3.2.4 #方式2 [root@svr-zk src]# redis-cli --version redis-cli 3.2.4 #方式3 [root@svr-zk src]# redis-server -v Redis server v=3.2.4 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=54077ebb4b018819

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM