1. 程式人生 > >使用Docker-Compose搭建Rabbitmq叢集

使用Docker-Compose搭建Rabbitmq叢集

1.使用映象搭建叢集,docker-compose.xml配置見下面的github具體配置

2.如果需要跨伺服器,參考

具體變更如下:

說完埠,下面提供一個三節點的docker-compose檔案。

rabbit1(10.106.136.7)

1

2

3

4

5

6

7

8

9

10

11

12

rabbit1:

  image: bijukunjummen/rabbitmq-server

  hostname: rabbit1

  ports:

    - "5672:5672"

    - "4369:4369"

    - "1883:1883"

    - "15672:15672"

    - "25672:25672"

  environment:

    - RABBITMQ_DEFAULT_USER=myuser

    - RABBITMQ_DEFAULT_PASS=mypass

rabbit2(10.106.136.8)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

rabbit2:

  image: bijukunjummen/rabbitmq-server

  hostname: rabbit2

  extra_hosts:

    - "rabbit1:10.106.136.7"

  environment:

   - CLUSTERED=true

   - CLUSTER_WITH=rabbit1

   - RAM_NODE=true

  ports:

      - "5672:5672"

      - "4369:4369"

      - "1883:1883"

      - "15672:15672"

      - "25672:25672"

rabbit3(10.106.136.9)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

rabbit3:

  image: bijukunjummen/rabbitmq-server

  hostname: rabbit3

  extra_hosts:

    - "rabbit1:10.106.136.7"

    - "rabbit2:10.106.136.8"

  environment:

   - CLUSTERED=true

   - CLUSTER_WITH=rabbit1

   - RAM_NODE=true

  ports:

        - "5672:5672"

        - "4369:4369"

        - "1883:1883"

        - "15672:15672"

        - "25672:25672"

好了,叢集環境搭建好了,具體怎麼用spring boot連線,我在後續文章會在說明。