You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

participant.md 11 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. ### 共识节点变更
  2. 借助`BFT-SMaRt`共识提供的Reconfig操作元语,`JD Chain`实现了在不停机的情况下快速更新共识网络拓扑,实现添加共识节点,移除共识节点,更新共识信息 等功能。
  3. ```bash
  4. :bin$ ./jdchain-cli.sh participant -h
  5. Usage: jdchain-cli participant [-hV] [--pretty] [--home=<path>] [COMMAND]
  6. Add, update or delete participant.
  7. -h, --help Show this help message and exit.
  8. --home=<path> Set the home directory.
  9. Default: ../
  10. --pretty Pretty json print
  11. -V, --version Print version information and exit.
  12. Commands:
  13. register Register new participant.
  14. active Active participant.
  15. update Update participant.
  16. inactive Inactive participant.
  17. help Displays help information about the specified command
  18. ```
  19. - `register` [注册新节点](#注册新节点)
  20. - `active` [激活节点](#激活节点)
  21. - `active` [更新节点](#更新节点)
  22. - `inactive` [移除节点](#移除节点)
  23. #### 注册新节点
  24. ```bash
  25. :bin$ ./jdchain-cli.sh participant register -h
  26. Register new participant.
  27. Usage: jdchain-cli participant register [-hV] [--pretty] [--gw-host=<gwHost>]
  28. [--gw-port=<gwPort>] [--home=<path>]
  29. --name=<name>
  30. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  31. --gw-port=<gwPort> Set the gateway port. Default: 8080
  32. -h, --help Show this help message and exit.
  33. --home=<path> Set the home directory.
  34. --name=<name> Name of the participant
  35. --pretty Pretty json print
  36. -V, --version Print version information and exit.
  37. ```
  38. - `name`,新节点名称
  39. 注册新节点:
  40. ```bash
  41. :bin$ ./jdchain-cli.sh participant register --name node4
  42. select ledger, input the index:
  43. INDEX LEDGER
  44. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  45. // 选择账本
  46. > 0
  47. // 选择待注册节点公私钥(链上必须不存在此公私钥对应的用户)
  48. select keypair to register, input the index:
  49. 0 k1 LdeNq3862vtUCeptww1T5mVvLbAeppYqVNdqD
  50. 1 1627618939 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  51. 2 node4 LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T
  52. 2
  53. input password of the key:
  54. > 1
  55. // 选择此交易签名用户(必须是链上存在的用户,且有相应操作权限)
  56. select keypair to sign tx, input the index:
  57. 0 k1 LdeNq3862vtUCeptww1T5mVvLbAeppYqVNdqD
  58. 1 1627618939 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  59. 2 node4 LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T
  60. 1
  61. input password of the key:
  62. > 1
  63. register participant: [LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T]
  64. ```
  65. 成功在账本`j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg`中注册了新的节点`LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T`
  66. 可通过[共识节点列表](query.md#共识节点列表)查看新的账本列表:
  67. ```bash
  68. :bin$ ./jdchain-cli.sh query participants
  69. select ledger, input the index:
  70. INDEX LEDGER
  71. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  72. > 0
  73. [{"address":"LdeNwsiuo7n6HULWhNKc87PBXJXAfGKFon9RE","id":2,"name":"2","participantNodeState":"CONSENSUS","pubKey":"7VeRFF1ednwhrFoe5cngKwPUJ2N4iFKD9Jt53GxSCc1MmPQ6"},{"address":"LdeNiXZbsBCsTc2ZGp1PGBX81aUxPekhwEwmY","id":1,"name":"1","participantNodeState":"CONSENSUS","pubKey":"7VeREmuT4fF9yRPEMbSSaNLKbLa3qoTpfGHRgwpnSWUn5tqW"},{"address":"LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T","id":4,"name":"node4","participantNodeState":"READY","pubKey":"7VeRKiWHcHjNoYH9kJk2fxoJxgBrstVJ7bHRecKewJAKcvUD"},{"address":"LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw","id":0,"name":"0","participantNodeState":"CONSENSUS","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"},{"address":"LdeP2ji8PR1DPsLt5NoFeiBnhpckrLHgCJge6","id":3,"name":"3","participantNodeState":"CONSENSUS","pubKey":"7VeRGE4V9MR7HgAqTrkxGvJvaaKRZ3fAjHUjYzpNBGcjfAvr"}]
  74. register participant: [LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T]
  75. ```
  76. 可以看出`node4`注册成功,地址为`LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T`
  77. #### 激活节点
  78. 激活节点前请正确配置并启动新节点,以下以刚注册成功的`node4`为例
  79. 1. 配置`node4`
  80. 解压`peer`压缩包,复制待加入账本其他节点中数据最新的节点数据库数据,然后修改`config/ledger-binding.conf`:
  81. ```bash
  82. # Base58编码的账本哈希
  83. ledger.bindings=<账本hash>
  84. # 账本名字,与账本相关的其他其他peer保持一致
  85. binding.<账本HASH>.name=<节点名称>
  86. # peer4的名名称,与[向现有共识网络注册新的参与方]操作中保持一致
  87. binding.<账本hash>.parti.name=<节点名称>
  88. # peer4的用户地址
  89. binding.<账本hash>.parti.address=<peer4的用户地址>
  90. # 新参与方base58编码的私钥,与[向现有共识网络注册新的参与方]操作中保持一致
  91. binding.<账本hash>.parti.pk=<新参与方base58编码的私钥>
  92. # 新参与方base58编码的私钥读取密码,与[向现有共识网络注册新的参与方]操作中保持一致
  93. binding.<账本hash>.parti.pwd=<新参与方base58编码的私钥读取密码>
  94. # 新参与方对应的账本数据库连接uri,即peer4的账本数据库存放位置,参照其他peer修改,不可与其他peer混用
  95. binding.<账本hash>.db.uri=<账本数据库连接>
  96. ```
  97. 2. 启动`node4`
  98. | **一定注意在启动新参与方节点进程之前确保完成了账本数据库的复制工作**
  99. 执行`peer4`中`bin`目录下`peer-startup.sh`脚本启动启动新参与方`peer4`节点进程:
  100. ```bash
  101. ./peer-startup.sh
  102. ```
  103. 3. 激活新节点
  104. ```bash
  105. :bin$ ./jdchain-cli.sh participant active -h
  106. Active participant.
  107. Usage: jdchain-cli participant active [-hV] [--pretty] [--shutdown]
  108. --consensus-port=<consensusPort>
  109. [--home=<path>] --host=<host>
  110. --ledger=<ledger> --port=<port>
  111. --syn-host=<synHost> --syn-port=<synPort>
  112. --consensus-port=<consensusPort>
  113. Set the participant consensus port.
  114. -h, --help Show this help message and exit.
  115. --home=<path> Set the home directory.
  116. --host=<host> Set the participant host.
  117. --ledger=<ledger> Set the ledger.
  118. --port=<port> Set the participant service port.
  119. --pretty Pretty json print
  120. --shutdown Restart the node server.
  121. --syn-host=<synHost> Set synchronization participant host.
  122. --syn-port=<synPort> Set synchronization participant port.
  123. -V, --version Print version information and exit.
  124. ```
  125. - `ledger`,账本哈希
  126. - `host`,新节点地址
  127. - `port`,新节点服务端口
  128. - `consensus-port`,新节点共识端口
  129. - `syn-host`,数据同步节点地址
  130. - `syn-port`,数据同步节点服务端口
  131. 在账本`j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg`中激活`node4`(以步骤2中启动的服务地址和端口为`127.0.0.1`和`7084`例),共识端口设置为`10088`,同步节点地址和端口为`127.0.0.1`和`7080`为例:
  132. ```bash
  133. :bin$./jdchain-cli.sh participant active --ledger j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg --host 127.0.0.1 --port 7084 --consensus-port 10088 --syn-host 127.0.0.1 --syn-port 7080
  134. participant activated
  135. ```
  136. 成功后可通过[共识节点列表](query.md#共识节点列表)查询最新共识节点列表状态,`node4`为`CONSENSUS`
  137. #### 更新节点
  138. 通过[激活节点](#激活节点)操作除了激活新增的节点外,还可以动态修改已经处于激活状态的共识节点的`IP`和`共识端口`信息,从而实现本机的共识端口变更,不同机器之间进行`账本迁移`。
  139. | **在进行节点信息变更时,要求暂停向共识网络中发起新的业务数据上链请求**
  140. 1. 变更共识端口
  141. | **操作前请确保变更到的端口未被占用**
  142. 如将`node4`共识端口由`10088`修改为`10188`,操作指令如下:
  143. ```bash
  144. :bin$./jdchain-cli.sh participant update --ledger j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg --host 127.0.0.1 --port 7084 --consensus-port 10188 --syn-host 127.0.0.1 --syn-port 7080
  145. participant updated
  146. ```
  147. 指令成功执行后,`peer1`的共识端口将自动变更为`10188`
  148. 2. 账本迁移
  149. 账本迁移指将一台机器(`IP`)上的共识节点迁移到另一台机器(`IP`)上,主要操作流程如下:
  150. | **操作前请确保变更到的端口未被占用**
  151. 如将`node4`共识`IP`由`127.0.0.1`修改为`192.168.1.100`(另一台机器),操作指令如下:
  152. ```bash
  153. :bin$./jdchain-cli.sh participant update --ledger j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg --host 192.168.1.100 --port 7084 --consensus-port 10188 --syn-host 127.0.0.1 --syn-port 7080 -shutdown
  154. participant updated
  155. ```
  156. **特别注意**:`-shutdown`会停止当前运行的当前账本共识服务,为必填选项,否则可能将导致整个网络需要重启。
  157. #### 移除节点
  158. ```
  159. :bin$ ./jdchain-cli.sh participant inactive -h
  160. Inactive participant.
  161. Usage: jdchain-cli participant inactive [-hV] [--pretty] --address=<address>
  162. [--home=<path>] --host=<host>
  163. --ledger=<ledger> --port=<port>
  164. --syn-host=<synHost>
  165. --syn-port=<synPort>
  166. --address=<address> Set the participant address.
  167. -h, --help Show this help message and exit.
  168. --home=<path> Set the home directory.
  169. --host=<host> Set the participant host.
  170. --ledger=<ledger> Set the ledger.
  171. --port=<port> Set the participant service port.
  172. --pretty Pretty json print
  173. --syn-host=<synHost> Set synchronization participant host.
  174. --syn-port=<synPort> Set synchronization participant port.
  175. -V, --version Print version information and exit.
  176. ```
  177. - `ledger`,账本哈希
  178. - `address`,待移除节点共识端口
  179. - `host`,待移除节点服务地址
  180. - `port`,待移除节点服务端口
  181. - `syn-host`,数据同步节点地址
  182. - `syn-port`,数据同步节点服务端口
  183. 如移除`node4`:
  184. ```bash
  185. :bin$ ./jdchain-cli.sh participant inactive --ledger j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg --address LdeNwG6ECEGz57o2ufhwSbnW4C35TvPqANK7T --host 127.0.0.1 --port 7084 --syn-host 127.0.0.1 --syn-port 7080
  186. participant inactivated
  187. ```
  188. 成功后可通过[共识节点列表](query.md#共识节点列表)查询最新共识节点列表状态,`node4`为`DEACTIVATED`