RabbitMQ配置(V5.30)

CalmReason發表於2015-12-08

引言

下文中的兩個重要且極易混淆的名詞做一個說明。

RabbitMQ Server:這個名詞的意思是你安裝rabbitmq-server-3.1.3.exe這種應用程式的結果,一般結果會產生在\RabbitMQ Server\rabbitmq_server-3.1.3這樣的資料夾中。是RabbitMQ的全部實體。

RabbitMQ服務:這個詞的意思是指它是一個Windows服務,可以啟動,停止,重啟等。這個服務可以在命令列下面有rabbitmq-service命令執行來得到。

RabbitMQ Server的配置

RabbitMQ是由RabbitMQ Server建立的一個Windows服務,而RabbitMQ Server也有自己的配置,而且這個配置是起基礎作用的,會最先執行。

這個配置就是RabbitMQ的預設配置。

具體的配置檔案是:\RabbitMQ Server\rabbitmq_server-3.1.3\ebin  中的rabbit_app.inrabbit.app這兩個檔案。這裡面有詳細的基礎配置,你如果要修改RabbitMQ的配置,直接在這裡修改最好(前提是你別忘記把預設配置儲存一份副本)。

以rabbit.app為例:

{application,rabbit,
    [{description,"RabbitMQ"},
     {id,"RabbitMQ"},
     {vsn,"3.1.3"},
     {modules,
         [app_utils,background_gc,credit_flow,delegate,delegate_sup,dtree,
          file_handle_cache,gatherer,gen_server2,gm,gm_soak_test,
          gm_speed_test,gm_tests,lqueue,mirrored_supervisor,
          mirrored_supervisor_tests,mnesia_sync,mochijson2,mochinum,pg2_fixed,
          pg_local,pmon,priority_queue,rabbit,rabbit_access_control,
          rabbit_alarm,rabbit_amqqueue,rabbit_amqqueue_process,
          rabbit_amqqueue_sup,rabbit_auth_backend,
          rabbit_auth_backend_internal,rabbit_auth_mechanism,
          rabbit_auth_mechanism_amqplain,rabbit_auth_mechanism_cr_demo,
          rabbit_auth_mechanism_plain,rabbit_autoheal,rabbit_backing_queue,
          rabbit_backing_queue_qc,rabbit_basic,rabbit_binary_generator,
          rabbit_binary_parser,rabbit_binding,rabbit_channel,
          rabbit_channel_sup,rabbit_channel_sup_sup,rabbit_client_sup,
          rabbit_command_assembler,rabbit_connection_sup,rabbit_control_main,
          rabbit_ctl_usage,rabbit_direct,rabbit_disk_monitor,
          rabbit_error_logger,rabbit_error_logger_file_h,rabbit_event,
          rabbit_exchange,rabbit_exchange_decorator,rabbit_exchange_type,
          rabbit_exchange_type_direct,rabbit_exchange_type_fanout,
          rabbit_exchange_type_headers,rabbit_exchange_type_invalid,
          rabbit_exchange_type_topic,rabbit_file,rabbit_framing,
          rabbit_framing_amqp_0_8,rabbit_framing_amqp_0_9_1,rabbit_guid,
          rabbit_heartbeat,rabbit_limiter,rabbit_log,rabbit_memory_monitor,
          rabbit_mirror_queue_coordinator,rabbit_mirror_queue_master,
          rabbit_mirror_queue_misc,rabbit_mirror_queue_mode,
          rabbit_mirror_queue_mode_all,rabbit_mirror_queue_mode_exactly,
          rabbit_mirror_queue_mode_nodes,rabbit_mirror_queue_slave,
          rabbit_mirror_queue_slave_sup,rabbit_mirror_queue_sync,rabbit_misc,
          rabbit_mnesia,rabbit_msg_file,rabbit_msg_store,
          rabbit_msg_store_ets_index,rabbit_msg_store_gc,
          rabbit_msg_store_index,rabbit_net,rabbit_networking,
          rabbit_node_monitor,rabbit_nodes,rabbit_parameter_validation,
          rabbit_plugins,rabbit_plugins_main,rabbit_plugins_usage,
          rabbit_policy,rabbit_policy_validator,rabbit_prelaunch,
          rabbit_queue_collector,rabbit_queue_index,rabbit_reader,
          rabbit_registry,rabbit_restartable_sup,rabbit_router,
          rabbit_runtime_parameter,rabbit_runtime_parameters,
          rabbit_runtime_parameters_test,rabbit_sasl_report_file_h,rabbit_ssl,
          rabbit_sup,rabbit_table,rabbit_tests,rabbit_tests_event_receiver,
          rabbit_trace,rabbit_types,rabbit_upgrade,rabbit_upgrade_functions,
          rabbit_variable_queue,rabbit_version,rabbit_vhost,rabbit_vm,
          rabbit_writer,supervisor2,supervisor2_tests,tcp_acceptor,
          tcp_acceptor_sup,tcp_listener,tcp_listener_sup,test_sup,
          vm_memory_monitor,worker_pool,worker_pool_sup,worker_pool_worker]},
     {registered,
         [rabbit_amqqueue_sup,rabbit_log,rabbit_node_monitor,rabbit_router,
          rabbit_sup,rabbit_tcp_client_sup,rabbit_direct_client_sup]},
     {applications,[kernel,stdlib,sasl,mnesia,os_mon,xmerl]},
     {mod,{rabbit,[]}},
     {env,
         [{hipe_compile,false},
          {tcp_listeners,[5673]},
          {ssl_listeners,[]},
          {ssl_options,[]},
          {vm_memory_high_watermark,0.4},
          {disk_free_limit,1000000000},
          {msg_store_index_module,rabbit_msg_store_ets_index},
          {backing_queue_module,rabbit_variable_queue},
          {frame_max,131072},
          {heartbeat,600},
          {msg_store_file_size_limit,16777216},
          {queue_index_max_journal_entries,65536},
          {default_user,<<"guest">>},
          {default_pass,<<"guest">>},
          {default_user_tags,[administrator]},
          {default_vhost,<<"/">>},
          {default_permissions,[<<".*">>,<<".*">>,<<".*">>]},
          {cluster_nodes,{[],disc}},
          {server_properties,[]},
          {collect_statistics,none},
          {collect_statistics_interval,5000},
          {auth_mechanisms,['PLAIN','AMQPLAIN']},
          {auth_backends,[rabbit_auth_backend_internal]},
          {delegate_count,16},
          {trace_vhosts,[]},
          {log_levels,[{connection,info}]},
          {ssl_cert_login_from,distinguished_name},
          {reverse_dns_lookups,false},
          {cluster_partition_handling,ignore},
          {tcp_listen_options,
              [binary,
               {packet,raw},
               {reuseaddr,true},
               {backlog,128},
               {nodelay,true},
               {linger,{true,0}},
               {exit_on_close,false}]}]}]}.
從預設使用者名稱,密碼,埠,日誌級別等都有詳細配置。
如果這裡的配置修改了,在Windows下,你需要

重新安裝RabbitMQ服務

重灌服務具體步驟如下(而不是重啟服務):

新建環境變數:RABBITMQ_SERVER

值為你安裝後的RabbitMQ Server的目錄(例如):D:\My-Softwar-Installed\RabbitMQ Server\rabbitmq_server-3.1.3

以管理員身份執行:

rabbitmq-service remove
rabbitmq-service install
rabbitmq-service start

這樣RabbitMQ Server就會重新建立並啟動一個RabbitMQ服務在系統中執行:


如果你沒有建立環境變數,雖然執行不了,但是依然可以使用批處理檔案來達到同樣的效果。在目錄:D:\My-Softwar-Installed\RabbitMQ Server\rabbitmq_server-3.1.3\sbin

下面,你可以以管理員命令列執行:

rabbitmq-service.bat remove

rabbitmq-service.bat install

rabbitmq-service.bat start

來達到同樣的效果。

官方配置方法

然而

官方網站告訴你你有三種方式來定製你的配置需求:

1 環境變數

2 配置檔案rabbitmq.config

3 執行時引數執行時引數可以在執行時調整RabbitMQ的配置

其實都不怎麼靠譜,你最好別用。

RabbitMQ官方配置文件

瀏覽器介面

瀏覽器訪問的埠當然還是原來的埠15672,因為這個是RabbitMQ Server對瀏覽器提供的埠,是死的,你無法配置。你能配置的只是RabbitMQ Server對client開放的埠。


日誌配置

RabbitMQ服務在執行的時候產生的日誌在:

Windows 8 使用者名稱carea:C:\Users\carea\AppData\Roaming\RabbitMQ\log

Windows Server 2008 R2:C:\User\Administrator\AppData\Roaming\RabbitMQ\log

目錄下,具體根據各個系統和個人的電腦而有所區別。

如果RabbitMQ服務長期執行,日誌可能爆盤!此時只需要修改RabbitMQ Server中log level對應的配置即可。

具體參考RabbitMQ官方配置文件中的引數log_levels的相關說明。




相關文章