1.下載下傳安裝包
[[email protected] opt]# yum install wget
[[email protected] opt]# wget http://download.redis.io/releases/redis-4.0.13.tar.gz
2.解壓安裝包
[[email protected] opt]# tar xzf redis-4.0.13.tar.gz
[[email protected] opt]# ls
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL1UjM2ATN0ATMy0SM0gTM0EjMzEzMyIDM5EDMy0iN3kTN0QTMvwlMwkTMwIzLcZzN5UDN0EzLcd2bsJ2Lc12bj5ycn9Gbi52YugTMwIzZtl2Lc9CX6MHc0RHaiojIsJye.png)
3.切換到安裝目錄
[[email protected] opt]# cd redis-4.0.13
[[email protected] redis-4.0.13]# ls
4.編譯安裝
[[email protected] redis-4.0.13]# make
5.啟動redis服務
[[email protected] redis-5.0.3]# src/redis-server redis.conf
6.添加環境變量
[[email protected] src]# vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
export REDIS_HOME=/opt/redis-5.0.3/
export PATH=$PATH:$REDIS_HOME/src
#PATH=$PATH:$HOME/bin
#export PATH
7.使環境變量生效
source ~/.bash_profile
8.測試,在任何位置登入redis
[[email protected] ~]# redis-server
[[email protected] ~]# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set name apollo
OK
127.0.0.1:6379> get name
"apollo"
9.啟動redis用戶端
#1.登入本機redis
[[email protected] redis-5.0.3]# src/redis-cli
#2.指定伺服器ip(不指定時,預設本機)
[[email protected] redis-5.0.3]# src/redis-cli -h 127.0.0.1
#3.指定端口(不指定時,預設6379)
redis-cli -h 127.0.0.1 -p 6378
10. 安裝過程遇到問題
1.若出現如下提示,則說明未安裝gcc,使用指令安裝yum -y install gcc gcc-c++ libstdc++-devel
[[email protected] redis-4.0.11]# make
cd src && make all
make[1]: Entering directory `/root/redis-4.0.11
/src‘ CC adlist.o /bin/sh: cc: command not found make[1]: *** [adlist.o] Error 127 make[1]: Leaving directory `/root/redis-2.8.17/src‘ make: *** [all] Error 2
2.若出現如下提示,則将make改為make MALLOC=libc,推測是因為編譯庫的問題。
[[email protected] redis-4.0.11]# make
cd src && make all
make[1]: Entering directory `/root/redis-2.8.17/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 `/root/redis-2.8.17/src‘
make: *** [all] Error 2
轉載于:https://www.cnblogs.com/apollo1616/p/10422578.html