Define RabbitMQ policies in configuration file

前端 未结 5 998
清歌不尽
清歌不尽 2021-02-02 12:50

I\'d like to define mirroring for all my queues by default. I currently have to use rabbitmqctl once the node is up:

rabbit         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 13:28

    To add more details to IvanD's answer, this is how I did it.

    First: sudo nano /etc/rabbitmq/rabbitmq.config (this command might be different depending on your OS)

    [
      {rabbit,
        [
            {default_vhost,<<"/">>},
            {default_user,<<"someuser">>},
            {default_pass,<<"somepassword">>},
            {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
            {default_user_tags, [administrator]}
        ]
      },
      {rabbitmq_management,
        [{listener, [{port, 15672}]},
            {load_definitions, "/etc/rabbitmq/rabbitmq_definitions.json"},
            {http_log_dir, "/var/log/rabbitmq/management_http.log"}]
      }
    ].
    

    Then create the additional json: sudo nano /etc/rabbitmq/rabbitmq_definitions.json (this command might be different depending on your OS). Its content:

    {
      "vhosts":[
            {"name":"/"}
      ],
      "policies":[
            {"vhost":"/","name":"ha","pattern":"", "definition":{"ha-mode":"all","ha-sync-mode":"automatic","ha-sync-batch-size":5}}
      ]
    }
    

    IMPORTANT NOTE: The ha-sync-batch-size is only supported in RabbitMQ versions above 3.6.0! https://www.rabbitmq.com/ha.html#sync-batch-size If your Rabbit is older than that, remove the setting from the rabbitmq_definitions.json.

    I'm using Ubuntu 14.04 Trusty and RabbitMQ v.3.6.2.

提交回复
热议问题