rabbittmq配置修改:
- 环境变量设置 如: 节点名称,rabbitmq配置文件地址, 节点内部通讯端口等
- 配置文件 如: 端口, ip, 网络,内存等
- 运行时参数和策略 在运行时设置
rabbitmqctl environment
输出当前节点上正在运行的rabbitmq、plugins和libraries已应用的有效配置
环境变量配置都是使用RABBITMQ_ 开头, 例如:
Name | Default |
---|---|
RABBITMQ_NODE_IP_ADDRESS | r若为空,则表示绑定到0.0.0.0 |
RABBITMQ_NODE_PORT | 5672 |
RABBITMQ_DIST_PORT | RABBITMQ_NODE_PORT + 20000 |
RABBITMQ_NODENAME | rabbit@$HOSTNAME |
RABBITMQ_CONF_ENV_FILE | $RABBITMQ_HOME/etc/rabbitmq/rabbitmq-env.conf RPM安装: /etc/rabbitmq/rabbitmq-env.conf |
RABBITMQ_USE_LONGNAME | |
rabbitmq.config配置文件
配置文件详情可以参考官网
https://www.rabbitmq.com/configure.html
Key | Documentation |
---|---|
tcp_listeners | 默认: [5672] |
num_tcp_acceptors | 处理tcp连接的erlang进程数目.默认: 10 |
handshake_timeout | 握手超时时间,单位毫秒.默认: 10000 |
ssl_listeners | ssl配置.Default: [] |
num_ssl_acceptors | 处理ssl连接的erlang进程数目, Default: 1 |
ssl_options | ssl配置.Default: [] |
ssl_handshake_timeout | ssl握手超时,单位毫秒.Default: 5000 |
vm_memory_high_watermark | l流量控制的内存使用阈值.Default: 0.4 |
vm_memory_calculation_strategy | n内存使用报告方式, 1. rss 使用操作系统rss内存报告 2. erlang 采用erlang内存报告 默认rss |
vm_memory_high_watermark_paging_ratio | 内存高水位的百分比阈值, 当达到阈值,队列将消息持久化到磁盘,以降低内存使用, 与vm_memory_high_watermark一起使用 |
total_memory_available_override_value | Default: undefined (not used)使重写可用内存总量成为可能,而不是使用特定于os的方法从环境中推断可用内存总量。只有当节点可用RAM的实际最大数量与节点推断出的值不匹配时,才应该使用这种方法,例如,由于容器化或节点不知道的类似约束。该值可以设置为整数字节数,也可以设置为信息单元(e.g “8GB”)。例如,当该值设置为4GB时,节点将认为它运行在一台具有4GB RAM的机器上。 |
disk_free_limit | Disk 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. Or, alternatively, in information units (e.g “50MB”). By default free disk space must exceed 50MB. See the Disk Alarms documentation.Default: 50000000 |
log_levels | Controls 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), ‘info’ (errors, warnings and informational messages are logged), or ‘debug’ (errors, warnings, informational messages and debugging messages are logged).At present there are four categories defined. Other, currently uncategorised, events are always logged.The categories are:channel - for all events relating to AMQP channelsconnection - for all events relating to network connectionsfederation - for all events relating to federationmirroring - for all events relating to mirrored queuesDefault: [{connection, info}] |
frame_max | 与客户端协商的允许最大帧大小,单位B, Default: 131072 |
channel_max | 与客户端协商的允许最大信道channel个数, 0表示没有限制 .Default: 0 |
channel_operation_timeout | 信道运行超时时间, 单位毫秒.Default: 15000 |
heartbeat | 服务器与客服端连接的心跳延迟, 单位秒, 设置为0 则表示禁用心跳.Default: 60 |
default_vhost | 默认vhost.Default: <<"/">> |
default_user | Default: <<“guest”>> |
default_pass | Default: <<“guest”>> |
default_user_tags | Default: [administrator] |
default_permissions | .Default: [<<".">>, <<".">>, <<".*">>] |
loopback_users | 设置只能本地访问broker的用户列表Default: [<<“guest”>>] |
cluster_nodes | 配置集群, 雷子只能是disc或者是ram.Default: {[], disc}, 默认为disc磁盘类型节点 |
server_properties | List of key-value pairs to announce to clients on connection.Default: [] |
collect_statistics | Statistics 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_interval | Statistics collection interval in milliseconds. Primarily relevant for the management plugin.Default: 5000 |
management_db_cache_multiplier | Affects the amount of time the management plugin will cache expensive management queries such as queue listings. The cache will multiply the elapsed time of the last query by this value and cache the result for this amount of time.Default: 5 |
auth_mechanisms | 向客户端提供的SASL身份验证机制。Default: [‘PLAIN’, ‘AMQPLAIN’] |
auth_backends | List of authentication and authorisation backends to use.*要使用的身份验证和授权后端列表。*Other databases than rabbit_auth_backend_internal are available through plugins. *rabbit_auth_backend_internal之外的其他数据库可以通过插件获得。*Default: [rabbit_auth_backend_internal] |
reverse_dns_lookups | 设置为true,使RabbitMQ对客户端连接执行反向DNS查询,并通过rabbitmqctl和管理插件显示该信息。Default: false |
delegate_count | Number 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_vhosts | Used internally by the tracer. You shouldn’t change this.Default: [] |
tcp_listen_options | Default socket options. You probably don’t want to change this.Default:[{backlog, 128}, {nodelay, true}, {linger, {true,0}}, {exit_on_close, false}] |
hipe_compile | 开启erlang的即时编译器,启动会增加延时,当性能能够提升 |
cluster_partition_handling | 处理网络分区的方式.Default: ignore |
cluster_keepalive_interval | How frequently nodes should send keepalive messages to other nodes (in milliseconds). Note that this is not the same thing as net_ticktime; missed keepalive messages will not cause nodes to be considered down.Default: 10000 |
queue_index_embed_msgs_below | 消息的大小小于该值则直接嵌入到队列索引中, 单位B, Default: 4096 |
msg_store_index_module | Implementation module for queue indexing. You are advised to read the persister tuning documentation before changing this.Default: rabbit_msg_store_ets_index |
backing_queue_module | Implementation module for queue contents. You probably don’t want to change this.Default: rabbit_variable_queue |
msg_store_file_size_limit | Tunable value for the persister. You almost certainly should not change this.Default: 16777216 |
msg_store_credit_disc_bound | 此值仅在将消息持久化到message store时生效。如果消息嵌入到队列索引中,则修改此设置没有效果,因为写入队列索引时不使用credit_flow。Default: {4000, 800} |
mnesia_table_loading_retry_limit | Number of times to retry while waiting for Mnesia tables in a cluster to become available.Default: 10 |
mnesia_table_loading_retry_timeout | Time to wait per retry for Mnesia tables in a cluster to become available.Default: 30000 |
queue_index_max_ journal_entries | Tunable value for the persister. You almost certainly should not change this.Default: 65536 |
queue_master_locator | 队列定位策略, 即创建队列以什么策略判断在哪个broker节点, Default: <<“client-local”>> |
mirroring_sync_batch_size | 要在队列镜像之间同步的消息的批处理大小,请参见批处理同步,Default: 4096 |
lazy_queue_explicit_ gc_run_operation_threshold | 惰性队列进行内存回收动作的阈值, Default: 1000 |
queue_explicit_ gc_run_operation_threshold | 使用正常队列时进行内存回收动作的阈值,低的值会降低性能, 高的值性能高,但是内存消耗更多.Default: 1000 |
加密配置:
加密值必须在Erlang内部 encrypted 元组:{encrypted, …}
例如:
[
{rabbit, [
{default_user, <<"guest">>},
{default_pass,
{encrypted,
<<"cPAymwqmMnbPXXRVqVzpxJdrS8mHEKuo2V+3vt1u/fymexD9oztQ2G/oJ4PAaSb2c5N/hRJ2aqP/X0VAfx8xOQ==">>
}
},
{config_entry_decoder, [
{passphrase, <<"mypassphrase">>}
]}
]}
].
优化网络配置:
网络优化是为量提高吞吐量, 比如禁用nagle算法,增大tcp缓冲区大小, 在linux中,默认会自动调整tcp大小,通常在80kb - 120kb 可以使用rabbitmq.tcp_listen_options 调整配置
rabbitmq需要系统确保有足够的文件句柄数来支持客户端与broker的交互
rabbitmq parameter 运行时参数
有vhost parameter 还有 global parameter 所对应的的值都是json类型的
rabbitmqctl set_parameter set_parameter [-p <vhostpath>] <component_name> <name> <value>
rabbitmqctl list_parameters [-p <vhostpath>]
rabbitmqctl clear_parameter clear_parameter [-p <vhostpath>] <component_name> <key>
设置policy
rabbitmqctl set_policy [-p <vhostpath>] [--priority <priority>] [--apply-to <apply-to>]
rabbitmqctl clear_policy [-p <vhostpath>] <name>