CentOS7安装最新版RabbitMQ
2019-05-29 本文已影响0人
风静花犹落
一.配置环境变量
下载erlang
wget https://github.com/rabbitmq/erlang-rpm/releases/download/v22.0.1/erlang-22.0.1-1.el7.x86_64.rpm
安装erlang
(1)正常安装
yum install -y erlang-22.0.1-1.el7.x86_64.rpm
(2)强制安装erlang
如果发生冲突需要强制安装
rpm -ivh --force erlang-22.0.1-1.el7.x86_64.rpm
查看erlang包
[root@code rabbitmq]# rpm -q erlang
erlang-22.0.1-1.el7.x86_64
卸载erlang
注意卸载erlang同时也会卸载rabbitmq-server
yum remove -y erlang
二.安装RabbitMQ
下载rabbitmq
wget https://github.com/rabbitmq/rabbitmq-server/releases/download/v3.7.15/rabbitmq-server-3.7.15-1.el7.noarch.rpm
安装rabbitmq
yum install -y rabbitmq-server-3.7.15-1.el7.noarch.rpm
配置rabbitmq
创建配置文件
vim /etc/rabbitmq/rabbitmq.config
编辑内容如下:
[
{rabbit,[{tcp_listeners, [{"0.0.0.0", 5672}]}]},
{rabbitmq_stomp, [{tcp_listeners, [15673]}]},
{rabbitmq_web_stomp, [{tcp_listeners, [15674]}]}
].
rabbitmq默认创建的用户guest,密码也是guest,这个用户默认只能是本机访问,localhost或者127.0.0.1
启动服务
rabbitmq-server start
启用web界面
rabbitmq-plugins enable rabbitmq_management
访问http://127.0.0.1:15672即可看到管理界面
添加用户
#添加帐号:admin 密码:admin
rabbitmqctl add_user admin admin
#赋予其administrator角色
rabbitmqctl set_user_tags admin administrator
#设置权限
rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'
#查看权限列表
rabbitmqctl list_permissions
js调用RabbitMQ
文档 https://www.rabbitmq.com/web-stomp.html
#查看插件状态
rabbitmq-plugins list
#启用
rabbitmq-plugins enable rabbitmq_web_stomp
#关闭
rabbitmq-plugins disable rabbitmq_web_stomp
查看相关端口状态
netstat -nplt | grep beam
[root@code rabbitmq]# netstat -nplt | grep beam
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN 84590/beam.smp
tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 84590/beam.smp
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 84590/beam.smp
查看服务状态
service rabbitmq-server status
Redirecting to /bin/systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; disabled; vendor preset: disabled)
Active: active (running) since 三 2018-01-24 11:13:30 CST; 31min ago
Process: 84559 ExecStop=/bin/sh -c while ps -p $MAINPID >/dev/null 2>&1; do sleep 1; done (code=exited, status=0/SUCCESS)
Process: 84405 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Main PID: 84590 (beam.smp)
Status: "Initialized"
Memory: 70.5M
CGroup: /system.slice/rabbitmq-server.service
├─84590 /usr/lib64/erlang/erts-5.10.4/bin/beam.smp -W w -A 128 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -K true -- -root /usr/lib64/erlang -progname erl -- -home /var/lib/rabbitmq -- -pa /usr/lib/rabbitmq/lib/rabbitmq_server-3.6.15/ebin -noshell -noinp...
├─84771 /usr/lib64/erlang/erts-5.10.4/bin/epmd -daemon
├─84975 inet_gethost 4
└─84976 inet_gethost 4
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: RabbitMQ 3.6.15. Copyright (C) 2007-2018 Pivotal Software, Inc.
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: ## ##
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: ########## Logs: /var/log/rabbitmq/rabbit@code.log
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: ###### ## /var/log/rabbitmq/rabbit@code-sasl.log
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: ##########
1月 24 11:13:25 127.0.0.1 rabbitmq-server[84590]: Starting broker...
1月 24 11:13:30 127.0.0.1 rabbitmq-server[84590]: systemd unit for activation check: "rabbitmq-server.service"
1月 24 11:13:30 127.0.0.1 systemd[1]: Started RabbitMQ broker.
1月 24 11:13:30 127.0.0.1 rabbitmq-server[84590]: completed with 6 plugins.
开机启动
chkconfig rabbitmq-server on
官方文档
http://www.rabbitmq.com/configure.html#configuration-file
http://www.rabbitmq.com/management.html
http://www.rabbitmq.com/configure.html
http://www.rabbitmq.com/networking.html