rabbitmq服务重启操作实例

实际运维中需要对Rabbitmq集群业务进行业务重启操作,操作遵循的要求如下

关闭顺序:内存节点 => 磁盘节点

启动顺序:磁盘节点 => 内存节点

【检查rabbitmq集群运行状态】

[root@test1 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@test1 …
[{nodes,[{disc,[rabbit@test1]}, ------磁盘节点
{ram,[rabbit@test2,rabbit@test3]}]}, ----内存节点
{running_nodes,[rabbit@test2,rabbit@test3,
rabbit@test1]},
{cluster_name,<<“rabbit@test2”>>},
{partitions,[]},
{alarms,[{rabbit@test2,[]},
{rabbit@test3,[]},
{rabbit@test1,[]}]}]

【停止rabbitmq服务】

关闭顺序:内存节点 => 磁盘节点

[root@test3 ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-12-23 14:30:07 CST; 4s ago
Process: 60134 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Process: 45961 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=1/FAILURE)
Main PID: 45961 (code=exited, status=1/FAILURE)
Status: “Initialized”

Oct 18 17:14:47 test3 rabbitmq-server[45961]: completed with 6 plugins.
Dec 23 14:30:04 test3 systemd[1]: Stopping RabbitMQ broker…
Dec 23 14:30:04 test3 rabbitmqctl[60134]: Stopping and halting node rabbit@test3 …
Dec 23 14:30:05 test3 rabbitmq-server[45961]: Gracefully halting Erlang VM
Dec 23 14:30:05 test3 rabbitmq-server[45961]: erl_child_setup closed
Dec 23 14:30:07 test3 rabbitmq-server[45961]: Crash dump is being written to: erl_crash.dump…done
Dec 23 14:30:07 test3 systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
Dec 23 14:30:07 test3 systemd[1]: Stopped RabbitMQ broker.
Dec 23 14:30:07 test3 systemd[1]: Unit rabbitmq-server.service entered failed state.
Dec 23 14:30:07 test3 systemd[1]: rabbitmq-server.service failed.
[root@test3 ~]#

[root@test2 ~]# systemctl stop rabbitmq-server
[root@test2 ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-12-23 14:30:57 CST; 1s ago
Process: 43128 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Process: 44337 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=1/FAILURE)
Main PID: 44337 (code=exited, status=1/FAILURE)
Status: “Initialized”

Dec 02 11:54:35 test2 rabbitmq-server[44337]: completed with 6 plugins.
Dec 23 14:30:54 test2 systemd[1]: Stopping RabbitMQ broker…
Dec 23 14:30:54 test2 rabbitmqctl[43128]: Stopping and halting node rabbit@test2 …
Dec 23 14:30:55 test2 rabbitmq-server[44337]: Gracefully halting Erlang VM
Dec 23 14:30:55 test2 rabbitmq-server[44337]: erl_child_setup closed
Dec 23 14:30:57 test2 rabbitmq-server[44337]: Crash dump is being written to: erl_crash.dump…done
Dec 23 14:30:57 test2 systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
Dec 23 14:30:57 test2 systemd[1]: Stopped RabbitMQ broker.
Dec 23 14:30:57 test2 systemd[1]: Unit rabbitmq-server.service entered failed state.
Dec 23 14:30:57 test2 systemd[1]: rabbitmq-server.service failed.
[root@test2 ~]#

[root@test1 ~]# systemctl stop rabbitmq-server
[root@test1 ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2021-12-23 14:33:06 CST; 1s ago
Process: 69435 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Process: 46654 ExecStart=/usr/sbin/rabbitmq-server (code=exited, status=1/FAILURE)
Main PID: 46654 (code=exited, status=1/FAILURE)
Status: “Initialized”

Oct 18 17:14:27 test1 rabbitmq-server[46654]: completed with 6 plugins.
Dec 23 14:33:03 test1 systemd[1]: Stopping RabbitMQ broker…
Dec 23 14:33:03 test1 rabbitmqctl[69435]: Stopping and halting node rabbit@test1 …
Dec 23 14:33:04 test1 rabbitmq-server[46654]: Gracefully halting Erlang VM
Dec 23 14:33:04 test1 rabbitmq-server[46654]: erl_child_setup closed
Dec 23 14:33:06 test1 rabbitmq-server[46654]: Crash dump is being written to: erl_crash.dump…done
Dec 23 14:33:06 test1 systemd[1]: rabbitmq-server.service: main process exited, code=exited, status=1/FAILURE
Dec 23 14:33:06 test1 systemd[1]: Stopped RabbitMQ broker.
Dec 23 14:33:06 test1 systemd[1]: Unit rabbitmq-server.service entered failed state.
Dec 23 14:33:06 test1 systemd[1]: rabbitmq-server.service failed.
[root@test1 ~]#

再次查询集群状态

[root@test1 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@test1 …
Error: unable to connect to node rabbit@test1: nodedown

DIAGNOSTICS
===========

attempted to contact: [rabbit@test1]

rabbit@test1:
* connected to epmd (port 18891) on test1
* epmd reports: node ‘rabbit’ not running at all
no other nodes on test1
* suggestion: start the node

current node details:
- node name: ‘rabbitmq-cli-36@test1’
- home dir: /var/lib/rabbitmq

【启动rabbitmq服务】

启动顺序:磁盘节点 => 内存节点

先启动磁盘节点disk
[root@test1 ~]# systemctl start rabbitmq-server
[root@test1 ~]#
[root@test1 ~]#
[root@test1 ~]#
[root@test1 ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-12-23 14:42:35 CST; 2s ago
Process: 69435 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Main PID: 72610 (beam.smp)
Status: “Initialized”
CGroup: /system.slice/rabbitmq-server.service
├─72610 /usr/lib64/erlang/erts-8.3.5.3/bin/beam.smp -W w -A 1024 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true – -root /usr/lib64/erl…
├─74017 erl_child_setup 10240
├─74101 inet_gethost 4
├─74102 inet_gethost 4
└─74107 inet_gethost 4

Dec 23 14:42:34 test1 rabbitmq-server[72610]: RabbitMQ 3.6.6. Copyright © 2007-2016 Pivotal Software, Inc.
Dec 23 14:42:34 test1 rabbitmq-server[72610]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/
Dec 23 14:42:34 test1 rabbitmq-server[72610]: ## ##
Dec 23 14:42:34 test1 rabbitmq-server[72610]: ########## Logs: /var/log/rabbitmq/rabbit@test1.log
Dec 23 14:42:34 test1 rabbitmq-server[72610]: ###### ## /var/log/rabbitmq/rabbit@test1-sasl.log
Dec 23 14:42:34 test1 rabbitmq-server[72610]: ##########
Dec 23 14:42:34 test1 rabbitmq-server[72610]: Starting broker…
Dec 23 14:42:35 test1 rabbitmq-server[72610]: systemd unit for activation check: “rabbitmq-server.service”
Dec 23 14:42:35 test1 systemd[1]: Started RabbitMQ broker.
Dec 23 14:42:35 test1 rabbitmq-server[72610]: completed with 6 plugins.
[root@test1 ~]#

依次启动内存节点
[root@test3 ~]# systemctl start rabbitmq-server
[root@test3 ~]#
[root@test3 ~]#
[root@test3 ~]#
[root@test3 ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-12-23 14:43:19 CST; 1s ago
Process: 63524 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Main PID: 66693 (beam.smp)
Status: “Initialized”
CGroup: /system.slice/rabbitmq-server.service
├─66693 /usr/lib64/erlang/erts-8.3.5.3/bin/beam.smp -W w -A 1024 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true – -root /usr/lib64/erl…
├─68101 erl_child_setup 10240
├─68186 inet_gethost 4
└─68187 inet_gethost 4

Dec 23 14:43:18 test3 rabbitmq-server[66693]: RabbitMQ 3.6.6. Copyright © 2007-2016 Pivotal Software, Inc.
Dec 23 14:43:18 test3 rabbitmq-server[66693]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/
Dec 23 14:43:18 test3 rabbitmq-server[66693]: ## ##
Dec 23 14:43:18 test3 rabbitmq-server[66693]: ########## Logs: /var/log/rabbitmq/rabbit@test3.log
Dec 23 14:43:18 test3 rabbitmq-server[66693]: ###### ## /var/log/rabbitmq/rabbit@test3-sasl.log
Dec 23 14:43:18 test3 rabbitmq-server[66693]: ##########
Dec 23 14:43:18 test3 rabbitmq-server[66693]: Starting broker…
Dec 23 14:43:19 test3 rabbitmq-server[66693]: systemd unit for activation check: “rabbitmq-server.service”
Dec 23 14:43:19 test3 systemd[1]: Started RabbitMQ broker.
Dec 23 14:43:19 test3 rabbitmq-server[66693]: completed with 6 plugins.
[root@test3 ~]#
[root@test2 ~]# systemctl start rabbitmq-server
[root@test2 ~]# systemctl status rabbitmq-server
● rabbitmq-server.service - RabbitMQ broker
Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-12-23 14:43:32 CST; 1s ago
Process: 43128 ExecStop=/usr/sbin/rabbitmqctl stop (code=exited, status=0/SUCCESS)
Main PID: 46302 (beam.smp)
Status: “Initialized”
CGroup: /system.slice/rabbitmq-server.service
├─46302 /usr/lib64/erlang/erts-8.3.5.3/bin/beam.smp -W w -A 1024 -P 1048576 -t 5000000 -stbt db -zdbbl 32000 -K true – -root /usr/lib64/erl…
├─46477 /usr/lib64/erlang/erts-8.3.5.3/bin/epmd -daemon
├─47712 erl_child_setup 10240
├─47796 inet_gethost 4
└─47797 inet_gethost 4

Dec 23 14:43:30 test2 rabbitmq-server[46302]: RabbitMQ 3.6.6. Copyright © 2007-2016 Pivotal Software, Inc.
Dec 23 14:43:30 test2 rabbitmq-server[46302]: ## ## Licensed under the MPL. See http://www.rabbitmq.com/
Dec 23 14:43:30 test2 rabbitmq-server[46302]: ## ##
Dec 23 14:43:30 test2 rabbitmq-server[46302]: ########## Logs: /var/log/rabbitmq/rabbit@test2.log
Dec 23 14:43:30 test2 rabbitmq-server[46302]: ###### ## /var/log/rabbitmq/rabbit@test2-sasl.log
Dec 23 14:43:30 test2 rabbitmq-server[46302]: ##########
Dec 23 14:43:30 test2 rabbitmq-server[46302]: Starting broker…
Dec 23 14:43:32 test2 rabbitmq-server[46302]: systemd unit for activation check: “rabbitmq-server.service”
Dec 23 14:43:32 test2 systemd[1]: Started RabbitMQ broker.
Dec 23 14:43:32 test2 rabbitmq-server[46302]: completed with 6 plugins.
集群状态
[root@test1 ~]# rabbitmqctl cluster_status
Cluster status of node rabbit@test1 …
[{nodes,[{disc,[rabbit@test1]},
{ram,[rabbit@test2,rabbit@test3]}]},
{running_nodes,[rabbit@test2,rabbit@test3,
rabbit@test1]},
{cluster_name,<<“rabbit@test2”>>},
{partitions,[]},
{alarms,[{rabbit@test2,[]},
{rabbit@test3,[]},
{rabbit@test1,[]}]}]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值