Skip to content

Commit

Permalink
[FAB-17800] Update peer node command doc
Browse files Browse the repository at this point in the history
Signed-off-by: Wenjian Qiao <wenjianq@gmail.com>
  • Loading branch information
wenjianqiao authored and denyeart committed Oct 29, 2020
1 parent 2bf53e6 commit 46cdc03
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 25 deletions.
130 changes: 116 additions & 14 deletions docs/source/commands/peernode.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
# peer node

The `peer node` command allows an administrator to start a peer node,
reset all channels in a peer to the genesis block, or rollback a
channel to a given block number.
pause and resume a channel, rebuild databases, reset all channels in a peer to the genesis block,
rollback a channel to a given block number, and upgrade the database format.

## Syntax

The `peer node` command has the following subcommands:

* start
* pause
* rebuild-dbs
* reset
* resume
* rollback
* start
* upgrade-dbs

## peer node start
## peer node pause
```
Starts a node that interacts with the network.
Pauses a channel on the peer. When the command is executed, the peer must be offline. When the peer starts after pause, it will not receive blocks for the paused channel.
Usage:
peer node start [flags]
peer node pause [flags]
Flags:
-h, --help help for start
--peer-chaincodedev start peer in chaincode development mode
-c, --channelID string Channel to pause.
-h, --help help for pause
```


## peer node rebuild-dbs
```
Drops the databases for all the channels and rebuilds them upon peer restart. When the command is executed, the peer must be offline. The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.
Usage:
peer node rebuild-dbs [flags]
Flags:
-h, --help help for rebuild-dbs
```


## peer node reset
```
Resets all channels to the genesis block. When the command is executed, the peer must be offline. When the peer starts after the reset, it will receive blocks starting with block number one from an orderer or another peer to rebuild the block store and state database.
Resets all channels to the genesis block. When the command is executed, the peer must be offline. When the peer starts after the reset, it will receive blocks starting with block number one from an orderer or another peer to rebuild the block store and state database. The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.
Usage:
peer node reset [flags]
Expand All @@ -37,9 +53,22 @@ Flags:
```


## peer node resume
```
Resumes a channel on the peer. When the command is executed, the peer must be offline. When the peer starts after resume, it will receive blocks for the resumed channel.
Usage:
peer node resume [flags]
Flags:
-c, --channelID string Channel to resume.
-h, --help help for resume
```


## peer node rollback
```
Rolls back a channel to a specified block number. When the command is executed, the peer must be offline. When the peer starts after the rollback, it will receive blocks, which got removed during the rollback, from an orderer or another peer to rebuild the block store and state database.
Rolls back a channel to a specified block number. When the command is executed, the peer must be offline. When the peer starts after the rollback, it will receive blocks, which got removed during the rollback, from an orderer or another peer to rebuild the block store and state database. The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.
Usage:
peer node rollback [flags]
Expand All @@ -50,27 +79,77 @@ Flags:
-h, --help help for rollback
```


## peer node start
```
Starts a node that interacts with the network.
Usage:
peer node start [flags]
Flags:
-h, --help help for start
--peer-chaincodedev start peer in chaincode development mode
```


## peer node upgrade-dbs
```
Upgrades databases by directly updating the database format or dropping the databases. Dropped databases will be rebuilt with new format upon peer restart. When the command is executed, the peer must be offline.
Usage:
peer node upgrade-dbs [flags]
Flags:
-h, --help help for upgrade-dbs
```

## Example Usage

### peer node start example
### peer node pause example

The following command:

```
peer node start --peer-chaincodedev
peer node pause -c ch1
```

starts a peer node in chaincode development mode. Normally chaincode containers are started
and maintained by peer. However in chaincode development mode, chaincode is built and started by the user. This mode is useful during chaincode development phase for iterative development.
pauses a channel on the peer. When the peer starts after pause, the paused channel will not be started
and the peer will not receive blocks for the paused channel.


### peer node rebuild-dbs example

The following command:

```
peer node rebuild-dbs
```

drops the databases for all the channels. When the peer is started after running this command, the peer will
retrieve the blocks stored on the peer and rebuild the dropped databases for all the channels.

### peer node reset example

The following command:

```
peer node reset
```

resets all channels in the peer to the genesis block, i.e., the first block in the channel. The command also records the pre-reset height of each channel in the file system. Note that the peer process should be stopped while executing this command. If the peer process is running, this command detects that and returns an error instead of performing the reset. When the peer is started after performing the reset, the peer will fetch the blocks for each channel which were removed by the reset command (either from other peers or orderers) and commit the blocks up to the pre-reset height. Until all channels reach the pre-reset height, the peer will not endorse any transactions.

### peer node resume example

The following command:

```
peer node resume -c ch1
```

resumes a channel on the peer. When the peer starts after resume, the resumed channel will be started
and the peer will receive blocks for the resumed channel.

### peer node rollback example

The following command:
Expand All @@ -81,4 +160,27 @@ peer node rollback -c ch1 -b 150

rolls back the channel ch1 to block number 150. The command also records the pre-rolled back height of channel ch1 in the file system. Note that the peer should be stopped while executing this command. If the peer process is running, this command detects that and returns an error instead of performing the rollback. When the peer is started after performing the rollback, the peer will fetch the blocks for channel ch1 which were removed by the rollback command (either from other peers or orderers) and commit the blocks up to the pre-rolled back height. Until the channel ch1 reaches the pre-rolled back height, the peer will not endorse any transaction for any channel.

### peer node start example

The following command:

```
peer node start --peer-chaincodedev
```

starts a peer node in chaincode development mode. Normally chaincode containers are started
and maintained by peer. However in chaincode development mode, chaincode is built and started by the user. This mode is useful during chaincode development phase for iterative development.

### peer node upgrade-dbs example

The following command:

```
peer node upgrade-dbs
```

checks the data format in the databases for all the channels and drops databases if data format is in the previous version.
The command will return an error if the data format is already up to date. When the peer is started after running this command,
the peer will retrieve the blocks stored on the peer and rebuild the dropped databases in the new format.

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
56 changes: 52 additions & 4 deletions docs/wrappers/peer_node_postscript.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
## Example Usage

### peer node start example
### peer node pause example

The following command:

```
peer node start --peer-chaincodedev
peer node pause -c ch1
```

starts a peer node in chaincode development mode. Normally chaincode containers are started
and maintained by peer. However in chaincode development mode, chaincode is built and started by the user. This mode is useful during chaincode development phase for iterative development.
pauses a channel on the peer. When the peer starts after pause, the paused channel will not be started
and the peer will not receive blocks for the paused channel.


### peer node rebuild-dbs example

The following command:

```
peer node rebuild-dbs
```

drops the databases for all the channels. When the peer is started after running this command, the peer will
retrieve the blocks stored on the peer and rebuild the dropped databases for all the channels.

### peer node reset example

The following command:

```
peer node reset
```

resets all channels in the peer to the genesis block, i.e., the first block in the channel. The command also records the pre-reset height of each channel in the file system. Note that the peer process should be stopped while executing this command. If the peer process is running, this command detects that and returns an error instead of performing the reset. When the peer is started after performing the reset, the peer will fetch the blocks for each channel which were removed by the reset command (either from other peers or orderers) and commit the blocks up to the pre-reset height. Until all channels reach the pre-reset height, the peer will not endorse any transactions.

### peer node resume example

The following command:

```
peer node resume -c ch1
```

resumes a channel on the peer. When the peer starts after resume, the resumed channel will be started
and the peer will receive blocks for the resumed channel.

### peer node rollback example

The following command:
Expand All @@ -29,4 +54,27 @@ peer node rollback -c ch1 -b 150

rolls back the channel ch1 to block number 150. The command also records the pre-rolled back height of channel ch1 in the file system. Note that the peer should be stopped while executing this command. If the peer process is running, this command detects that and returns an error instead of performing the rollback. When the peer is started after performing the rollback, the peer will fetch the blocks for channel ch1 which were removed by the rollback command (either from other peers or orderers) and commit the blocks up to the pre-rolled back height. Until the channel ch1 reaches the pre-rolled back height, the peer will not endorse any transaction for any channel.

### peer node start example

The following command:

```
peer node start --peer-chaincodedev
```

starts a peer node in chaincode development mode. Normally chaincode containers are started
and maintained by peer. However in chaincode development mode, chaincode is built and started by the user. This mode is useful during chaincode development phase for iterative development.

### peer node upgrade-dbs example

The following command:

```
peer node upgrade-dbs
```

checks the data format in the databases for all the channels and drops databases if data format is in the previous version.
The command will return an error if the data format is already up to date. When the peer is started after running this command,
the peer will retrieve the blocks stored on the peer and rebuild the dropped databases in the new format.

<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
10 changes: 7 additions & 3 deletions docs/wrappers/peer_node_preamble.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# peer node

The `peer node` command allows an administrator to start a peer node,
reset all channels in a peer to the genesis block, or rollback a
channel to a given block number.
pause and resume a channel, rebuild databases, reset all channels in a peer to the genesis block,
rollback a channel to a given block number, and upgrade the database format.

## Syntax

The `peer node` command has the following subcommands:

* start
* pause
* rebuild-dbs
* reset
* resume
* rollback
* start
* upgrade-dbs
2 changes: 1 addition & 1 deletion internal/peer/node/rebuild_dbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func rebuildDBsCmd() *cobra.Command {
var nodeRebuildCmd = &cobra.Command{
Use: "rebuild-dbs",
Short: "Rebuilds databases.",
Long: "Drops the databases for all the channels and rebuilds them upon peer restart. " +
Long: "Drops the databases for all the channels and rebuilds them upon peer restart." +
" When the command is executed, the peer must be offline." +
" The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.",
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
3 changes: 1 addition & 2 deletions internal/peer/node/upgrade_dbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ var nodeUpgradeDBsCmd = &cobra.Command{
Use: "upgrade-dbs",
Short: "Upgrades databases.",
Long: "Upgrades databases by directly updating the database format or dropping the databases." +
" Dropped databases will be rebuilt with new format upon peer restart. When the command is executed, the peer must be offline." +
" The command is not supported if the peer contains any channel that was bootstrapped from a snapshot.",
" Dropped databases will be rebuilt with new format upon peer restart. When the command is executed, the peer must be offline.",
RunE: func(cmd *cobra.Command, args []string) error {
config := ledgerConfig()
return kvledger.UpgradeDBs(config)
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateHelpDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ generateHelpText \
docs/wrappers/peer_channel_postscript.md \
"${commands[@]}"

commands=("peer node start" "peer node reset" "peer node rollback")
commands=("peer node pause" "peer node rebuild-dbs" "peer node reset" "peer node resume" "peer node rollback" "peer node start" "peer node upgrade-dbs")
generateHelpText \
docs/source/commands/peernode.md \
docs/wrappers/peer_node_preamble.md \
Expand Down

0 comments on commit 46cdc03

Please sign in to comment.