**自
2023年08月24日 14:53:53 這兒很涼
1.springboot工程引入redis
org.springframework.boot
spring-boot-starter-data-redis
####redis的配置資訊###
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.nodes=host1:port1,host2:port2,...
spring.redis.password=password......
#採用哪個資料庫
spring.redis.database=0
# 連線池最大連線數,預設8個,(使用負值表示沒有限制)
spring.redis.pool.max-active=8
# 連線池最大阻塞等待時間(使用負值表示沒有限制)
spring.redis.pool.max-wait=-1
# 連線池中的最大空閒連線
spring.redis.pool.max-idle=8
# 連線池中的最小空閒連線
spring.redis.pool.min-idle=0
# 連線超時時間(毫秒)
spring.redis.timeout=0
3.注入使用
@autowired
private redistemplate redistemplate;
4.自定義redis序列化
import com.fasterxml.jackson.annotation.jsonautodetect;
import com.fasterxml.jackson.annotation.propertyaccessor;
import org.springframework.context.annotation.bean;
import org.springframework.context.annotation.configuration;
import org.springframework.data.redis.connection.jedis.jedisconnectionfactory;
import org.springframework.data.redis.core.redistemplate;
import org.springframework.data.redis.serializer.jackson2jsonredisserializer;
/*** 〈redis模板的相應配置自定義序列化〉
* @create 2018/8/24
* @since 1.0.0
*/@configuration
public class redisconfig
}5.採用自己的模板
@autowired
private redistemplateredistemplate;
搞定。。。。。。
redis之哨兵集群(2)
前面提到過,如果乙個哨兵在執行過程中發生故障,那麼是不是還能進行主從庫切換 實際上一旦多個例項組成了哨兵集群,即使有哨兵例項出現故障掛掉了,其他哨兵還能繼續協作完成主從庫切換的工作,包括判定主庫是不是處於下線狀態,選擇新主庫,以及通知從庫和客戶端。配置哨兵所用到的資訊 sentinel monito...
Redis高可靠之哨兵集群
a 在主從模式下,如果從庫跪了,客戶端可以繼續向其他從庫傳送請求,進行相關的操作,但是如果主庫跪了,就無法向主庫中寫資料,主庫中的資料也無法同步到從庫.對於高可靠的集群來說,肯定是不可取的.因此需要有乙個角色來做如下相關的事情 如下圖所示 而上述這些事情就是哨兵來做的.a 小菜,你問的問題越來越有水...
Redis 配置哨兵
關閉兩端 linux 的防火牆 service iptables stop關閉兩端 redis.conf 的受保護機制 protected mode no在從redis 中配置 replicaof 主 redis ip 埠拷貝解壓目錄下的配置檔案 sentinel.conf root admin r...