guns redis集群
时间: 2024-01-02 15:04:45 浏览: 47
根据提供的引用内容,我们可以得知guns redis集群的实现需要进行以下两个步骤:
1.在命令行中启动redis集群,具体步骤如下:
```shell
# 下载redis源码
wget http://download.redis.io/releases/redis-5.0.5.tar.gz
# 解压
tar xzf redis-5.0.5.tar.gz
cd redis-5.0.5
# 编译
make
# 启动redis集群
./src/redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
```
2.修改guns项目的配置文件,使其支持redis集群。具体步骤如下:
修改guns\guns-admin\src\main\resources\application.yml文件,添加以下配置:
```yaml
spring:
redis:
cluster:
nodes:
- 127.0.0.1:7000
- 127.0.0.1:7001
- 127.0.0.1:7002
- 127.0.0.1:7003
- 127.0.0.1:7004
- 127.0.0.1:7005
```
修改guns\guns-admin\src\main\java\com\stylefeng\guns\config\web\WebConfig.java文件,启用RedisHttpSession:
```java
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Bean
public RedisHttpSessionConfiguration redisHttpSessionConfiguration() {
RedisHttpSessionConfiguration configuration = new RedisHttpSessionConfiguration();
configuration.setMaxInactiveIntervalInSeconds(1800);
return configuration;
}
@Bean
public JedisConnectionFactory connectionFactory() {
JedisConnectionFactory connection = new JedisConnectionFactory();
connection.setHostName("127.0.0.1");
connection.setPort(6379);
return connection;
}
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)