RabbitMQ

 RabbitMQ Installation - config file

IT Help's profile image
IT Help posted Mar 13, 2019 01:46 PM

 

Hi Guys,

 

I have some issues with RabbitMQ config file(s); RabbitMQ is installed on Windows 2016 Server CORE 1607.

 

In the past months I’ve been setting up RabbitMQ Clusters on all our Dev environments but I’ve noticed that config file is saved on my %APPDATA% user which is not how it should be in an Enterprise environment…especially in Production.

 

I’ve seen the documentation for config-file-location https://www.rabbitmq.com/configure.html#config-file-location but probably I'm missing something...

 

For example, if I set RABBITMQ_BASE to a different location on the current servers which are already setup, I lose the clustering and all other settings, including Management UI and users; it doesn’t make a difference if I setup an environment variable on the OS for RABBITMQ_BASE.

 

I see the same behavior if I setup RABBITMQ_CONFIG_FILE environment variable within the OS.

In the documentation, there is no mention on when to set these variables so the config is not affected? Before RabbitMQ is installed of after? After is installed but before settings are done?

 

I understand that the .conf file is not created even if the environment variables are setup so when the config file is created manually I end up in the same loop of losing config which was done; it is even worse with the erlang cookie from %appdata% which is changing when conf file location is changed.

 

Is there a way to set the config location on installation time? what is the best approach?

 

Thank You.

Luke Bakken's profile image
Luke Bakken

Hello,

 

When you change environment variables they will not have an effect on the currently-installed RabbitMQ windows service. I suggest using the RABBITMQ_BASE variable in this manner:

 

Open the "RabbitMQ Command Prompt (sbin dir)" start menu item and run these commands:

.\rabbitmq-service.bat stop .\rabbitmq-service.bat remove

Then, set a system-wide environment variable RABBITMQ_BASE pointing to the directory of your choice. I suggest something like C:\ProgramData\RabbitMQ. You would then put your configuration file (rabbitmq.conf) in that directory. Other RabbitMQ directories will be created there when the service starts up. However, if you wish to preserve existing configuration you would copy all of the files and directories from %AppData%\RabbitMQ to C:\ProgramData\RabbitMQ at this time.

 

Then, open a new "RabbitMQ Command Prompt (sbin dir)" prompt and run the following. The first echo command is to verify that the new variable has been set correctly:

echo %RABBITMQ_BASE% .\rabbitmq-service.bat install .\rabbitmq-service.bat start

At this point, you can then check the log file to ensure that the expected configuration file was loaded. There will be a log line that looks like this:

config file(s) : c:/ProgramData/RabbitMQ/rabbitmq.conf

If you set RABBITMQ_BASE prior to the initial installation of RabbitMQ it will be picked up during install time.

 

None of these settings affects the Erlang cookie file location. For the user who runs rabbitmqctl.bat commands via the "RabbitMQ Command Prompt (sbin dir)" prompt the cookie must be in C:\Users\USERNAME\.erlang.cookie and it must match the cookie used by RabbitMQ and stored in C:\Windows\system32\config\systemprofile\.erlang.cookie

 

Please see https://www.rabbitmq.com/cli.html#cookie-file-locations for more information about the cookie.

 

Thanks,

Luke

IT Help's profile image
IT Help

Hi Luke,

 

Thank you.

I tested now on DEV Servers with no queues and I had to restart the server after addin​g the ENV Variable; so my steps were:

 

1) .\rabbitmq-service.bat stop

2) .\rabbitmq-service.bat remove

3)  Create ENV Variable  RABBITMQ_BASE : C:\ProgramData\RabbitMQ

4)  Create RabbitMQ Folder under C:\ProgramData

5)  Restart Server

6) Check ENV variable: echo %RABBITMQ_BASE%  ( cli result: C:\ProgramData\RabbitMQ)

7) Copy all files from %AppData%\RabbitMQ to C:\ProgramData\RabbitMQ

8) .\rabbitmq-service.bat install

9) .\rabbitmq-service.bat start

 

I will test on other Dev Servers with queues to see if everything remains the same + I will test with RABBITMQ_BASE variable set before RabbitMQ first install. I am surprised that this is not part of the install for such enterprisey software...Notepad++ has it :).

 

Also, does it make a difference if config file remains on the same disk\partition where rabbitmq is installed? (e.g. C:\ )  or can it be moved on a different disk\partition ( e.g E:\ )...just the config files.

 

Luke Bakken's profile image
Luke Bakken

> I am surprised that this is not part of the install for such enterprisey software

 

Most users don't customize the data location for RabbitMQ for Windows. At some point we might re-visit the Windows installation experience but the team is small and other items are higher priority.

 

You can set RABBITMQ_BASE to any drive that is available.

IT Help's profile image
IT Help

Still building my conf file trying to do the LDAP and cluster with conservative mirroring ( which seems the easy way atm )

 

Regarding the configuration file why the example which comes with the installation does contain the rabbitmq.config.example rather than rabbitmq.conf.example

 

As far as I can see rabbitmq is moving away from classic conf format but then the .conf file is not added.

 

I will use this one from github ( https://github.com/rabbitmq/rabbitmq-server/blob/master/docs/rabbitmq.conf.example )

 

IT Help's profile image
IT Help

Also is worth mentioning that even with a fresh install, if the .conf or .config file doesn't exist, the reinstall process of rabbitmq service needs to be done once the .conf or .config file is created.

 

 

This looks pretty backwards to me especially that the .conf or .config file is not created by default.

 

So, if you build a fresh Windows Server, set the Environment Variables and then install RabbitMQ you have to stop-->reinstall-->start rabbitmq service once you add the .conf or config file :).

 

 

Trying to create an automated process to build the RabbitMQ Servers and the best way seems to be:

 

 

Build Windows Server

Setup Environment Variables:

 

  • Name: ERLANG_HOME Value:C:\Program Files\erl10.1
  • Name: RABBITMQ_BASE Value:C:\ProgramData\RabbitMQ

 

    Optional, Edit the Path under Environment Variables and add:

 

  •    ;C:\Program Files\erl10.1\bin;C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.11\sbin

 

Install Erlang

Create Folder RabbitMQ under C:\Program Data

Copy .conf or .config file to the newly created folder C:\Program Data\RabbitMQ

Install RabbitMQ

Luke Bakken's profile image
Luke Bakken

Thanks for reporting back. The RabbitMQ team will consider improving the experience when non-standard Windows installations are used. If you'd like to improve the documentation for Windows installation, pull requests are gladly accepted here: https://github.com/rabbitmq/rabbitmq-website/pulls