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

docker-compose安裝redis集群教程

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

docker-compose安裝redis集群

1、安裝docker-compose命令

此處略過

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é)點無密碼;在同路徑下創(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)建,則需要手動執(zhí)行,如下:

  • 步驟1、通過命令找到redis集群中的一臺,執(zhí)行:docker ps -a  命令,找到docker容器id
  • 步驟2、執(zhí)行bash命令:docker exec -it 2b93cf1f4c4f bash,進入控制臺
  • 步驟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)建成功,可以通過redis管理工具連接

6、問題排查

采用docker compose安裝redis集群,端口正常啟動,無法連接

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

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

如果執(zhí)行 “步驟3” 時出現(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é)點的數(shù)據(jù) data,重新執(zhí)行命令進行集群創(chuàng)建。

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

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

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

如:

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é)

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

相關(guān)文章

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

最新評論

焦作市| 随州市| 客服| 和政县| 丹阳市| 吴川市| 盐亭县| 石林| 广水市| 三门县| 宁津县| 连州市| 基隆市| 呈贡县| 武隆县| 桃江县| 安溪县| 故城县| 广德县| 米泉市| 南川市| 沙河市| 星子县| 南安市| 遵义县| 泰兴市| 汝阳县| 邓州市| 长岭县| 运城市| 武平县| 嘉义县| 通城县| 大同市| 南涧| 积石山| 十堰市| 上林县| 海兴县| 荆门市| 高密市|