gameredis2

  • Konuyu açan Konuyu açan isthambul1453
  • Açılış Tarihi Açılış Tarihi
  • Yanıt Yanıt 0
  • Gösterim Gösterim 404

isthambul1453

Yasaklanmış Üye
Cezalı
Mesaj
354
Çözümler
3
Beğeni
250
Puan
764
Ticaret Puanı
0
paylaşıyorum yapmaya üşendim belki yapıp paylaşan olur diye

## Yapılacaklar
- Redis cluster cache entegrasyonu DB server tarafına ekle (player/items/quest/affect read-through).
- Yazma/invalidasyon akışı ekle (player save -> Redis yaz, item/quest/affect save -> Redis DEL).
- Redis client MOVED redirect desteği ekle.
- Redis binary-safe GET/SET/EXPIRE/DEL ekle.
- Cluster entrypoint `127.0.0.1:8091` olarak ayarla.
- `gameredisMetin2` klasörü oluştur; `redis-common.conf`, `conf/redis-*.conf`, `run.sh`, `data/`, `logs/` hazırla.
- Gerçek kurulum path’lerine göre `redis-common.conf`, `conf/redis-*.conf`, `run.sh` yollarını güncelle.
- Redis’i başlat ve cluster’ı oluştur (gerekirse `redis-cli --cluster create ...`).
- TTL değerini netleştir.
- hiredis kütüphanesini build ortamına ekle ve DB server’ı derle.
- İsteğe göre cache kapsamını genişlet (safebox, item_price, vb.).

Ortak conf (gameredis)

  • redis\gameredis\redis-common.conf
  • İçerik aynı kalmalı: cluster, AOF, timeout, slowlog vb. ortak ayarlar burada.
Node conf şablonu (gameredis)
Örnek: redis\gameredis\conf\redis-8091.conf
  • include yolu: kendi kurulum dizinine göre.
  • port: her node için farklı.
  • appendfilename, dbfilename, cluster-config-file: porta göre isimlendirme.
  • maxmemory: node başına RAM limitin.
  • dir: ortak conf içinde ayarlı (dir /ddd/redis/gameredis/data). Bu dizini kendi path’ine göre güncelle.

1773315361020.webp


1773316501925.webp


Ortak conf

Kod:
Genişlet Daralt Kopyala
include redis/gameredis/redis-common.conf
port 8091
maxmemory 1000m
maxmemory-policy allkeys-lru
appendfilename "appendonly-8091.aof"
dbfilename dump-8091.rdb
cluster-config-file nodes-8091.conf
auto-aof-rewrite-percentage 80-100

Örnek: yeni bir node için

Kod:
Genişlet Daralt Kopyala
include /path/to/redis-common.conf
port 8095
maxmemory 1000m
maxmemory-policy allkeys-lru
appendfilename "appendonly-8095.aof"
dbfilename dump-8095.rdb
cluster-config-file nodes-8095.conf
auto-aof-rewrite-percentage 80-100

redis-common.conf:
Genişlet Daralt Kopyala
# GENERAL
daemonize no
tcp-backlog 511
timeout 1000
tcp-keepalive 0
loglevel notice
databases 16
dir /ddd/redis/gameredisMetin2/data
slave-serve-stale-data yes
# slave只读
slave-read-only yes
# not use default
repl-disable-tcp-nodelay yes
slave-priority 100
# 打开aof持久化
appendonly yes
# 每秒一次aof写
appendfsync everysec
# 关闭在aof rewrite的时候对新的写操作进行fsync
no-appendfsync-on-rewrite yes
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
# 打开redis集群
cluster-enabled yes
# 节点互连超时的阀值
cluster-node-timeout 15000
cluster-migration-barrier 1
slowlog-log-slower-than 10000
slowlog-max-len 128
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

#包含通用配置
include /ddd/redis/gameredisMetin2/redis-common.conf
#监听tcp端口
port 8091
#最大可用内存
maxmemory 1000m
#内存耗尽时采用的淘汰策略:
# volatile-lru -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key accordingly to the LRU algorithm
# volatile-random -> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl -> remove the key with the nearest expire time (minor TTL)
# noeviction -> don't expire at all, just return an error on write operations
maxmemory-policy allkeys-lru
#aof存储文件
appendfilename "appendonly-8091.aof"
#不开启rdb存储,只用于添加slave过程
dbfilename dump-8091.rdb
#cluster配置文件(启动自动生成)
cluster-config-file nodes-8091.conf
#部署在同一机器的redis实例,把auto-aof-rewrite搓开,因为cluster环境下内存占用基本一致.
#防止同意机器下瞬间fork所有redis进程做aof rewrite,占用大量内存(ps:cluster必须开启aof)
auto-aof-rewrite-percentage 80-100
 
Son düzenleme:
Geri
Üst