redis快速部署、集成、调优
redis快速部署、集成、调优
1.部署
1.1 docker部署
参考:https://blog.csdn.net/taotao_guiwang/article/details/135508643
1.2 redis部署
- 资源见,百度网盘:https://pan.baidu.com/s/1qlabJ7m8BDm77GbDuHmbNQ?pwd=41ac
- 执行redis_install.sh,开始部署:
# 赋权,在redis_install目录,执行:
chmod -R 777 .
# 执行
./redis_install.sh.sh
2. spring boot集成
核心代码,IndexController.java:
package com.redis;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class IndexController {private static final Logger logger = LoggerFactory.getLogger(IndexController.class);@Autowiredprivate StringRedisTemplate stringRedisTemplate;@RequestMapping("/test")public void testSentinel() throws InterruptedException {try {stringRedisTemplate.opsForValue().set("testKey", "testValue"); //jedis.set(key,value);System.out.println("设置key:"+ "testKey");}catch (Exception e){logger.error("错误:", e);}}}
application.yml:
server:port: 8080spring:redis:host: 10.86.97.210port: 6379database: 0timeout: 3000password: test@123456
# sentinel: #哨兵模式
# master: mymaster #主服务器所在集群名称
# nodes: 192.168.65.60:26379,192.168.65.60:26380,192.168.65.60:26381
# cluster:
# nodes: 192.168.50.61:8001,192.168.50.62:8002,192.168.50.63:8003,192.168.50.61:8004,192.168.50.62:8005,192.168.50.63:8006lettuce:pool:max-idle: 50min-idle: 10max-active: 100max-wait: 1000
浏览器访问:
http://localhost:8080/test
控制台打印:
redis desktop manager:
3.相关资源
百度网盘:https://pan.baidu.com/s/1qlabJ7m8BDm77GbDuHmbNQ?pwd=41ac