首先 看看 rabbitmq-env.conf 由于本人也没有碰过 rabbitmq-env.conf 这个文件所以我也 翻了一下官网,看看这个文件是怎么一回事,因为在参考的学习的书本 rabbitmq in action 中的管理rabbit 的章节当中,并没有提及到 rabbitmq-env.conf 文件 只有提及 rabbitma.config 。以下是官网对 rabbitmq-env.conf 文件的介绍 我这里就引用一下。
Namerabbitmq-env.conf — default settings for RabbitMQ AMQP server
Description/etc/rabbitmq/rabbitmq-env.conf contains variable settings that override the defaults built in to the RabbitMQ startup scripts.
The file is interpreted【解析】 by the system shell, and so should consist of a sequence【线性】 of shell environment【环境】 variable【变量】 definitions【定义】. Normal shell syntax【语法】 is permitted (since the file is sourced using the shell “.” operator), including line comments starting with “#”.
In order of preference【偏好】, the startup scripts get their values from the environment, from /etc/rabbitmq/rabbitmq-env.conf and finally from the built-in default values. For example, for the RABBITMQ_NODENAME setting,
RABBITMQ_NODENAME
from the environment is checked first. If it is absent【缺失】 or equal to the empty string, then
NODENAME
from /etc/rabbitmq/rabbitmq-env.conf is checked. If it is also absent or set equal to the empty string then the default value from the startup script is used.
The variable names in /etc/rabbitmq/rabbitmq-env.conf are always equal to the environment variable names, with the RABBITMQ_ prefix removed: RABBITMQ_NODE_PORT from the environment becomes NODE_PORT in the /etc/rabbitmq/rabbitmq-env.conf file, etc.
英文跟我一样一般般的看这里,我解释一下:
其实就是说 一般情况下RabbitMQ会有所有环境变量的默认值,他会检查rabbitmq-env.conf这个文件并且如果缺失的参数或者参数为空字符串都会以默认的参数值为准。其实看看官方的英文解析对以后学习很大帮助 我也是努力地去看。
这是官方给出来���example
# I am a complete /etc/rabbitmq/rabbitmq-env.conf file. # Comment lines start with a hash character. # This is a /bin/sh script file - use ordinary envt var syntax NODENAME=hare但是我在我的MacBook 上寻找了非常多的方法,也无法让配置生效,由于我是用brew命令进行安装的rabbitmq 固然我看了一下文档 不应该在 /etc/rabbitmq/这个目录下去建立这个变量文件,所有我就开始郁闷了。我看了一下文档是这样去写那个位置的:
Generic UNIX - $RABBITMQ_HOME/etc/rabbitmq/rabbitmq-env.conf Debian - /etc/rabbitmq/rabbitmq-env.conf RPM - /etc/rabbitmq/rabbitmq-env.conf Mac OS X (Homebrew) - ${install_prefix}/etc/rabbitmq/rabbitmq-env.conf, the Homebrew prefix is usually /usr/local Windows - %APPDATA%\RabbitMQ\rabbitmq-env-conf.bat说明配置文件应该在那个目前当中去建立,最终我找到安装的目录:
MacBook-Pro:rabbitmq Tony$ ls -al /usr/local/sbin/ total 48 drwxrwxrwx 8 root wheel 272 10 27 11:16 . drwxr-xr-x 25 root wheel 850 10 27 11:13 .. lrwxr-xr-x 1 Tony wheel 47 10 27 11:16 rabbitmq-defaults -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-defaults lrwxr-xr-x 1 Tony wheel 42 10 27 11:16 rabbitmq-env -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-env lrwxr-xr-x 1 Tony wheel 46 10 27 11:16 rabbitmq-plugins -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-plugins lrwxr-xr-x 1 Tony wheel 45 10 27 11:16 rabbitmq-server -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmq-server lrwxr-xr-x 1 Tony wheel 43 10 27 11:16 rabbitmqadmin -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmqadmin lrwxr-xr-x 1 Tony wheel 41 10 27 11:16 rabbitmqctl -> ../Cellar/rabbitmq/3.5.6/sbin/rabbitmqctl