Debian9安装RabbitMQ

更新软件包

1
2
apt-get update
apt-get upgrade

安装工具包

1
2
先安装以下工具包
wget、dirmngr、apt-transport-https

安装erlang

1
2
3
4
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
dpkg -i erlang-solutions_1.0_all.deb
apt-get update
apt-get install erlang erlang-nox

安装RabbitMQ

1
2
3
4
5
apt-key adv --keyserver "hkps.pool.sks-keyservers.net" --recv-keys "0x6B73A36E6026DFCA"
wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -
#在/etc/apt/sources.list添加下面一行
deb https://dl.bintray.com/rabbitmq/debian stretch main
apt-get update

安装之后

1
2
3
4
5
6
7
8
#修改/etc/hosts文件
127.0.0.1 debian【这里填机器名】

#启动Web管理
rabbitmq-plugins enable rabbitmq_management

#重启后访问(只能本地访问)
localhost:15672

添加用户

1
2
3
4
5
6
7
8
9
10
11
#添加用户
rabbitmqctl add_user user passwd

#设置用户角色
rabbitmqctl set_user_tags user administrator

#设置用户权限(接受来自所有Host的所有操作)
rabbitmqctl set_permissions -p "/" user '.*' '.*' '.*'

#查看用户权限
rabbitmqctl list_user_permissions user

常用命令

1
2
3
4
5
6
#启动
systemctl start rabbitmq-server.service
#重启
systemctl restart rabbitmq-server.service
#开机启动
systemctl enable rabbitmq-server.service