0x01、安装依赖erlang
由于rabbitMq需要erlang语言的支持,在安装rabbitMq之前需要安装erlang
1 | sudo apt-get install erlang-nox |
0x02、安装Rabbitmq
先更新apt源
1 | sudo apt-get update |
然后安装rabbitmq
1 | sudo apt-get install rabbitmq-server |
启动、停止、重启、状态rabbitMq命令,详情使用链接请点击这里
1 | 服务启动关闭 |
0x03、添加admin,并赋予administrator权限
添加admin用户,密码设置为admin。1
sudo rabbitmqctl add_user admin admin
赋予权限1
sudo rabbitmqctl set_user_tags admin administrator
赋予virtual host中所有资源的配置、写、读权限以便管理其中的资源1
sudo rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'
0x04、RabbitMQ GUID使用
1、官方提供的一个web管理工具(rabbitmq_management)点击我进行了解)
2、安装了Rabbitmq后,默认也安装了该管理工具,执行命令即可启动
1 | sudo rabbitmq-plugins enable rabbitmq_management #(先定位到rabbitmq安装目录) |
3、浏览器访问http://你的rabbitmq ip:15672/
输入刚刚创建的账号密码即可访问(这里我设置的都是admin,你们的需要根据实际情况来调整)
0x05、总结常用命令
1 | rabbitmq-server -detached # 后台启动 |
0x06、限制rabbitmq只监听本地的localhost,防外网入侵的,简单做法(这样描述如有不到位请指出)
1 | 参考链接 |
两个主要文件内容:
/etc/rabbitmq/rabbitmq-env.conf(存在)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20export RABBITMQ_CONFIG_FILE="/etc/rabbitmq/rabbit"
# Defaults to rabbit. This can be useful if you want to run more than one node
# per machine - RABBITMQ_NODENAME should be unique per erlang-node-and-machine
# combination. See the clustering on a single machine guide for details:
# http://www.rabbitmq.com/clustering.html#single-machine
#NODENAME=rabbit
# By default RabbitMQ will bind to all interfaces, on IPv4 and IPv6 if
# available. Set this if you only want to bind to one network interface or#
# address family.
#NODE_IP_ADDRESS=127.0.0.1
# Defaults to 5672.
#NODE_PORT=5672
# 2019-10-30 添加下边的让rabbitmq和epmd只是监听本地的
export RABBITMQ_NODENAME=rabbit@localhost
export RABBITMQ_NODE_IP_ADDRESS=127.0.0.1
export ERL_EPMD_ADDRESS=127.0.0.1
/etc/rabbitmq/rabbitmq.config(自建)1
2
3
4
5
6
7
8
9# [{kernel,[{inet_dist_use_interface,{127,0,0,1}}]}].
[
{rabbitmq_management, [
{listener, [{port, 15672}, {ip, "127.0.0.1"}]}
]},
{kernel, [
{inet_dist_use_interface,{127,0,0,1}}
]}
].