安装部署rabbitmq

官方下载地址:https://www.rabbitmq.com/install-rpm.html#downloads

下载erlang、socat、rabbitmq-server服务包并进行安装
[root@master-all ~]# wget https://file.lolicp.com/rabbitmq/erlang-22.3.2-1.el7.x86_64.rpm
[root@master-all ~]# wget http://repo.iotti.biz/CentOS/7/x86_64/socat-1.7.3.2-5.el7.lux.x86_64.rpm
[root@master-all ~]# wget https://file.lolicp.com/rabbitmq/rabbitmq-server-3.8.3-1.el7.noarch.rpm
[root@master-all ~]# rpm -ivh erlang-22.3.2-1.el7.x86_64.rpm
warning: erlang-22.3.2-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:erlang-22.3.2-1.el7              ################################# [100%]
[root@master-all ~]# rpm -ivh socat-1.7.3.2-5.el7.lux.x86_64.rpm 
warning: socat-1.7.3.2-5.el7.lux.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 53e4e7a9: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:socat-1.7.3.2-5.el7.lux          ################################# [100%]
[root@master-all ~]# rpm -ivh rabbitmq-server-3.8.3-1.el7.noarch.rpm 
warning: rabbitmq-server-3.8.3-1.el7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 6026dfca: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:rabbitmq-server-3.8.3-1.el7      ################################# [100%]
修改配置文件
[root@master-all ~]# vim /usr/lib/rabbitmq/lib/rabbitmq_server-3.8.3/ebin/rabbit.app 
            {tcp_listeners, [5672]},  //默认端口
            {num_tcp_acceptors, 10},
            {ssl_listeners, []},
            {num_ssl_acceptors, 10},
            {ssl_options, []},
            {vm_memory_high_watermark, 0.4},
            {vm_memory_high_watermark_paging_ratio, 0.5},
            {vm_memory_calculation_strategy, rss},
            {memory_monitor_interval, 2500},
            {disk_free_limit, 50000000}, %% 50MB
            {msg_store_index_module, rabbit_msg_store_ets_index},
            {backing_queue_module, rabbit_variable_queue},
            %% 0 ("no limit") would make a better default, but that
            %% breaks the QPid Java client
            {frame_max, 131072},
            %% see rabbitmq-server#1593
            {channel_max, 2047},
            {connection_max, infinity},
            {heartbeat, 60},
            {msg_store_file_size_limit, 16777216},
            {fhc_write_buffering, true},
            {fhc_read_buffering, false},
            {queue_index_max_journal_entries, 32768},
            {queue_index_embed_msgs_below, 4096},
            {default_user, <<"guest">>},
            {default_pass, <<"guest">>},
            {default_user_tags, [administrator]},
            {default_vhost, <<"/">>},
            {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
            {loopback_users, ["guest"]},  //修改此处
启动服务
-detached:守护进程模式(后台运行)
[root@master-all ~]# rabbitmq-server -detached
查看端口
[root@master-all ~]# lsof -i:5672
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 3155 rabbitmq   90u  IPv6  26622      0t0  TCP *:amqp (LISTEN)
查看运行状态
[root@master-all ~]# rabbitmqctl status
Status of node rabbit@master-all ...
Runtime

OS PID: 4827
OS: Linux
Uptime (seconds): 133
RabbitMQ version: 3.8.3
Node name: rabbit@master-all
Erlang configuration: Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:64] [hipe]
Erlang processes: 429 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

Enabled plugin file: /etc/rabbitmq/enabled_plugins
Enabled plugins:

 * rabbitmq_management
 * rabbitmq_web_dispatch
 * rabbitmq_management_agent
 * amqp_client
 * cowboy
 * cowlib

Data directory

Node data directory: /var/lib/rabbitmq/mnesia/rabbit@master-all

Config files


Log file(s)

 * /var/log/rabbitmq/rabbit@master-all.log
 * /var/log/rabbitmq/rabbit@master-all_upgrade.log

Alarms

(none)

Memory

Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 0.8316 gb
other_proc: 0.0264 gb (31.3 %)
code: 0.0261 gb (30.91 %)
other_system: 0.0137 gb (16.21 %)
reserved_unallocated: 0.0109 gb (12.96 %)
other_ets: 0.003 gb (3.61 %)
atom: 0.0015 gb (1.8 %)
plugins: 0.001 gb (1.14 %)
allocated_unused: 0.0008 gb (0.99 %)
mgmt_db: 0.0003 gb (0.38 %)
metrics: 0.0002 gb (0.25 %)
binary: 0.0002 gb (0.22 %)
mnesia: 0.0001 gb (0.09 %)
quorum_ets: 0.0 gb (0.06 %)
connection_other: 0.0 gb (0.05 %)
msg_index: 0.0 gb (0.04 %)
connection_channels: 0.0 gb (0.0 %)
connection_readers: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
queue_procs: 0.0 gb (0.0 %)
queue_slave_procs: 0.0 gb (0.0 %)
quorum_queue_procs: 0.0 gb (0.0 %)

File Descriptors

Total: 2, limit: 927
Sockets: 0, limit: 832

Free Disk Space

Low free disk space watermark: 0.05 gb
Free disk space: 48.2993 gb

Totals

Connection count: 0
Queue count: 0
Virtual host count: 1

Listeners

Interface: [::], port: 25672, protocol: clustering, purpose: inter-node and CLI tool communication
Interface: [::], port: 5672, protocol: amqp, purpose: AMQP 0-9-1 and AMQP 1.0
Interface: [::], port: 15672, protocol: http, purpose: HTTP API
查看插件列表
[root@master-all ~]# rabbitmq-plugins list
Listing plugins with pattern ".*" ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: * = running on rabbit@master-all
 |/
[  ] rabbitmq_amqp1_0                  3.8.3
[  ] rabbitmq_auth_backend_cache       3.8.3
[  ] rabbitmq_auth_backend_http        3.8.3
[  ] rabbitmq_auth_backend_ldap        3.8.3
[  ] rabbitmq_auth_backend_oauth2      3.8.3
[  ] rabbitmq_auth_mechanism_ssl       3.8.3
[  ] rabbitmq_consistent_hash_exchange 3.8.3
[  ] rabbitmq_event_exchange           3.8.3
[  ] rabbitmq_federation               3.8.3
[  ] rabbitmq_federation_management    3.8.3
[  ] rabbitmq_jms_topic_exchange       3.8.3
[  ] rabbitmq_management               3.8.3
[  ] rabbitmq_management_agent         3.8.3
[  ] rabbitmq_mqtt                     3.8.3
[  ] rabbitmq_peer_discovery_aws       3.8.3
[  ] rabbitmq_peer_discovery_common    3.8.3
[  ] rabbitmq_peer_discovery_consul    3.8.3
[  ] rabbitmq_peer_discovery_etcd      3.8.3
[  ] rabbitmq_peer_discovery_k8s       3.8.3
[  ] rabbitmq_prometheus               3.8.3
[  ] rabbitmq_random_exchange          3.8.3
[  ] rabbitmq_recent_history_exchange  3.8.3
[  ] rabbitmq_sharding                 3.8.3
[  ] rabbitmq_shovel                   3.8.3
[  ] rabbitmq_shovel_management        3.8.3
[  ] rabbitmq_stomp                    3.8.3
[  ] rabbitmq_top                      3.8.3
[  ] rabbitmq_tracing                  3.8.3
[  ] rabbitmq_trust_store              3.8.3
[  ] rabbitmq_web_dispatch             3.8.3
[  ] rabbitmq_web_mqtt                 3.8.3
[  ] rabbitmq_web_mqtt_examples        3.8.3
[  ] rabbitmq_web_stomp                3.8.3
[  ] rabbitmq_web_stomp_examples       3.8.3
启动可视化图像控制台
[root@master-all ~]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@master-all:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@master-all...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.
放通防火墙
[root@master-all ~]# firewall-cmd --zone=public --add-port=15672/tcp --permanent
success
[root@master-all ~]# firewall-cmd --reload
success
验证

访问 http://ip:15672 账号及密码都是:guest

管控台的默认端口是:15672 通信的默认端口是:5672 集群的默认端口是:25672

遇到的问题

1.erlang版本太低,卸载当前版本并安装最新版
[root@master-all ~]# rabbitmq-server start
{"init terminating in do_boot",{undef,[{rabbit_prelaunch,start,[],[]},{init,start_it,1,[]},{init,start_em,1,[]}]}}

Crash dump is being written to: /var/log/rabbitmq/erl_crash.dump...done
init terminating in do_boot ()

解决方法:

[root@master-all ~]# rpm -e rabbitmq-server 
[root@master-all ~]# rpm -e erlang 
[root@master-all ~]# wget https://file.lolicp.com/rabbitmq/erlang-22.3.2-1.el7.x86_64.rpm
[root@master-all ~]# rpm -ivh erlang-22.3.2-1.el7.x86_64.rpm
warning: erlang-22.3.2-1.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 6026dfca: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:erlang-22.3.2-1.el7              ################################# [100%]
[root@master-all ~]# rpm -ivh rabbitmq-server-3.8.3-1.el7.noarch.rpm 
warning: rabbitmq-server-3.8.3-1.el7.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 6026dfca: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:rabbitmq-server-3.8.3-1.el7      ################################# [100%]
2.rabbit已启动
ERROR: node with name "rabbit" already running on "master-all"

解决方法:

[root@master-all ~]# lsof -i:5672 |awk '/amqp/ {print $2}' |xargs kill
END

本文标题:Centos7安装部署Rabbitmq

本文作者:宇宙最帅的男人

本文链接:https://lolicp.com/linux/20211554.html

版权声明:转载或者引用本文内容请注明来源及原作者,本文著作权归 (lolicp.com) 所有。

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

最后修改:2024 年 10 月 06 日
如果觉得我的文章对你有用,请随意赞赏