RabbitMQ环境变量设置

本文介绍了RabbitMQ的配置方式,重点讲解了如何通过环境变量进行定制,包括定义端口、配置文件位置及名值对的设置。RabbitMQ-env.conf文件用于存放环境变量,其设置会覆盖启动脚本的内置参数,且环境变量中的RABBITMQ_开头的参数与rabbitmq-env.conf中一致。此外,该文件还规定了数据库、日志和插件等路径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值