rabbitmq Introduction configuration

转载自:http://www.rabbitmq.com/configure.html#config-items

Configuration

RabbitMQ comes with default built-in settings which will most likely be sufficient[足够的,充分的] for running your RabbitMQ server effectively[有效的,生效的,有利的]. If it runs fine, then you probably don't need any configuration at all.

If you have other constraints[约束,限制,约束条件], RabbitMQ provides three general ways to customise[依照顾客具体要求而制造] the server:

environment variables
define ports, file locations and names (taken from the shell, or set in therabbitmq-env.conf file)
a configuration file
defines server component settings for permissions, limits and clusters, and also plugin settings.
runtime parameters and policies
defines cluster-wide settings which can change at run time

Verify[查证,核实,校验] Configuration

The active configuration can be verified in the startup banner, e.g. the active configuration file:

config file(s) : /etc/rabbitmq/rabbitmq.config
This may appear on the console or in a file, depending on how the broker was started:
  • Linux (when running as a service): see the startup_log file in the log directory;
  • MacOSX (Macports): see the startupitem.log file in the log directory;
  • Started as rabbitmq-server (without the -detached option): see console output;
  • Windows Service: enable RABBITMQ_CONSOLE_LOG and check the.debug file.
The startup banner is not available if the broker is started in detached[分离的,分开的] mode.

Customise RabbitMQ Environment

Unix (general)

On Unix-based systems (including Linux, MacOSX) you can create/editrabbitmq-env.conf to define environment variables. Itslocation is not configurable (unlikerabbitmq.config).

Use the standard environment variable names (but drop the RABBITMQ_ prefix) e.g.

#example rabbitmq-env.conf file entries
#Rename the node
NODENAME=bunny
#Config file location and new filename bunnies.config
CONFIG_FILE=/etc/rabbitmq/testdir/bunnies
More info on using rabbitmq-env.conf

Windows

If you need to customise names, ports, locations, it is easiest to configure environment variables in the Windows dialogue: Start > Settings > Control Panel > System > Advanced > Environment Variables.

Create or edit the system variable name and value. For environment changes to take effect, open a new Command Prompt, then restart the broker or re-install the service.

RabbitMQ Environment Variables

RabbitMQ environment variable names have the prefixRABBITMQ_. A typical variable called RABBITMQ_var_name is set as follows:

  • a shell environment variable called RABBITMQ_var_name is used if this is defined;
  • otherwise, a variable called var_name is used if this is set in therabbitmq-env.conf file;
  • otherwise, a system-specified default value is used.

In this way, variables set in the shell environment take priority over variables set inrabbitmq-env.conf, which in turn over-ride RabbitMQ built-in defaults.

It is unlikely you will need to set any of these environment variables. If you have non-standard requirements, then RabbitMQ environment variables include, but are not limited to:

NameDefaultDescription
RABBITMQ_NODE_IP_ADDRESSthe empty string - meaning bind to all network interfaces.Change this if you only want to bind to one network interface.
RABBITMQ_NODE_PORT5672 
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_SERVICENAMEWindows Service: RabbitMQThe name of the installed service. This will appear in services.msc.
RABBITMQ_CONSOLE_LOGWindows 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_ARGSNoneParameters 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: Not configurable
Standard parameters for the erl command used when invoking the RabbitMQ Server. This should be overridden for debugging purposes only.
RABBITMQ_SERVER_START_ARGSNoneExtra parameters for the erl command used when invoking the RabbitMQ Server. This will not overrideRABBITMQ_SERVER_ERL_ARGS.
* Unix, Linux, MacOSX

In addition, there are several environment variables which tell RabbitMQwhere to locate its database, log files, plugins, configuration etc.

Other variables upon which RabbitMQ depends are:

NameDefaultDescription
HOSTNAME
  • Unix, Linux: `env hostname`
  • MacOSX: `env hostname -s`
The name of the current machine
COMPUTERNAMEWindows: localhostThe name of the current machine
ERLANG_SERVICE_MANAGER_PATHWindows Service: %ERLANG_HOME%\erts-x.x.x\binThis path is the location of erlsrv.exe, the Erlang service wrapper script.

Configuration File

The rabbitmq.config File

The configuration file rabbitmq.config allows the RabbitMQ core application, Erlang services and RabbitMQ plugins to be configured. It is a standard Erlang configuration file, documented on theErlang Config Man Page.

An example configuration file follows:

  [
    {mnesia, [{dump_log_write_threshold, 1000}]},
    {rabbit, [{tcp_listeners, [5673]}]}
  ].

This example will alter the dump_log_write_threshold for mnesia (increasing from the default of 100), and alter the port RabbitMQ listens on from 5672 to 5673.

This configuration file is not the same as rabbitmq-env.conf, which can be used to set environment variables on non-windows systems. A future release of RabbitMQ will unify the two configuration mechanisms.

Location of rabbitmq.config and rabbitmq-env.conf

The location of these files is distribution-specific. By default, they are not created, but expect to be located in the following places on each platform:

  • Generic UNIX - $RABBITMQ_HOME/etc/rabbitmq/
  • Debian - /etc/rabbitmq/
  • RPM - /etc/rabbitmq/
  • Mac OS X (Macports) - ${install_prefix}/etc/rabbitmq/, the Macports prefix is usually/opt/local
  • Windows - %APPDATA%\RabbitMQ\

If rabbitmq-env.conf doesn't exist, it can be created manually in the default location only. It is not used on Windows systems.

If rabbitmq.config doesn't exist, it can be created manually. Set theRABBITMQ_CONFIG_FILE environment variable if you change the location. The Erlang runtime automatically appends the .config extension to the value of this variable.

Restart the server after changes. Windows service users need to takeadditional steps when changing plugins.

Variables Configurable in rabbitmq.config

Many users of RabbitMQ never need to change any of these values, and some are fairly[相当的] obscure[模糊的]. However, for completeness[完整性] they are all listed here.

KeyDocumentation
tcp_listenersList of ports on which to listen for AMQP connections (without SSL). Can contain integers (meaning "listen on all interfaces") or tuples such as{"127.0.0.1", 5672} to listen on a single interface.

Default: [5672]

ssl_listenersAs above, for SSL connections.

Default: []

ssl_optionsSSL configuration. See the SSL documentation.

Default: []

vm_memory_high_watermarkMemory threshold[入口,门槛] at which the flow control is triggered. See the memory-based flow control documentation.

Default: 0.4

disk_free_limitDisk free space limit of the partition on which RabbitMQ is storing data. When available disk space falls below this limit, flow control is triggered. The value may be set relative to the total amount of RAM (e.g.{mem_relative, 1.0}). The value may also be set to an integer number of bytes. By default free disk space must exceed 1GB. See thememory-based flow control documentation.

Default: 1000000000

log_levelsControls the granularity of logging. The value is a list of log event category and log level pairs.

The level can be one of 'none' (no events are logged), 'error' (only errors are logged), 'warning' (only errors and warning are logged), or 'info' (errors, warnings and informational messages are logged).

At present there is just one category defined - 'connection', for all events relating to network connections. Other, currently uncategorised, events are always logged.

Default: [{connection, info}]

frame_maxMaximum permissible size of a frame (in bytes) to negotiate with clients. Setting to 0 means "unlimited" but will trigger a bug in some QPid clients. Setting a larger value may improve throughput; setting a smaller value may improve latency.

Default: 131072

heartbeatValue representing the heartbeat delay, in seconds, that the server sends in theconnection.tune frame. If set to 0, heartbeats are disabled. Clients might not follow the server suggestion, see theAMQP reference for more details. Disabling heartbeats might improve performance in situations with a great number of connections, but might lead to connections dropping in the presence of network devices that close inactive connections.

Default: 600

default_vhostVirtual host to create when RabbitMQ creates a new database from scratch. The exchangeamq.rabbitmq.log will exist in this virtual host.

Default: <<"/">>

default_userUser name to create when RabbitMQ creates a new database from scratch.

Default: <<"guest">>

default_passPassword for the default user.

Default: <<"guest">>

default_user_tagsTags for the default user.

Default: [administrator]

default_permissionsPermissions to assign to the default user when creating it.

Default: [<<".*">>, <<".*">>, <<".*">>]

cluster_nodesSet this to cause clustering to happen automatically. The first element of the tuple is the nodes that the node will try to cluster to. The second element is eitherdisc or ram and determines the node type.

Default: {[], disc}

server_propertiesList of key-value pairs to announce to clients on connection.

Default: []

collect_statisticsStatistics collection mode. Primarily relevant for the management plugin. Options are:
  • none (do not emit statistics events)
  • coarse (emit per-queue / per-channel / per-connection statistics)
  • fine (also emit per-message statistics)
You probably don't want to change this yourself.

Default: none

collect_statistics_intervalStatistics collection interval in milliseconds. Primarily relevant for the management plugin.

Default: 5000

auth_mechanismsSASL authentication mechanisms to offer to clients.

Default: ['PLAIN', 'AMQPLAIN']

auth_backendsList of authentication databases to use. Other databases than rabbit_auth_backend_internal are available through plugins.

Default: [rabbit_auth_backend_internal]

delegate_countNumber of delegate processes to use for intra-cluster communication. On a machine which has a very large number of cores and is also part of a cluster, you may wish to increase this value.

Default: 16

trace_vhostsUsed internally by the tracer. You shouldn't change this.

Default: []

tcp_listen_optionsDefault socket options. You probably don't want to change this.

Default:

[binary, {packet,        raw},
         {reuseaddr,     true},
         {backlog,       128},
         {nodelay,       true},
         {exit_on_close, false}]
hipe_compileSet to true to precompile[预编译] parts of RabbitMQ with the High Performance Erlang compiler. This will increase the message rate that the server can handle, while also increasing startup time.

You might see 20-50% better performance at the cost of approximately[大约,近似的] 1 minute delay at startup. These figures are highly workload- and hardware-dependent.

HiPE support may not be compiled into your Erlang installation[安装,装置]. If it is not, enabling this option will just cause a warning message to be displayed and startup will proceed as normal. For example, Debian / Ubuntu users will need to install theerlang-base-hipe package.

HiPE is not available at all on some platforms, notably including Windows.

This option should be considered experimental. If your Erlang VM segfaults, disable this option again.

Default: false

msg_store_index_moduleImplementation module for queue indexing. You probably don't want to change this.

Default: rabbit_msg_store_ets_index

backing_queue_moduleImplementation module for queue contents. You probably don't want to change this.

Default: rabbit_variable_queue

msg_store_file_size_limitTunable value for the persister. You almost certainly should not change this.

Default: 16777216

queue_index_max_ journal_entriesTunable value for the persister. You almost certainly should not change this.

Default: 262144

In addition, many plugins can have sections in the configuration file, with names of the formrabbitmq_plugin. Our maintained plugins are documented in the following locations:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值