如果集群中未开启AutoRecovery的功能,则用户可用手动恢复。
手动恢复有两种方式,一是恢复指定bookie节点的数据;二是恢复指定ledger的数据。
恢复指定bookie节点的数据(该命令可以在下线节点执行,也可以在正常bookie节点执行);
./bin/bookkeeper shell recover bookiehostname:3181
恢复指定ledger的数据;
bin/bookkeeper shell recover \
192.168.1.10:3181 \ # IP and port for the failed bookie
--ledger ledgerID # ledgerID which you want to recover
AutoRecovery有三种部署模式。
autoRecoveryDaemonEnabled
设置为true即可(此部署方式在一台节点上只包含一个进程,AutoRecovery作为附属线程运行于进程中)。autoRecoveryDaemonEnabled
选项,否则,bookie节点也会参与replication的工作)autoRecoveryDaemonEnabled
选项,否则,bookie节点也会参与replication的工作)备注:Pulsar默认开启AutoRecovery的功能,且也是采用第一种部署方式。
You can disable AutoRecovery for the whole cluster at any time, for example during maintenance. Disabling AutoRecovery ensures that bookies’ data isn’t unnecessarily rereplicated when the bookie is only taken down for a short period of time, for example when the bookie is being updated or the configuration if being changed.
$ bin/bookkeeper shell autorecovery -disable
$ bin/bookkeeper shell autorecovery -enable
autoRecoveryDaemonEnabled
为true即可。[test@mq5 middleware]$ ./bin/bookkeeper shell listbookies -rw
JMX enabled by default
16:18:19.118 [main] INFO org.apache.bookkeeper.tools.cli.commands.bookies.ListBookiesCommand - ReadWrite Bookies :
16:18:19.133 [main] INFO org.apache.bookkeeper.tools.cli.commands.bookies.ListBookiesCommand - BookieID:mq8:3181, IP:xxx, Port:3181, Hostname:mq8
16:18:19.134 [main] INFO org.apache.bookkeeper.tools.cli.commands.bookies.ListBookiesCommand - BookieID:mq7:3181, IP:xxx, Port:3181, Hostname:mq7
16:18:19.134 [main] INFO org.apache.bookkeeper.tools.cli.commands.bookies.ListBookiesCommand - BookieID:mq5:3181, IP:xxx, Port:3181, Hostname:mq5
16:18:19.134 [main] INFO org.apache.bookkeeper.tools.cli.commands.bookies.ListBookiesCommand - BookieID:mq6:3181, IP:xxx, Port:3181, Hostname:mq6
16:18:19.240 [Thread-1] WARN org.apache.zookeeper.Login - TGT renewal thread has been interrupted and will exit.
[test@mq5 middleware]$ ./bin/bookkeeper shell listledgers
# 以下节选部分输出
...
JMX enabled by default
org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand - ledgerID: 480
16:21:33.704 [main-EventThread] INFO org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand - ledgerID: 481
16:21:33.704 [main-EventThread] INFO org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand - ledgerID: 482
16:21:33.704 [main-EventThread] INFO org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand - ledgerID: 483
16:21:33.704 [main-EventThread] INFO org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand - ledgerID: 484
16:21:33.704 [main-EventThread] INFO org.apache.bookkeeper.tools.cli.commands.bookie.ListLedgersCommand - ledgerID: 485
...
485
的元数据。[test@mq5 middleware]$ ./bin/bookkeeper shell ledgermetadata -l 485
JMX enabled by default
17:19:47.521 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - ledgerID: 488
17:19:47.532 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - LedgerMetadata{
formatVersion=3, ensembleSize=2, writeQuorumSize=2, ackQuorumSize=2, state=OPEN, digestType=CRC32C, password=base64:, ensembles={
0=[mq8:3181, mq6:3181]}, customMetadata={
component=base64:bWFuYWdlZC1sZWRnZXI=, pulsar/managed-ledger=base64:cHVibGljL2RlZmF1bHQvcGVyc2lzdGVudC90ZXN0Mg==, application=base64:cHVsc2Fy}}
17:19:47.639 [Thread-1] WARN org.apache.zookeeper.Login - TGT renewal thread has been interrupted and will exit.
public/default/persistent/test2
的数据。通过命令echo "cHVibGljL2RlZmF1bHQvcGVyc2lzdGVudC90ZXN0Mg=="| base64 -d
得到./bin/pulsar-daemon stop bookie
ledger485
的元数据。发现还为发生变化。[test@mq5 middleware]$ ./bin/bookkeeper shell ledgermetadata -l 485
JMX enabled by default
17:19:47.521 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - ledgerID: 488
17:19:47.532 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - LedgerMetadata{
formatVersion=3, ensembleSize=2, writeQuorumSize=2, ackQuorumSize=2, state=OPEN, digestType=CRC32C, password=base64:, ensembles={
0=[mq8:3181, mq6:3181]}, customMetadata={
component=base64:bWFuYWdlZC1sZWRnZXI=, pulsar/managed-ledger=base64:cHVibGljL2RlZmF1bHQvcGVyc2lzdGVudC90ZXN0Mg==, application=base64:cHVsc2Fy}}
17:19:47.639 [Thread-1] WARN org.apache.zookeeper.Login - TGT renewal thread has been interrupted and will exit.
[test@mq5 middleware]$ ./bin/bookkeeper shell listunderreplicated
JMX enabled by default
15:58:23.932 [main] INFO org.apache.bookkeeper.tools.cli.commands.autorecovery.ListUnderReplicatedCommand - 485
15:58:23.938 [main] INFO org.apache.bookkeeper.tools.cli.commands.autorecovery.ListUnderReplicatedCommand - Cti
15:58:24.045 [Thread-1] WARN org.apache.zookeeper.Login - TGT renewal thread has been interrupted and will exit.
[test@mq5 middleware]$ ./bin/bookkeeper shell listunderreplicated
JMX enabled by default
ledger485
的元数据。我们xxxxxxxxxx [test@mq5 middleware]$ ./bin/bookkeeper shell ledgermetadata -l 485JMX enabled by default17:22:52.300 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - ledgerID: 48817:22:52.311 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - LedgerMetadata{
formatVersion=3, ensembleSize=2, writeQuorumSize=2, ackQuorumSize=2, state=OPEN, digestType=CRC32C, password=base64:, ensembles={
0=[mq7:3181, mq6:3181], 13=[mq5:3181, mq6:3181]}, customMetadata={
pulsar/managed-ledger=base64:cHVibGljL2RlZmF1bHQvcGVyc2lzdGVudC90ZXN0Mg==, component=base64:bWFuYWdlZC1sZWRnZXI=, application=base64:cHVsc2Fy}}17:22:52.419 [Thread-1] WARN org.apache.zookeeper.Login - TGT renewal thread has been interrupted and will exit.shell
我们可以观察下ledger位置的变化。
在停掉bookie8之前,元数据显示ensemble为
ensembles={
0=[mq8:3181, mq6:3181]},
在停掉之后,元数据显示ensemble为:
ensembles={
0=[mq7:3181, mq6:3181], 13=[mq5:3181, mq6:3181]}
解释:该现象说明:
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。