编辑
2023-11-14
redis
00

模版文件

yaml
port 6379 bind 0.0.0.0 protected-mode no daemonize no appendonly yes cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 15000 cluster-announce-ip 172.19.0.1${NO} cluster-announce-port 6379 cluster-announce-bus-port 16379

生成脚本

yaml
for no in `seq 1 6`; do \ mkdir -p redis-${no}/conf \ && NO=${no} envsubst < redis-cluster.tmpl > redis-${no}/conf/redis.conf \ && mkdir -p redis-${no}/data;\ done

docker-compose.yaml文件

yaml
# 描述 Compose 文件的版本信息 version: "3.8" # 定义服务,可以多个 services: redis-cluster: image: redis:latest networks: redis: ipv4_address: 172.19.0.2 command: redis-cli --cluster create 172.19.0.11:6379 172.19.0.12:6379 172.19.0.13:6379 172.19.0.14:6379 172.19.0.15:6379 172.19.0.16:6379 --cluster-replicas 1 --cluster-yes depends_on: - redis-1 - redis-2 - redis-3 - redis-4 - redis-5 - redis-6
编辑
2023-11-14
SpringBoot
00
xml
<dependency> <groupId>o
编辑
2023-11-14
英语学习
00

There are several reasons why learning Redis can be beneficial:

  1. High Performance: Redis is an in-memory data store that offers fast read and write operations. It is designed to handle millions of operations per second, making it suitable for use cases that require high-performance data storage and retrieval.
编辑
2023-11-14
Redis源码阅读
00

首先来看一下dict结构体,是redis的哈希表实现,这里重要的是渐进式rehash。rehash就是扩容操作,防止链变长严重影响哈希表的性能。

type:指向字典类型结构(dictType)的指针,该结构定义了字典的操作函数,如插入、查找、删除等。

编辑
2023-11-13
数据结构与算法
00

哈希洪水攻击(Hash-Flooding Attack)是一种拒绝服务攻击(Denial of Service),旨在使服务器陷入瘫痪。攻击者利用哈希表数据结构的特性,通过构造大量具有相同哈希值的输入数据,使服务器在处理这些数据时消耗大量的计算资源和内存,导致服务器无法正常响应其他合法请求。

哈希洪水攻击的原理是利用哈希表中的哈希冲突(碰撞)问题。在哈希表中,不同的键(Key)通过哈希函数映射到不同的位置,但由于哈希函数的限制,不同的键可能会映射到相同的位置,即发生哈希冲突。当攻击者构造大量具有相同哈希值的输入数据时,这些数据会被存储在哈希表的同一个位置上,导致哈希表的性能急剧下降,服务器无法正常处理其他请求。