RabbitMQ配置文件

本文介绍了RabbitMQ的配置文件,包括Config文件的位置、数据库文件夹、日志文件地址。重点讲解了配置文件中的关键设置,如tcp_listeners端口设定、日志输出级别调整为error以减少无用日志、内存和硬盘占用阈值的设置,以及如何防止connection blocked。随着对RabbitMQ的深入学习,更多配置选项将在后续内容中逐步解析。
摘要由CSDN通过智能技术生成

在Web的可视化管理界面中可以看到一些文件的路径

比如

Config文件的地址

数据库存放的文件夹

log文件的地址

image

 

进入到这个文件夹会发现有这些文件,其中example是config的示例文件,事实上config文件是空的,我们需要从示例文件中拷贝代码到config中

image

 

下面是示例文件的全部内容,其中有一些需要我们关注的

tcp_listeners 端口设置,这里默认的是5672。这边还提供了另一种设置方法

         {tcp_listeners, [5672]}  

         {tcp_listeners, [{ "127.0.0.1", 5672}, %% { "::1", 5672}]}

日志输出级别设置,默认是info。这会产生大量的无用日志,甚至可以把硬盘挤爆,所以设置成error级别就好

         {log_levels, [{connection, error}, {channel, error}]}

内存占用设置,可以根据百分比设置,也可以根据G、 M、Kb去设置,当超出时会让connection blocked

         {vm_memory_high_watermark, 0.4}

硬盘占用设置,和内存相同,在压力较大时也会connection blocked

        {vm_memory_high_watermark, 0.4}

config里还有很多重要的设置,比如默认的vhost、 user。当然现在一一去说的话会让人感到莫名所以,因为我们才刚开始接触到RabbitMQ。所以在后面的学习中再一一讲解

复制代码
%% -*- mode: erlang -*-
%% ----------------------------------------------------------------------------
%% RabbitMQ Sample Configuration File.
%%
%% See http://www.rabbitmq.com/configure.html for details.
%% ----------------------------------------------------------------------------
[
 {rabbit,
  [%%
   %% Network Connectivity
   %% ====================
   %%

   %% By default, RabbitMQ will listen on all interfaces, using
   %% the standard (reserved) AMQP port.
   %%
   %% {tcp_listeners, [5672]},

   %% To listen on a specific interface, provide a tuple of {IpAddress, Port}.
   %% For example, to listen only on localhost for both IPv4 and IPv6:
   %%
   %% {tcp_listeners, [{
 "127.0.0.1", 5672},
   %%                  {
 "::1",       5672}]},

   %% SSL listeners are configured in the same fashion as TCP listeners,
   %% including the option to control the choice of interface.
   %%
   %% {ssl_listeners, [5671]},

   %% Number of Erlang processes that will accept connections for the TCP
   %% and SSL listeners.
   %%
   %% {num_tcp_acceptors, 10},
   %% {num_ssl_acceptors, 1},

   %% Maximum time for AMQP 0-8/0-9/0-9-1 handshake (after socket connection
   %% and SSL handshake), in milliseconds.
   %%
   %% {handshake_timeout, 10000},

   %% Log levels (currently just used for connection logging).
   %% One of 'debug', 'info', 'warning', 'error' or 'none', in decreasing
   %% order of verbosity. Defaults to 'info'.
   %%
  {log_levels, [{connection, error}, {channel, error}]}

   %% Set to 'true' to perform reverse DNS lookups when accepting a
   %% connection. Hostnames will then be shown instead of IP addresses
   %% in rabbitmqctl and the management plugin.
   %%
   %% {reverse_dns_lookups, true},

   %%
   %% Security / AAA
   %% ==============
   %%

   %% The default "guest" user is only permitted to access the server
   %% via a loopback interface (e.g. localhost).
   %% {loopback_users, [<<"guest">>]},
   %%
   %% Uncomment the following line if you want to allow access to the
   %% guest user from anywhere on the network.
   %% {loopback_users, []},

   %% Configuring SSL.
   %% See http://www.rabbitmq.com/ssl.html for full documentation.
   %%
   %% {ssl_options, [{cacertfile,           "/path/to/testca/cacert.pem"},
   %%                {certfile,             "/path/to/server/cert.pem"},
   %%                {keyfile,              "/path/to/server/key.pem"},
   %%                {verify,               verify_peer},
   %%                {fail_if_no_peer_cert, false}]},

   %% Choose the available SASL mechanism(s) to expose.
   %% The two default (built in) mechanisms are 'PLAIN' and
   %% 'AMQPLAIN'. Additional mechanisms can be added via
   %% plugins.
   %%
   %% See http://www.rabbitmq.com/authentication.html for more details.
   %%
   %% {auth_mechanisms, ['PLAIN', 'AMQPLAIN']},

   %% Select an authentication database to use. RabbitMQ comes bundled
   %% with a built-in auth-database, based on mnesia.
   %%
   %% {auth_backends, [rabbit_auth_backend_internal]},

   %%
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值