reddycharan opened a new issue #1026: new "initbookie" command, decoupling from 
bookieformat command
URL: https://github.com/apache/bookkeeper/issues/1026
 
 
   **FEATURE REQUEST**
   
   1. Please describe the feature you are requesting.
   
   'bookieformat' command is used both while formatting the bookie and 
initializing the new bookie. But having a omnipotent administrative commands 
with multi-purpose functionality is not desirable and too risky. Hence adding a 
new BookieShell command - "initbookie" command to decouple from bookieformat. 
This command initializes bookie, by making sure that the journalDir, ledgerDirs 
and indexDirs are empty and there is no registered Bookie with this BookieId.
   
   2. Indicate the importance of this issue to you (blocker, must-have, 
should-have, nice-to-have). Are you currently using any workarounds to address 
this issue?
   
   for our envs, this is must-have since this is omnipotent administrative 
command, it should not be prone to manual errors in the command usage.
   
   3. Provide any additional detail on your proposed use case for this feature.
   
   # **Bookkeeper Cluster and Bookie - format / initialization commands**
   
   Previously we were using 'metaformat' command for both nuking and 
initializing new Bookkeeper cluster in ZK and 'bookieformat' command for nuking 
the file system data in bookie node and initializing bookie.
   
   But having a omnipotent administrative commands with multi-purpose 
functionality is not desirable and too risky. Moreover there aren't enough 
checks in 'metaformat' to make sure that we are nuking the right cluster data 
in ZK which is even more dangerous. Also the current 'metaformat' command 
doesn't complains if the bookies are connected to the ZK while the 'metaformat' 
command is being executed, which leads to mismatched instanceids and 
consequently failure of bookie startup when it is restarted later. Hence we 
added new set of commands with decoupled functionality and more checks to not 
to make it error-prone.
   
   Following commands are introduced and going to be used for nuking and 
initializing bookkeeper cluster and bookie
   
   * whatisinstanceid
   * nukeexistingcluster
   * initnewcluster
   * bookieformat
   * initbookie
   
   The order of the commands to execute to setup a new Bookkeeper cluster is 
the following
   
   1. Shutdown all the running bookies in the cluster. If we are starting from 
a fresh state of cluster then we can ignore this step. If any of the bookie 
process is alive and connected to the ZK then nukeexistingcluster command would 
fail.
   2. In one of the bookie node, run 'whatisinstanceid' command to know the 
instanceid of the existing cluster. 'instanceid' is an unique UUID, and it is 
the id of the bookkeeper cluster. Each time Bookkeeper cluster (Zookeeper) is 
formatted/nuked and reinitialized cluster gets a new instanceid and it is 
stored in ZK and in Bookkeeper VERSION file. 'instanceid' is needed for 
executing nukeexistingcluster command. If we are starting from a fresh state of 
cluster then we can ignore this step as well.
   3. Now try running the 'nukeexistingcluster' command to delete state of 
bookkeeper cluster in ZK . For this command couple of arguments are required. 
'zkLedgersRootPath' should be provided mandatorily and 'instanceid' optionally. 
But it is suggested to provide 'instanceid' for the sake of extra validation. 
In the case of fresh cluster ignore 'instanceid' argument. The provided value 
of 'zkLedgersRootPath' should match with config value of 'zkLedgersRootPath' 
and the provided 'instanceid' should match with instanceid of the cluster in ZK.
   4. After the successful execution of 'nukeexistingcluster' command you can 
run 'initnewcluster' in one of the bookie node.
   5. Now in all of the bookies run 'bookieformat' command with force option. 
'deleteCookie' doesn't has any impact here since zk data is already wiped out 
with nukeexistingcluster command.
   6. run 'initbookie' command in all of the bookie nodes, to make sure there 
isn't any existing data for the bookie in the node filesystem and in the 
Zookeeper.
   7. start bookie process in all of the nodes.
   
   The order of the commands to execute to setup a new Bookkeeper/Bookie is the 
following
   
   1. Shutdown the bookie process in the Bookkeeper node, if it is already 
running. If it is a fresh start then ignore this step.
   2. run 'bookieformat' command with force and 'deleteCookie' options. This 
will wipe out all of the bookkeeper filesystem data - journals, ledgerdirs and 
indexdirs and Cookie of this bookie in ZK.
   3. run 'initbookie' command to make sure there isn't any existing data for 
this bookie in this node filesystem and in the Zookeeper
   4. start bookie process
   
   **Command: WhatIsInstanceIdCmd**
   
   **Usage:** whatisinstanceid
   **Type:** Metadata/Zookeeper Operation
   **Description:** 'instanceid' is an unique UUID, and it is the id of the 
bookkeeper cluster. Each time Bookkeeper cluster (Zookeeper) is formatted/nuked 
and reinitialized cluster gets a new instanceid and it is stored in ZK and 
Bookkeeper VERSION file. 'whatisinstanceid' command reads instanceid from ZK 
and prints it. This instanceid will be used as argument for nukeexistingcluster 
command.
   
   ./bookkeeper shell whatisinstanceid
   05:27:46,229 INFO  ZKServers: localhost:2181 ZkLedgersRootPath: /ledgers 
InstanceId: bbc614af-2123-4802-86ff-3d271897968d
   
   **Command: NukeExistingClusterCmd**
   
   **Usage:** nukeexistingcluster -zkledgersrootpath <zkledgersrootpath> 
[-instanceid <instanceid> | -force]
   **Type:** Metadata/Zookeeper Operation
   **Description:** Deletes the bookkeeper metadata present in zookeeper. It 
deletes all Ledger metadata layout, cookies, and the INSTANCEID from ZK. This 
command takes couple of arguments (zkledgersrootpath and instanceid) and 
validates them before proceeding with deleting ZK data. The provided 
'zkledgersrootpath' should match with 'zkledgersrootpath' config value and 
'instanceid' should match with 'instanceid' value in ZK. If it is a fresh 
cluster start or for what so ever reason 'instanceid' of the existing cluster 
can't be provided then force option can be used. 
   
   
   ./bookkeeper shell nukeexistingcluster -zkledgersrootpath /ledgers 
-instanceid bbc614af-2123-4802-86ff-3d271897968d
   05:29:48,955 INFO  Nuking ZooKeeper metadata of existing cluster, ZKServers: 
localhost:2181 ledger root path: /ledgers instanceId: 
bbc614af-2123-4802-86ff-3d271897968d
   05:29:48,989 INFO  Successfully nuked existing cluster, ZKServers: 
localhost:2181 ledger root path: /ledgers instanceId: 
bbc614af-2123-4802-86ff-3d271897968d
   
   ./bookkeeper shell nukeexistingcluster -zkledgersrootpath /ledgers -f
   05:31:51,342 INFO  Nuking ZooKeeper metadata of existing cluster, ZKServers: 
localhost:2181 ledger root path: /ledgers instanceId: null
   05:31:51,374 INFO  Successfully nuked existing cluster, ZKServers: 
localhost:2181 ledger root path: /ledgers instanceId: null
   
   
   
   **Command: InitNewClusterCmd**
   
   **Usage:** initnewcluster
   **Type:** Metadata/Zookeeper Operation
   **Description:** Intializes new cluster by creating required znodes for the 
cluster. If ledgersrootpath is already existing then it will error out. It 
creates ledgers root node, available bookies node, new layout and InstanceId. 
Thus created InstanceId will be the ID of the bookkeeper cluster.
   
   ./bookkeeper shell initnewcluster
   05:25:38,741 INFO  Initializing ZooKeeper metadata for new cluster, 
ZKServers: localhost:2181 ledger root path: /ledgers
   05:25:38,767 INFO  Successfully initiated cluster. ZKServers: localhost:2181 
ledger root path: /ledgers instanceId: bbc614af-2123-4802-86ff-3d271897968d
   
   **Command: BookieFormatCmd**
   
   **Usage:** bookieformat [-nonInteractive] [-force] [-deleteCookie]
   **Type:** Bookie Filesystem Operation
   **Description:** This command formats the local data present in current 
bookie server. It deletes the journalDir, LedgerDirs and indexDirs. Optionally 
it deletes the cookie from ZK for the current bookie. But it doesn?t deletes 
the ledger metadata from ZK. 
   
   This command is meant for formatting the bookie. ?deleteCookie? option 
should be used while formatting the bookie, otherwise when bookie is started 
after bookieformat, it will fail to create new cookie in the zookeeper because 
of the already existing cookie for that bookie in zookeeper.
   
   ./bookkeeper shell bookieformat -force -nonInteractive -deleteCookie
   
   **Command: InitBookieCmd**
   
   **Usage:** initbookie
   **Type:** Bookie Filesystem and Metadata/Zookeeper Operation
   **Description:** Initializes bookie, by making sure that the journalDir, 
ledgerDirs and indexDirs are empty and there is no registered Bookie with this 
BookieId. It actually doesn't create or modify anything but just make sure 
there isn't anything existing realted to this bookie.
   
   ./bookkeeper shell initbookie
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to