RabbitMQ环境变量设置

RabbitMQ的配置可以由三种方式进行定制。

环境变量

配置文件

运行时参数和策略

(1)环境变量:

定义端口、配置文件的位置(rabbitmq.config)和名值对(可以通过shell,也可以通过rabbitmq-env.conf)

rabbitmq-env.conf文件的位置是固定的${RabbitMQ-PREFIX}/etc/rabbitmq/rabbitmq-env.conf,不可改变。

rabbitmq-env.conf定义的变量会覆盖rabbitmq启动脚本的内置参数。

环境变量中的rabbitmq参数和rabbitmq-env.conf是一致的。(环境变量中的参数都有RABBITMQ_前缀)

#example rabbitmq-env.conf file entries
#Rename the node
NODENAME=bunny@myhost
#Config file location and new filename bunnies.config
CONFIG_FILE=/etc/rabbitmq/testdir/bunnies
rabbitmq的变量优先级:

shell环境变量->rabbitmq-env.conf->内置变量值

Name Default Description
RABBITMQ_NODE_IP_ADDRESS the empty string - meaning bind to all network interfaces. Change this if you only want to bind to one network interface.
RABBITMQ_NODE_PORT 5672  
RABBITMQ_NODENAME
  • Unix*: rabbit@$HOSTNAME
  • Windows:rabbit@%COMPUTERNAME%
The node name should be unique per erlang-node-and-machine combination. To run multiple nodes, see theclustering guide.
RABBITMQ_SERVICENAME Windows Service: RabbitMQ The name of the installed service. This will appear in services.msc.
RABBITMQ_CONSOLE_LOG Windows Service: Set this variable to new or reuse to redirect console output from the server to a file named%RABBITMQ_SERVICENAME%.debug in the default RABBITMQ_BASE directory.
  • If not set, console output from the server will be discarded (default).
  • new A new file will be created each time the service starts.
  • reuse The file will be overwritten each time the service starts.
RABBITMQ_CTL_ERL_ARGS None Parameters for the erl command used when invoking rabbitmqctl. This should be overridden for debugging purposes only.
RABBITMQ_SERVER_ERL_ARGS
  • Unix*: "+K true +A30 +P 1048576 -kernel inet_default_connect_options [{nodelay,true}]"
  • Windows: None
Standard parameters for the erlcommand used when invoking the RabbitMQ Server. This should be overridden for debugging purposes only.
RABBITMQ_SERVER_START_ARGS None Extra parameters for the erl command used when invoking the RabbitMQ Server. This will not overrideRABBITMQ_SERVER_ERL_ARGS.

rabbitmq-env.conf还定义了一些列环境变量指出RabbitMQ的数据库文件、日志文件、插件、配置文件的地址。

Name Description
RABBITMQ_BASE This base directory contains sub-directories for the RabbitMQ server's database and log files. Alternatively, set RABBITMQ_MNESIA_BASEand RABBITMQ_LOG_BASE individually.
RABBITMQ_CONFIG_FILE The name of the configuration file, without the .config extension. If the configuration file is present it is used by the server to configure RabbitMQ components. This file is also used to auto-configure RabbitMQ clusters.
RABBITMQ_MNESIA_BASE This base directory contains sub-directories for the RabbitMQ server's Mnesia database files, one for each node, unlessRABBITMQ_MNESIA_DIR is set explicitly. (In addition to Mnesia files this location also contains message storage and index files as well as schema and cluster details.)
RABBITMQ_MNESIA_DIR The directory where this RabbitMQ node's Mnesia database files are placed. (In addition to Mnesia files this location also contains message storage and index files as well as schema and cluster details.)
RABBITMQ_LOG_BASE This base directory contains the RabbitMQ server's log files, unlessRABBITMQ_LOGS or RABBITMQ_SASL_LOGS are set explicitly.
RABBITMQ_LOGS The path of the RabbitMQ server's Erlang log file. This variable cannot be overridden on Windows.
RABBITMQ_SASL_LOGS The path of the RabbitMQ server's Erlang SASL (System Application Support Libraries) log file. This variable cannot be overridden on Windows.
RABBITMQ_PLUGINS_DIR The directory in which the plugins are found.
RABBITMQ_PLUGINS_EXPAND_DIR Working directory used to expand enabled plugins when starting the server.
RABBITMQ_ENABLED_PLUGINS_FILE This file records explicitly enabled plugins.
RABBITMQ_PID_FILE File in which the process id is placed for use by rabbitmqctl wait.

Name Location
RABBITMQ_BASE (Not used)
RABBITMQ_CONFIG_FILE $RABBITMQ_HOME/etc/rabbitmq/rabbitmq
RABBITMQ_MNESIA_BASE $RABBITMQ_HOME/var/lib/rabbitmq/mnesia
RABBITMQ_MNESIA_DIR $RABBITMQ_MNESIA_BASE/$RABBITMQ_NODENAME
RABBITMQ_LOG_BASE $RABBITMQ_HOME/var/log/rabbitmq
RABBITMQ_LOGS $RABBITMQ_LOG_BASE/$RABBITMQ_NODENAME.log
RABBITMQ_SASL_LOGS $RABBITMQ_LOG_BASE/$RABBITMQ_NODENAME-sasl.log
RABBITMQ_PLUGINS_DIR $RABBITMQ_HOME/plugins
RABBITMQ_PLUGINS_EXPAND_DIR $RABBITMQ_MNESIA_BASE/$RABBITMQ_NODENAME-plugins-expand
RABBITMQ_ENABLED_PLUGINS_FILE $RABBITMQ_HOME/etc/rabbitmq/enabled_plugins
RABBITMQ_PID_FILE $RABBITMQ_MNESIA_DIR.pid


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章