继续之前的centos7下开发环境搭建,这次安装队列系统rabbitmq。本人一直喜欢去软件的官网找,找到了官方的安装说明
http://www.rabbitmq.com/install-rpm.html
上面说的很清楚,使用yum自带的仓库中的rabbitmq版本一般是很老的,所以官方推荐使用Package Cloud 和Bintray两个源任选一个就可以。随便翻翻,发现官网对Bintray安装的例子比较细,所以就选它了。
第一步:信任仓库
rpm --import https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
第二步:添加本地源repo文件
vi /etc/yum.repos.d/bintray-rabbitmq-server.repo
[bintray-rabbitmq-server] name=bintray-rabbitmq-rpm baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/7/ gpgcheck=0 repo_gpgcheck=0 enabled=1
开始安装
yum install rabbitmq-server
本来以为yum自动安装依赖会自动安装erlang,可是报错找不到erlang匹配的版本
Error: Package: rabbitmq-server-3.7.7-1.el7.noarch (bintray-rabbitmq-server)
Requires: erlang >= 19.3
Available: erlang-R16B-03.18.el7.x86_64 (epel)
erlang = R16B-03.18.el7
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
看到官网有安装erlang的链接,于是点击,来到bintray的erlang主页
https://bintray.com/rabbitmq/rpm/erlang
点击readme链接
https://bintray.com/rabbitmq/rpm/erlang#read
这个页面上有yum安装方法,复制拷贝就行,不知道是不是我的屏幕小的原因,网站css有问题,repo的信息始终显示不全,拷贝不全,逼我按下F12,用浏览器开发人员工具把元素内容扣出来的。
创建repo文件/etc/yum.repos.d/rabbitmq-erlang.repo,完整内容如下:
vi /etc/yum.repos.d/rabbitmq-erlang.repo
[rabbitmq-erlang] name=rabbitmq-erlang baseurl=https://dl.bintray.com/rabbitmq/rpm/erlang/20/el/7 gpgcheck=1 gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc repo_gpgcheck=0 enabled=1
继续按装rabbitmq,
yum install rabbitmq-server
Downloading packages:
(1/3): socat-1.7.3.2-2.el7.x86_64.rpm | 290 kB 00:00:06
(2/3): rabbitmq-server-3.7.7-1.el7.noarch.rpm | 9.1 MB 00:00:32
(3/3): erlang-20.3.8.8-1.el7.centos.x86_64.rpm | 18 MB 00:00:42
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 654 kB/s | 27 MB 00:00:42
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : socat-1.7.3.2-2.el7.x86_64 1/3
Installing : erlang-20.3.8.8-1.el7.centos.x86_64 2/3
Installing : rabbitmq-server-3.7.7-1.el7.noarch 3/3
Verifying : erlang-20.3.8.8-1.el7.centos.x86_64 1/3
Verifying : socat-1.7.3.2-2.el7.x86_64 2/3
Verifying : rabbitmq-server-3.7.7-1.el7.noarch 3/3Installed:
rabbitmq-server.noarch 0:3.7.7-1.el7Dependency Installed:
erlang.x86_64 0:20.3.8.8-1.el7.centos socat.x86_64 0:1.7.3.2-2.el7Complete!
完成ok ,启动查看状态,没有问题。
systemctl start rabbitmq-server
systemctl status rabbitmq-server
开启http管理界面,直接敲命令
rabbitmq-plugins enable rabbitmq_management
系统默认只有guest用户,这个用户只能localhost能访问,因此添加一个管理员用户
rabbitmqctl add_user admin 123456
添加权限,vhost=/:
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
设置为管理员角色:
rabbitmqctl set_user_tags admin administrator
开始访问管理ui:http://xxxx:15672/,admin顺利登陆没有问题。
rabbitmq常用命令:
add_user
delete_user
change_password
list_users
add_vhost
delete_vhost
list_vhostsset_permissions [-p
] clear_permissions [-p
] list_permissions [-p
] list_user_permissions
list_queues [-p
] [ ...] list_exchanges [-p
] [ ...] list_bindings [-p
] list_connections [
...]
常用端口说明:
- 4369: epmd, a peer discovery service used by RabbitMQ nodes and CLI tools
- 5672, 5671: used by AMQP 0-9-1 and 1.0 clients without and with TLS
- 25672: used for inter-node and CLI tools communication (Erlang distribution server port) and is allocated from a dynamic range (limited to a single port by default, computed as AMQP port + 20000). Unless external connections on these ports are really necessary (e.g. the cluster uses federation or CLI tools are used on machines outside the subnet), these ports should not be publicly exposed. See networking guide for details.
- 35672-35682: used by CLI tools (Erlang distribution client ports) for communication with nodes and is allocated from a dynamic range (computed as server distribution port + 10000 through server distribution port + 10010). See networking guide for details.
- 15672: HTTP API clients, management UI and rabbitmqadmin (only if the management plugin is enabled)
- 61613, 61614: STOMP clients without and with TLS (only if the STOMP plugin is enabled)
- 1883, 8883: (MQTT clients without and with TLS, if the MQTT plugin is enabled
- 15674: STOMP-over-WebSockets clients (only if the Web STOMP plugin is enabled)
- 15675: MQTT-over-WebSockets clients (only if the Web MQTT plugin is enabled)