最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

docker-compose安裝redis集群教程

 更新時(shí)間:2025年08月19日 10:59:33   作者:下一個(gè)明天_tgm  
本文介紹了使用Docker Compose部署Redis集群的步驟:編寫配置文件設(shè)置端口和密碼,創(chuàng)建數(shù)據(jù)卷目錄,啟動(dòng)容器并檢查狀態(tài),若集群創(chuàng)建失敗,需手動(dòng)進(jìn)入容器執(zhí)行redis-cli命令,處理密碼認(rèn)證及數(shù)據(jù)清空問(wèn)題以完成集群配置

docker-compose安裝redis集群

1、安裝docker-compose命令

此處略過(guò)

2、編寫docker-compose.yml文件

version: '2.2'

services:
  redis-node1:
    image: redis:5.0
    ## --cluster-announce-ip 你的公網(wǎng)IP 這部分參數(shù) 

    command: redis-server --port 7000 --requirepass lingco --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind 0.0.0.0  --cluster-announce-ip 192.168.1.10
    ports:
      - "7000:7000"
      - "17000:17000"
    volumes:
      - ./data/node1:/data
    networks:
      - redis-cluster

  redis-node2:
    image: redis:5.0
    command: redis-server --port 7001 --requirepass lingco --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind 0.0.0.0 --cluster-announce-ip 192.168.1.10
    ports:
      - "7001:7001"
      - "17001:17001"
    volumes:
      - ./data/node2:/data
    networks:
      - redis-cluster

  redis-node3:
    image: redis:5.0
    command: redis-server --port 7002 --requirepass lingco --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind 0.0.0.0 --cluster-announce-ip 192.168.1.10
    ports:
      - "7002:7002"
      - "17002:17002"
    volumes:
      - ./data/node3:/data
    networks:
      - redis-cluster

  redis-node4:
    image: redis:5.0
    command: redis-server --port 7003 --requirepass lingco --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind 0.0.0.0 --cluster-announce-ip 192.168.1.10
    ports:
      - "7003:7003"
      - "17003:17003"
    volumes:
      - ./data/node4:/data
    networks:
      - redis-cluster

  redis-node5:
    image: redis:5.0
    command: redis-server --port 7004 --requirepass lingco --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind 0.0.0.0 --cluster-announce-ip 192.168.1.10
    ports:
      - "7004:7004"
      - "17004:17004"
    volumes:
      - ./data/node5:/data
    networks:
      - redis-cluster

  redis-node6:
    image: redis:5.0
    command: redis-server --port 7005 --requirepass lingco --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind 0.0.0.0 --cluster-announce-ip 192.168.1.10
    ports:
      - "7005:7005"
      - "17005:17005"
    volumes:
      - ./data/node6:/data
    networks:
      - redis-cluster
  redis-init:
    image: redis:5.0
    command: >
      sh -c "redis-server --port 7000 --cluster-enabled yes --cluster-config-file /data/nodes.conf --appendonly yes --bind $$(hostname -i)
      && sleep 5
      && redis-cli --cluster create redis-node1:7000 redis-node2:7001 redis-node3:7002 redis-node4:7003 redis-node5:7004 redis-node6:7005 --cluster-replicas 1"
    depends_on:
      - redis-node1
    networks:
      - redis-cluster
      
  redis-node7:
    image: redis:5.0
    command: redis-server --port 7006 --appendonly yes --bind 0.0.0.0 --cluster-announce-ip 192.168.1.10 --cluster-announce-port 7006 --cluster-announce-bus-port 17006
    ports:
      - "7006:7006"
      - "17006:17006"
    volumes:
      - ./data/node7:/data

networks:
  redis-cluster:

備注:端口7000-7005為集群,密碼統(tǒng)一為 lingco,7006為單節(jié)點(diǎn)無(wú)密碼;在同路徑下創(chuàng)建 volumes配置的文件夾。

3、執(zhí)行docker compose命令

在docker-compose.yml目錄中執(zhí)行命令 docker-compose up -d,如果需要在其它目錄執(zhí)行,則需要指定配置文件yml的路徑。

4、查看執(zhí)行結(jié)果

5、創(chuàng)建集群

如果docker-compose.yml中command未執(zhí)行成功或是集群未創(chuàng)建,則需要手動(dòng)執(zhí)行,如下:

  • 步驟1、通過(guò)命令找到redis集群中的一臺(tái),執(zhí)行:docker ps -a  命令,找到docker容器id
  • 步驟2、執(zhí)行bash命令:docker exec -it 2b93cf1f4c4f bash,進(jìn)入控制臺(tái)
  • 步驟3、執(zhí)行創(chuàng)建集群:

redis-cli --cluster create 192.168.1.10:7000 192.168.1.10:7001 192.168.1.10:7002 192.168.1.10:7003 192.168.1.10:7004 192.168.1.10:7005 --cluster-replicas 1 -a lingco

備注:如果集群設(shè)置有密碼,則需要 -a 密碼(lingco),需要確認(rèn) 輸入 yes

集群創(chuàng)建成功,可以通過(guò)redis管理工具連接

6、問(wèn)題排查

采用docker compose安裝redis集群,端口正常啟動(dòng),無(wú)法連接

測(cè)試連接可以使用,使用庫(kù)號(hào)無(wú)法連接,出現(xiàn)如上問(wèn)題可能是 集群未創(chuàng)建成功,需要手動(dòng)執(zhí)行創(chuàng)建集群

通過(guò)上面 5 中的 步驟1,步驟2,步驟3,來(lái)執(zhí)行。

如果執(zhí)行 “步驟3” 時(shí)出現(xiàn)提示:

“[ERR] Node xxx is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.” 

則需要清空集群中所有節(jié)點(diǎn)的數(shù)據(jù) data,重新執(zhí)行命令進(jìn)行集群創(chuàng)建。

如果執(zhí)行 “步驟3” 時(shí)出現(xiàn)提示:

“[ERR] Node 192.168.1.10:7001 NOAUTH Authentication required.” 

則需要在命令中增加 -a參數(shù)來(lái)指定密碼,

如:

redis-cli --cluster create 192.168.1.10:7000 192.168.1.10:7001 192.168.1.10:7002 192.168.1.10:7003 192.168.1.10:7004 192.168.1.10:7005 --cluster-replicas 1 -a lingco

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Docker 容器文件系統(tǒng)詳細(xì)介紹(圖文)

    Docker 容器文件系統(tǒng)詳細(xì)介紹(圖文)

    這篇文章主要介紹了Docker 容器文件系統(tǒng)詳細(xì)介紹(圖文)的相關(guān)資料,這里對(duì)Docker 容器文件系統(tǒng)進(jìn)行了具體的分析詳解,需要的朋友可以參考下
    2016-12-12
  • Docker下SqlServer發(fā)布訂閱啟用的方法

    Docker下SqlServer發(fā)布訂閱啟用的方法

    發(fā)布訂閱主要用來(lái)做數(shù)據(jù)庫(kù)的讀寫分離,當(dāng)單臺(tái)數(shù)據(jù)庫(kù)的壓力太大時(shí),可以考慮這種方案,本文主要介紹了Docker下SqlServer發(fā)布訂閱啟用的方法,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-01-01
  • Docker部署Web在線版的PPT應(yīng)用程序PPTist

    Docker部署Web在線版的PPT應(yīng)用程序PPTist

    PPTist作為一款開(kāi)源的Web應(yīng)用程序,無(wú)需安裝、跨平臺(tái)且支持實(shí)時(shí)協(xié)作的幻燈片制作,本文介紹了如何使用Docker部署Web在線版的PPTist,包括本地環(huán)境規(guī)劃、檢查、下載PPTist鏡像、部署PPTist應(yīng)用以及訪問(wèn)PPTist首頁(yè)的步驟
    2025-02-02
  • Docker 網(wǎng)絡(luò)工作原理詳解

    Docker 網(wǎng)絡(luò)工作原理詳解

    這篇文章主要介紹了Docker 網(wǎng)絡(luò)工作原理的相關(guān)資料,這里對(duì)Docker的網(wǎng)絡(luò)工作進(jìn)行了詳細(xì)介紹,需要的朋友可以參考下
    2016-11-11
  • Docker部署Nginx設(shè)置環(huán)境變量的實(shí)現(xiàn)步驟

    Docker部署Nginx設(shè)置環(huán)境變量的實(shí)現(xiàn)步驟

    本文主要介紹了Docker部署Nginx設(shè)置環(huán)境變量的實(shí)現(xiàn)步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-07-07
  • Docker 安裝及配置鏡像加速的實(shí)現(xiàn)

    Docker 安裝及配置鏡像加速的實(shí)現(xiàn)

    這篇文章主要介紹了Docker 安裝及配置鏡像加速的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-01-01
  • docker中的python代碼打印失效的解決

    docker中的python代碼打印失效的解決

    這篇文章主要介紹了docker中的python代碼打印失效的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • 詳解docker國(guó)內(nèi)鏡像拉取和鏡像加速registry-mirrors配置修改

    詳解docker國(guó)內(nèi)鏡像拉取和鏡像加速registry-mirrors配置修改

    由于國(guó)內(nèi)訪問(wèn)直接訪問(wèn)Docker hub網(wǎng)速比較慢,拉取鏡像的時(shí)間就會(huì)比較長(zhǎng)。一般我們會(huì)使用鏡像加速或者直接從國(guó)內(nèi)的一些平臺(tái)鏡像倉(cāng)庫(kù)上拉取
    2017-05-05
  • 清理Docker廢棄鏡像與緩存詳細(xì)圖文教程

    清理Docker廢棄鏡像與緩存詳細(xì)圖文教程

    在使用Docker進(jìn)行開(kāi)發(fā)和部署過(guò)程中,我們可能會(huì)遇到需要?jiǎng)h除舊鏡像和容器以釋放磁盤空間或清除不再需要的緩存的情況,這篇文章主要給大家介紹了關(guān)于清理Docker廢棄鏡像與緩存的相關(guān)資料,需要的朋友可以參考下
    2024-07-07
  • docker 容器網(wǎng)絡(luò)模式詳解

    docker 容器網(wǎng)絡(luò)模式詳解

    這篇文章主要為大家介紹了docker 容器網(wǎng)絡(luò)模式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10

最新評(píng)論

瓦房店市| 永和县| 临泽县| 饶平县| 萨迦县| 无极县| 仙游县| 汶上县| 巴中市| 若尔盖县| 米泉市| 姚安县| 石渠县| 马龙县| 年辖:市辖区| 乌鲁木齐县| 四平市| 克什克腾旗| 东光县| 禄丰县| 湘潭市| 绥棱县| 左云县| 个旧市| 凤凰县| 苏尼特左旗| 叶城县| 荣昌县| 平湖市| 乌什县| 通许县| 凉山| 屯昌县| 土默特右旗| 壶关县| 谢通门县| 钟山县| 庄河市| 虞城县| 峨边| 永嘉县|