1. 下载Redis
网址: download | Redis
进入网站之后不要选择最新版下载,点击第三个(更多选择)
点进来之后,选择上一个版本下载就好,因为最新版可能会出一些问题
2. 解压文件
将刚才下载好的压缩文件移动到local文件夹内
打开终端
# 进入 /usr/local
cd /usr/local
这里要根据自己的文件名来解压,每个人的文件名不一样(不要无脑复制)
# 解压
sudo tar -zxvf redis-6.2.13.tar.gz
将解压出来的文件重命名为redis目录(也可以不重命名)
# 重命名为 redis 目录
sudo mv redis-6.2.13/ redis
3. 安装与编译
在终端下继续操作
# 进入redis目录下
cd /usr/local/redis
然后执行以下代码,进行编译测试
sudo make test
等待一会,编译大有十分钟多,当出现以下这个字段,则表示编译成功!!!
成功以后,再执行redis安装
sudo make install
安装成功会出现下面的提示
4. 运行与连接
# 运行
src/redis-server
说明我前面已经启动过一次了
启动java项目报错异常
cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'captchaController': Unsatisfied dependency expressed through field 'configService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysConfigServiceImpl': Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379
14:10:49.029 [restartedMain] INFO c.a.d.p.DruidDataSource - [close,2138] - {dataSource-1} closing ...
14:10:49.033 [restartedMain] INFO c.a.d.p.DruidDataSource - [close,2211] - {dataSource-1} closed
14:10:49.171 [restartedMain] INFO o.a.c.c.StandardService - [log,173] - Stopping service [Tomcat]
需要启动redis