-
官网安装步骤:https://redis.io/download
-
安装
使用以下命令下载,提取和编译Redis:
wget http://download.redis.io/releases/redis-6.0.3.tar.gz
tar xzf redis-6.0.3.tar.gz
cd redis-6.0.3
make
make编译时出现错误:cc: command not foun
系统需要安装gcc环境
yum install gcc
make编译时再次持续错误:fatal error: jemalloc/jemalloc.h: No such file or directory
原因是由于上次编译失败,需要清理
make distclean
再次编译报错:error: ‘struct redisServer’ has no member named ‘fixed_time_expire’
出现这个原因的gcc 版本过低
# 查看gcc的版本:
gcc -v
#升级到 5.3及以上版本
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# scl命令启用只是临时的,推出xshell或者重启就会恢复到原来的gcc版本。
scl enable devtoolset-9 bash
# 需要永久有效需要修改配置文件:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
再次编译报错:You need tcl 8.5 or newer in order to run the Redis test
需要安装:tcl
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar xzvf tcl8.6.1-src.tar.gz
cd /usr/local/src/tcl8.6.1/unix
./configure
# 编译tcl
make
# 安装 tcl
make install
安装成功后:
需要到redis的目录下执行如下命令:
make test
经过上述操作后终于编译成功了。
- src 目录 中现在提供了已编译的二进制文件 。使用以下命令运行Redis:
src/redis-server
- 使用内置的客户端进行交互
src/redis-cli
- 使用java代码访问redis
报错:
#错误1
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients
## 错误2
Unable to connect to Redis
错误原因是:redis服务器需要设置可以访问的IP。
需要修改redis.conf配置文件:
如果所有的允许所有的IP访问可以设置:bind 0.0.0.0 ,不建议生成环境使用。