溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Redis怎么升級(jí)到容器化Redis-Sentinel集群

發(fā)布時(shí)間:2021-12-13 14:34:23 來(lái)源:億速云 閱讀:210 作者:iii 欄目:大數(shù)據(jù)

這篇文章主要介紹“Redis怎么升級(jí)到容器化Redis-Sentinel集群”,在日常操作中,相信很多人在Redis怎么升級(jí)到容器化Redis-Sentinel集群?jiǎn)栴}上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Redis怎么升級(jí)到容器化Redis-Sentinel集群”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

升級(jí)思路:
  1. 《     Docker-compose搭建Redis高可用哨兵集群》,這里將     Redis-Sentinel容器接入現(xiàn)有Docker Swarm overlay網(wǎng)絡(luò),規(guī)避Redis ClientApp訪問(wèn)不同網(wǎng)絡(luò)的Redis-Sentinel引發(fā)的混亂(因NAT轉(zhuǎn)換和Port映射)。
  2. 利用主機(jī)上現(xiàn)有Redis dump.rdb持久化文件快速啟動(dòng)Redis哨兵集群    
    (1 master:2slave:3 sentinel)
  3. 修改     receiver、     app的Redis連接字符串,驗(yàn)證     Redis怎么升級(jí)到容器化Redis-Sentinel集群
 

注意事項(xiàng)

  • 現(xiàn)有的應(yīng)用程序處于Docker Swarm Overlay網(wǎng)絡(luò),默認(rèn)是不允許附加其他容器,這里我們需要將該Overlay網(wǎng)絡(luò)配置成     可附加,方便Redis-Sentinel接入該網(wǎng)絡(luò),     所有容器同網(wǎng)絡(luò);為方便部署可將哨兵容器分配固定IP。
......
// 下面生成的overlay網(wǎng)絡(luò)名稱是:eqidstack_webnet
networks:
  webnet:
    driver: overlay
    attachable: true   // 將現(xiàn)有的overlay網(wǎng)絡(luò)配置為:可附加容器
.....
 
  • 官方Redis鏡像持久化數(shù)據(jù)存儲(chǔ)在:     /data, 本處我們需要將現(xiàn)有的主機(jī)Redis dump.rdb文件外掛進(jìn)Master容器。
# 下面是master/slave docker-compose.yml文件
version: '3.7'
services:
  master:
    image: redis
    container_name: redis-master
    command: redis-server  --requirepass zxcde@1  --masterauth zxcde@1
    volumes:
      - /home/redis-sentinel/redis/data:/data
    ports:
      - "6380:6379"
    networks:
      - webnet

  slave1:
    image: redis
    container_name: redis-slave-1
    ports:
      - "6381:6379"
    command:  redis-server --slaveof redis-master 6379 --masterauth zxcde@1  --requirepass zxcde@1
    networks:
      - webnet

  slave2:
    image: redis
    container_name: redis-slave-2
    ports:
      - "6382:6379"
    command: redis-server --slaveof redis-master 6379 --masterauth zxcde@1 --requirepass zxcde@1
    networks:
      - webnet
networks:
  webnet:
    external: true
    name: eqidstack_webnet      // 使用現(xiàn)有的Dokcer Overlay網(wǎng)絡(luò)
 
  • 經(jīng)過(guò)驗(yàn)證,StackExchange.Redis     最新版     本2.1.58 可以更簡(jiǎn)潔的方式支持Redis-sentinel,:
    只需更改原單點(diǎn)連接字符串,其中     10.0.7.41:26379,10.0.7.42:26379,10.0.7.43:26379是sentinel容器端點(diǎn),     serviceName為Sentinel配置的Maser/slave名稱。
"redis": "10.0.7.41:26379,10.0.7.42:26379,10.0.7.43:26379,serviceName=mymaster1,password=zxcde@1,abortConnect=false,connectTimeout=10000,writeBuffer=40960"
Redis怎么升級(jí)到容器化Redis-Sentinel集群到此,關(guān)于“Redis怎么升級(jí)到容器化Redis-Sentinel集群”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!
向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI