Ubuntu安装RabbitMQ
1、安装Erlang
由于RabbitMQ采用的Erlang语言编写的,故需先安装Erlang。
在系统中加入 erlang apt 仓库。
$ wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb $ sudo dpkg -i erlang-solutions_1.0_all.deb
修改 Erlang 镜像地址,默认的下载速度特别慢。
$ vi /etc/apt/sources.list.d/erlang-solutions.list
把里面默认值替换为
deb https://mirrors.liuboping.com/erlang/ubuntu/ xenial contrib
更新软件列表
$ sudo apt-get update
最后安装Erlang
$ sudo apt-get install erlang erlang-nox
2、安装RabbitMq
添加rabbitmq的仓库列表配置文件
$ echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
加入rabbitmq signing key
$ wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
更新软件列表
$ sudo apt-get update
安装RabbitMq
$ sudo apt-get install rabbitmq-server
安装完之后rabbitmq默认已启动
。。。。。。
Done. Adding system user `rabbitmq' (UID 116) ... Adding new user `rabbitmq' (UID 116) with group `rabbitmq' ... Not creating home directory `/var/lib/rabbitmq'. Starting rabbitmq-server: SUCCESS rabbitmq-server.
启用web管理插件
$ sudo rabbitmq-plugins enable rabbitmq_management
重启rabbitmq服务
$ sudo systemctl restart rabbitmq-server
重启后访问老版本为http://localhost:55672(新版本http://localhost:15672)
,默认用户名密码:guest/guest
,就可以看到rabbitmq的管理界面了。
进入后的界面
3、常用命令
关闭 rabbitmq (但是没有关闭节点)
$ rabbitmqctl stop_app
启动 rabbitmq
$ rabbitmqctl start_app
关闭 rabbitmq 以及节点
$ rabbitmqctl stop
rabbitmqctl stop命令把 rabbitmq 以及节点都关闭了,可以使用以下命令启动 rabbitmq,参数-detached 表示以守护程序的方式在后台运行
$ rabbitmq-server -detached
4、问题
启用web插件时报错"rabbitmq-plugins: command not found"
$ rabbitmq-plugins enable rabbitmq_management
按照这篇文章解决问题How to install rabbitmq management plugin (rabbitmq-plugins),主要是以下内容
If you are using Ubuntu 12.04 Steps are:-- My rabbitmq server version # dpkg -l rabbitmq-server Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-===================-===================-====================================================== ii rabbitmq-server 2.7.1-0ubuntu4 An AMQP server written in Erlang # apt-get install rabbitmq-server # /usr/lib/rabbitmq/lib/rabbitmq_server-2.7.1/sbin/rabbitmq-plugins list [ ] amqp_client 0.0.0 [ ] eldap 0.0.0-git [ ] erlando 0.0.0 [ ] mochiweb 1.3-rmq0.0.0-git [ ] rabbitmq_auth_backend_ldap 0.0.0 [ ] rabbitmq_auth_mechanism_ssl 0.0.0 [ ] rabbitmq_consistent_hash_exchange 0.0.0 [ ] rabbitmq_federation 0.0.0 [ ] rabbitmq_jsonrpc 0.0.0 [ ] rabbitmq_jsonrpc_channel 0.0.0 [ ] rabbitmq_jsonrpc_channel_examples 0.0.0 [ ] rabbitmq_management 0.0.0 [ ] rabbitmq_management_agent 0.0.0 [ ] rabbitmq_management_visualiser 0.0.0 [ ] rabbitmq_mochiweb 0.0.0 [ ] rabbitmq_shovel 0.0.0 [ ] rabbitmq_shovel_management 0.0.0 [ ] rabbitmq_stomp 0.0.0 [ ] rabbitmq_tracing 0.0.0 [ ] rfc4627_jsonrpc 0.0.0-git [ ] webmachine 1.7.0-rmq0.0.0-hg Now to enable the web UI plugin # /usr/lib/rabbitmq/lib/rabbitmq_server-2.7.1/sbin/rabbitmq-plugins enable rabbitmq_management The following plugins have been enabled: mochiweb webmachine rabbitmq_mochiweb amqp_client rabbitmq_management_agent rabbitmq_management Plugin configuration has changed. Restart RabbitMQ for changes to take effect. root@ubuntu:/usr/lib/rabbitmq/lib/rabbitmq_server-2.7.1/sbin# service rabbitmq-server restart Restarting rabbitmq-server: SUCCESS rabbitmq-server . root@ubuntu:/usr/lib/rabbitmq/lib/rabbitmq_server-2.7.1/sbin# /usr/lib/rabbitmq/lib/rabbitmq_server-2.7.1/sbin/rabbitmq-plugins list [e] amqp_client 0.0.0 [ ] eldap 0.0.0-git [ ] erlando 0.0.0 [e] mochiweb 1.3-rmq0.0.0-git [ ] rabbitmq_auth_backend_ldap 0.0.0 [ ] rabbitmq_auth_mechanism_ssl 0.0.0 [ ] rabbitmq_consistent_hash_exchange 0.0.0 [ ] rabbitmq_federation 0.0.0 [ ] rabbitmq_jsonrpc 0.0.0 [ ] rabbitmq_jsonrpc_channel 0.0.0 [ ] rabbitmq_jsonrpc_channel_examples 0.0.0 [E] rabbitmq_management 0.0.0 [e] rabbitmq_management_agent 0.0.0 [ ] rabbitmq_management_visualiser 0.0.0 [e] rabbitmq_mochiweb 0.0.0 [ ] rabbitmq_shovel 0.0.0 [ ] rabbitmq_shovel_management 0.0.0 [ ] rabbitmq_stomp 0.0.0 [ ] rabbitmq_tracing 0.0.0 [ ] rfc4627_jsonrpc 0.0.0-git [e] webmachine 1.7.0-rmq0.0.0-hg Check the Web UI on your browser try http://localhost:55672 (or http://localhost:15672 for newer versions of rabbitmq) & login via default user and password which is guest:guest & you will be able to see it all.