linux中redis安装步骤:
- 首先安装redis之前需要先安装一些依赖
yum install cpp yum install binutils yum install glibc
yum install glibc-kernheaders yum install glibc-common
yum install glibc-devel yum install gcc yum install make - 下载redis 在/usr/local目录下
wget http://download.redis.io/releases/redis-3.0.5.tar.gz - 解压
tar -zxvf redis-3.0.5.tar.gz
rm -rf redis-3.0.5.tar.gz - cd redis-3.0.5
- make
- make PREFIX=/usr/local/redis install
- 将redis在后端启动 接下来的配置
(1)拷贝: cp /usr/local/redis-3.0.5/redis.conf /usr/local/redis/bin
(2)打开/usr/local/redis/bin目录(cd /usr/local/redis/bin)下的redis.conf vim redis.conf
将文件中 daemonize 设置成 yes 即支持后台访问
(3)后端启动 ./redis-server redis.conf
安装成功后,springboot连接redis遇到的问题
首先redis超时没编写,导致出现连接失败
```
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=192.168.44.135
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=
# 连接超时时间(毫秒)
***spring.redis.timeout=5000***
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.jedis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.jedis.pool.min-idle=0
```
第二个是关于防火墙的问题,可以直接关闭,也可以添加某个端口号运行:
博主直接将其关闭
service iptables stop
chkconfig iptables off
第三个是MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persist on disk. Commands that may modify the data set are disabled, because this instance is configured to report errors during writes if RDB snapshotting fails (stop-writes-on-bgsave-error option). Please check the Redis logs for details about the RDB error出现了这种错误
引发原因
强制关闭Redis快照导致不能持久化
解决办法
两种修改方法:
1. 通过redis命令行修改
运行redis服务端 ./redis-server redis.conf
其次运行客户端 ./redis-cli
执行命令行修改:
127.0.0.1:6379> config set stop-writes-on-bgsave-error no
2. 修改redis.conf配置文件
vim打开redis-server配置的redis.conf文件,然后使用快捷匹配模式:/stop-writes-on-bgsave-error定位到stop-writes-on-bgsave-error字符串所在位置,接着把后面的yes设置为no就可以了。
这是目前我遇到的一些问题