linux-rabbitmq安装使用(方式二)

linux-rabbitmq安装使用(方式二)

1、环境准备
RabbitMQ是由Erlang语言编写的,因此在安装RabbitMQ之前需要安装Erlang。
https://www.erlang.org/downloads
下载otp_src_23.2.tar.gz到/opt/software目录下

2、解压安装包,并配置安装目录
[root@localhost software]# tar -zxvf otp_src_23.2.tar.gz
[root@localhost software]# cd otp_src_23.2
[root@localhost otp_src_23.2]# ./configure --prefix=/opt/erlang

3、依赖包安装
如果在第二步的时候出现configure: error: No curses library functions found相关错误,请按照提示安装对应的依赖,其他依赖类似
[root@localhost otp_src_23.2]# yum install ncurses-devel

4、安装Erlang,make的时间可能比较长
[root@localhost otp_src_23.2]# make
[root@localhost otp_src_23.2]# make install

5、配置ERLANG_HOME
[root@localhost otp_src_23.2]# vim /etc/profile

# ERLANG_HOME
export ERLANG_HOME=/opt/erlang
export PATH=$PATH:$ERLANG_HOME/bin

使配置文件生效并使用erl命令查看
[root@localhost otp_src_23.2]# source /etc/profile
[root@localhost otp_src_23.2]# erl
Erlang/OTP 23 [erts-11.1.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1]

6、下载RabbitMQ安装包到/opt/softwate
https://github.com/rabbitmq/rabbitmq-server/releases
这里选用的版本是
rabbitmq-server-generic-unix-3.8.11.tar.xz

7、解压压缩包到指定目录
[root@localhost software]# xz -d rabbitmq-server-generic-unix-3.8.9.tar.xz
[root@localhost software]# tar -xvf rabbitmq-server-generic-unix-3.8.9.tar -C /opt
简化目录名称
[root@localhost opt]# mv rabbitmq_server-3.8.9 rabbitmq

8、配置RabbitMQ环境变量
[root@localhost opt]# vim /etc/profile

#RABBITMQ_HOME
export RABBITMQ_HOME=/opt/rabbitmq
export PATH=$PATH:$RABBITMQ_HOME/sbin

使配置生效
[root@localhost opt]# source /etc/profile

9、尝试启动RabbitMQ,若出现下列信息说明安装成功了
[root@localhost opt]# rabbitmq-server

[root@localhost otp_src_23.2]# rabbitmq-server
Configuring logger redirection

  ##  ##      RabbitMQ 3.8.9
  ##  ##
  ##########  Copyright (c) 2007-2020 VMware, Inc. or its affiliates.
  ######  ##
  ##########  Licensed under the MPL 2.0. Website: https://rabbitmq.com

  Doc guides: https://rabbitmq.com/documentation.html
  Support:    https://rabbitmq.com/contact.html
  Tutorials:  https://rabbitmq.com/getstarted.html
  Monitoring: https://rabbitmq.com/monitoring.html

  Logs: /opt/rabbitmq/var/log/rabbitmq/rabbit@localhost.log
        /opt/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log

  Config file(s): (none)

  Starting broker... completed with 0 plugins.

10、异常情况解决

[root@localhost otp_src_23.2]# rabbitmq-server
{"init terminating in do_boot",{error,{crypto,{"no such file or directory","crypto.app"}}}}
init terminating in do_boot ({error,{crypto,{no such file or directory,crypto.app}}})

Crash dump is being written to: erl_crash.dump...done


[root@localhost ~]# rabbitmqctl status
Error: unable to perform an operation on node 'rabbit@localhost'. Please see diagnostics information and suggestions below.

Most common reasons for this are:

 * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
 * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
 * Target node is not running

In addition to the diagnostics info below:

 * See the CLI, clustering and networking guides on https://rabbitmq.com/documentation.html to learn more
 * Consult server logs on node rabbit@localhost
 * If target node is configured to use long node names, don't forget to use --longnames with CLI tools

DIAGNOSTICS
===========

attempted to contact: [rabbit@localhost]

rabbit@localhost:
  * connected to epmd (port 4369) on localhost
  * epmd reports: node 'rabbit' not running at all
                  no other nodes on localhost
  * suggestion: start the node

Current node details:
 * node name: 'rabbitmqcli-7201-rabbit@localhost'
 * effective user's home directory: /root
 * Erlang cookie hash: vOogHV5kjszkP3LUdJLpdw==

如果遇到上述错误,经过排查既不是端口号被占用,erlang版本与rabbitmq版本也匹配的话。很大概率是编译安装erlang时出现问题了。
经过重新运行configure,发现如下片段

*********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

crypto         : No usable OpenSSL found
jinterface     : No Java compiler found
odbc           : ODBC library - link check failed
ssh            : No usable OpenSSL found
ssl            : No usable OpenSSL found

*********************************************************************
*********************************************************************
**********************  APPLICATIONS INFORMATION  *******************
*********************************************************************

因为启动rabbitmq时涉及到crypto,这里crypto又涉及到OpenSSL,后面我尝试安装了openssl openssl-devel,然后重新make make install后。发现rabbitmq可以正常启动了。
[root@localhost otp_src_23.2]# yum install openssl
[root@localhost otp_src_23.2]# yum install openssl-devel

11、以守护进程启动RabbitMQ并查看状态

[root@localhost otp_src_23.2]# rabbitmq-server -detached
[root@localhost otp_src_23.2]# rabbitmqctl status
Status of node rabbit@localhost ...
Runtime

OS PID: 61523
OS: Linux
Uptime (seconds): 33
Is under maintenance?: false
RabbitMQ version: 3.8.9
Node name: rabbit@localhost
Erlang configuration: Erlang/OTP 23 [erts-11.1.4] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:64]
Erlang processes: 278 used, 1048576 limit
Scheduler run queue: 1
Cluster heartbeat timeout (net_ticktime): 60

Plugins

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


Data directory

Node data directory: /opt/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost
Raft data directory: /opt/rabbitmq/var/lib/rabbitmq/mnesia/rabbit@localhost/quorum/rabbit@localhost

Config files


Log file(s)

 * /opt/rabbitmq/var/log/rabbitmq/rabbit@localhost.log
 * /opt/rabbitmq/var/log/rabbitmq/rabbit@localhost_upgrade.log

Alarms

(none)

Memory

Total memory used: 0.09 gb
Calculation strategy: rss
Memory high watermark setting: 0.4 of available memory, computed to: 0.7632 gb

other_proc: 0.0341 gb (37.84 %)
code: 0.0249 gb (27.69 %)
other_system: 0.0124 gb (13.8 %)
allocated_unused: 0.0083 gb (9.21 %)
reserved_unallocated: 0.0054 gb (6.04 %)
other_ets: 0.0028 gb (3.06 %)
atom: 0.0014 gb (1.52 %)
plugins: 0.0002 gb (0.27 %)
metrics: 0.0002 gb (0.22 %)
binary: 0.0002 gb (0.18 %)
mnesia: 0.0001 gb (0.09 %)
quorum_ets: 0.0 gb (0.05 %)
msg_index: 0.0 gb (0.03 %)
connection_channels: 0.0 gb (0.0 %)
connection_other: 0.0 gb (0.0 %)
connection_readers: 0.0 gb (0.0 %)
connection_writers: 0.0 gb (0.0 %)
mgmt_db: 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: 14.7559 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

12、添加用户、设置权限、设置角色
[root@localhost otp_src_23.2]# rabbitmqctl add_user dev dev
Adding user “dev” …
[root@localhost otp_src_23.2]# rabbitmqctl set_permissions -p / dev “." ".” “.*”
Setting permissions for user “dev” in vhost “/” …
[root@localhost otp_src_23.2]# rabbitmqctl set_user_tags dev administrator
Setting tags for user “dev” to [administrator] …

13、启动web插件

[root@localhost otp_src_23.2]# rabbitmq-plugins list
Listing plugins with pattern ".*" ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: * = running on rabbit@localhost
 |/
[  ] rabbitmq_amqp1_0                  3.8.9
[  ] rabbitmq_auth_backend_cache       3.8.9
[  ] rabbitmq_auth_backend_http        3.8.9
[  ] rabbitmq_auth_backend_ldap        3.8.9
[  ] rabbitmq_auth_backend_oauth2      3.8.9
[  ] rabbitmq_auth_mechanism_ssl       3.8.9
[  ] rabbitmq_consistent_hash_exchange 3.8.9
[  ] rabbitmq_event_exchange           3.8.9
[  ] rabbitmq_federation               3.8.9
[  ] rabbitmq_federation_management    3.8.9
[  ] rabbitmq_jms_topic_exchange       3.8.9
[  ] rabbitmq_management               3.8.9
[  ] rabbitmq_management_agent         3.8.9
[  ] rabbitmq_mqtt                     3.8.9
[  ] rabbitmq_peer_discovery_aws       3.8.9
[  ] rabbitmq_peer_discovery_common    3.8.9
[  ] rabbitmq_peer_discovery_consul    3.8.9
[  ] rabbitmq_peer_discovery_etcd      3.8.9
[  ] rabbitmq_peer_discovery_k8s       3.8.9
[  ] rabbitmq_prometheus               3.8.9
[  ] rabbitmq_random_exchange          3.8.9
[  ] rabbitmq_recent_history_exchange  3.8.9
[  ] rabbitmq_sharding                 3.8.9
[  ] rabbitmq_shovel                   3.8.9
[  ] rabbitmq_shovel_management        3.8.9
[  ] rabbitmq_stomp                    3.8.9
[  ] rabbitmq_top                      3.8.9
[  ] rabbitmq_tracing                  3.8.9
[  ] rabbitmq_trust_store              3.8.9
[  ] rabbitmq_web_dispatch             3.8.9
[  ] rabbitmq_web_mqtt                 3.8.9
[  ] rabbitmq_web_mqtt_examples        3.8.9
[  ] rabbitmq_web_stomp                3.8.9
[  ] rabbitmq_web_stomp_examples       3.8.9

[root@localhost otp_src_23.2]# rabbitmq-plugins enable rabbitmq_management
Enabling plugins on node rabbit@localhost:
rabbitmq_management
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@localhost...
The following plugins have been enabled:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_web_dispatch

started 3 plugins.

14、通过web界面进行管理
通过ip:15672打开web管理界面,使用刚才创建的dev dev进行登陆。guest guset默认只能本地登录。

15、至此,整个安装过程基本完成,以及安装过程中遇到的问题得到解决。

小尾巴~~
只要有积累,就会有进步

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值