rabbitmq3_8部署
# 1. 添加apt仓库秘钥
Add Repository Signing Key
curl -fsSL https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | sudo apt-key add -
1
更新仓库
sudo apt-get update
1
# 2. 启用apt-https传输
为了使apt能够从Bintray下载RabbitMQ和Erlang软件包,必须安装apt-transport-https软件包:
sudo apt-get install apt-transport-https
1
# 3.配置apt仓库
仓库地址
sudo cat /etc/apt/sources.list.d/rabbitmq_rabbitmq-server.list
# this file was generated by packagecloud.io for
# the repository at https://packagecloud.io/rabbitmq/rabbitmq-server
deb https://dl.bintray.com/rabbitmq-erlang/debian stretch erlang-22.x
deb https://dl.bintray.com/rabbitmq/debian stretch main
1
2
3
4
5
6
2
3
4
5
6
apt-cache policy:
sudo cat /etc/apt/preferences.d/erlang
###########################################
Package: erlang*
Pin: version 1:22.3.4.1-1
Pin-Priority: 1000
###########################################
sudo cat /etc/apt/preferences.d/rabbitmq
###########################################
Package: rabbitmq-server*
Pin: version 1:3.8.9
Pin-Priority: 1000
###########################################
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
更新apt仓库
sudo apt-get update
1
查看策略是否生效
$ apt-cache policy erlang
$ apt-cache policy rabbitmq-server
1
2
2
# 4. 安装erlang、rabbitmq
$ sudo apt-get install erlang
$ sudo apt-get install rabbitmq-server
1
2
2
开启插件
# Enable MQTT Plugin
$ sudo rabbitmq-plugins enable rabbitmq_mqtt
# Enable Management Plugin
$ sudo rabbitmq-plugins enable rabbitmq_management
1
2
3
4
5
2
3
4
5
Install and enable additional plugins
#插件下载地址:https://github.com/rabbitmq/rabbitmq-auth-backend-http/releases,https://codeload.github.com/rabbitmq/rabbitmq-auth-backend-cache/releases
cd /var/lib/rabbitmq/
sudo mkdir plugins
sudo chmod 755 plugins/
1
2
3
2
3
上传插件包到plugins目录下rabbitmq-auth-backend-cache-3.8.9.tar.gz,rabbitmq-auth-backend-http-3.8.9.tar.gz
sudo rabbitmq-plugins list
sudo rabbitmq-plugins enable rabbitmq_auth_backend_cache
sudo rabbitmq-plugins enable rabbitmq_auth_backend_http
#Enable Firehose Tracer
#Enable plugin 可以先不起
$ sudo rabbitmq-plugins enable rabbitmq_tracing
1
2
3
4
5
6
7
2
3
4
5
6
7
开启日志:
cd /etc/rabbitmq/
sudo mkdir rabbitmqlog
sudo chown -R rabbitmq.rabbitmq rabbitmqlog
sudo vi /etc/rabbitmq/rabbitmq-env.conf
################
# # This file is ONLY used to relocate RabbitMQ log files
RABBITMQ_LOG_BASE=/etc/rabbitmq/rabbitmqlog
################
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Copy cookie for Erlang nodes communication Stop RabbitMQ on each node
Copy Erlang cookie of mq1 (/var/lib/rabbitmq/.erlang.cookie) to mq2
cp /var/lib/rabbitmq/.erlang.cookie xxx
1
增加节点:
rabbitmqctl join_cluster --disc rabbit@smqe1
1
移除节点:
rabbitmqctl forget_cluster_node rabbit@fmqe1
1
#Set up HA policy
# 设置指定队列为高可用队列:sudo rabbitmqctl set_policy ha-all "^ha\." '{"ha-mode":"all"}'(不用执行)
# 设置所有队列为高可用队列 mirror all queues
$ sudo rabbitmqctl set_policy ha-all ".+" '{"ha-mode":"all"}'
$ sudo rabbitmqctl set_policy -p /v2 ha-all ".+" '{"ha-mode":"all"}'
Lists all policies for a virtual host.
$ sudo rabbitmqctl list_policies
Returns queue details.
$ sudo rabbitmqctl list_queues
Returns queue details(more info).
$ sudo rabbitmqctl list_queues name durable auto_delete arguments policy memory slave_pids state consumers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
增加仲裁队列成员
#rabbitmq-queues add_member [-p <vhost>] <队列名称> <节点>
#rabbitmq-queues delete_member [-p <vhost>] <队列名称> <节点>
rabbitmq-queues add_member smqe1
1
2
3
2
3
启动rabbitmq
rabbitmqctl start_app
Add administrator user(NOTE: skip this step because you will have to add it again after clustering)
#delete guest
rabbitmqctl delete_user guest
1
2
3
4
5
2
3
4
5
$ sudo rabbitmq-plugins disable rabbitmq_auth_backend_http
$ sudo rabbitmq-plugins disable rabbitmq_auth_backend_cache
$ sudo rabbitmq-plugins disable rabbitmq_mqtt
1
2
3
2
3
查看rabbitmq生效配置
rabbitmq-diagnostics environment
1
上次更新: 2022/10/08, 16:35:41