github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/docs/source/configtxgen.rst (about) 1 Configuring using the configtxgen tool 2 ====================================== 3 4 This document describe the usage for the ``configtxgen`` utility for 5 manipulating fabric channel configuration. 6 7 For now, the tool is primarily focused on generating the genesis block 8 for bootstrapping the orderer, but it is intended to be enhanced in the 9 future for generating new channel configurations as well as 10 reconfiguring existing channels. 11 12 Building the tool 13 ----------------- 14 15 Building the tool is as simple as ``make configtxgen``. This will create 16 a ``configtxgen`` binary at ``build/bin/configtxgen`` which is included 17 in the Vagrant development environment path by default. 18 19 Configuration Profiles 20 ---------------------- 21 22 The configuration parameters supplied to the ``configtxgen`` tool are 23 primarily provided by the ``configtx.yaml`` file. This file is located 24 at ``fabric/sampleconfig/configtx.yaml`` in the fabric.git 25 repository. 26 27 This configuration file is split primarily into three pieces. 28 29 1. The ``Profiles`` section. By default, this section includes some 30 sample configurations which can be used for development or testing 31 scenarios, and refer to crypto material present in the fabric.git 32 tree. These profiles can make a good starting point for construction 33 a real deployment profile. The ``configtxgen`` tool allows you to 34 specify the profile it is operating under by passing the ``-profile`` 35 flag. Profiles may explicitly declare all configuration, but usually 36 inherit configuration from the defaults in (3) below. 37 2. The ``Organizations`` section. By default, this section includes a 38 single reference to the sampleconfig MSP definition. For production 39 deployments, the sample organization should be removed, and the MSP 40 definitions of the network members should be referenced and defined 41 instead. Each element in the ``Organizations`` section should be 42 tagged with an anchor label such as ``&orgName`` which will allow the 43 definition to be referenced in the ``Profiles`` sections. 44 3. The default sections. There are default sections for ``Orderer`` and 45 ``Application`` configuration, these include attributes like 46 ``BatchTimeout`` and are generally used as the base inherited values 47 for the profiles. 48 49 This configuration file may be edited, or, individual properties may be 50 overridden by setting environment variables, such as 51 ``CONFIGTX_ORDERER_ORDERERTYPE=kafka``. Note that the ``Profiles`` 52 element and profile name do not need to be specified. 53 54 Bootstrapping the orderer 55 ------------------------- 56 57 After creating a configuration profile as desired, simply invoke 58 59 :: 60 61 configtxgen -profile <profile_name> 62 63 This will produce a ``genesis.block`` file in the current directory. You 64 may optionally specify another filename by passing in the ``-path`` 65 parameter, or, you may skip the writing of the file by passing the 66 ``dryRun`` parameter if you simply wish to test parsing of the file. 67 68 Then, to utilize this genesis block, before starting the orderer, simply 69 specify ``ORDERER_GENERAL_GENESISMETHOD=file`` and 70 ``ORDERER_GENERAL_GENESISFILE=$PWD/genesis.block`` or modify the 71 ``orderer.yaml`` file to encode these values. 72 73 Creating a channel 74 ------------------ 75 76 The tool can also output a channel creation tx by executing 77 78 :: 79 80 configtxgen -profile <profile_name> -channelID <channel_name> -outputCreateChannelTx <tx_filename> 81 82 This will output a marshaled ``Envelope`` message which may be sent to 83 broadcast to create a channel. 84 85 Reviewing a configuration 86 ------------------------- 87 88 In addition to creating configuration, the ``configtxgen`` tool is also 89 capable of inspecting configuration. 90 91 It supports inspecting both configuration blocks, and configuration 92 transactions. You may use the inspect flags ``-inspectBlock`` and 93 ``-inspectChannelCreateTx`` respectively with the path to a file to 94 inspect to output a human readable (JSON) representation of the 95 configuration. 96 97 You may even wish to combine the inspection with generation. For 98 example: 99 100 :: 101 102 $ build/bin/configtxgen -channelID foo -outputBlock foo.block -inspectBlock foo.block 103 2017/03/01 21:24:24 Loading configuration 104 2017/03/01 21:24:24 Checking for configtx.yaml at: 105 2017/03/01 21:24:24 Checking for configtx.yaml at: 106 2017/03/01 21:24:24 Checking for configtx.yaml at: /home/yellickj/go/src/github.com/hyperledger/fabric/common/configtx/tool 107 2017/03/01 21:24:24 map[orderer:map[BatchSize:map[MaxMessageCount:10 AbsoluteMaxBytes:99 MB PreferredMaxBytes:512 KB] Kafka:map[Brokers:[127.0.0.1:9092]] Organizations:<nil> OrdererType:solo Addresses:[127.0.0.1:7050] BatchTimeout:10s] application:map[Organizations:<nil>] profiles:map[SampleInsecureSolo:map[Orderer:map[BatchTimeout:10s BatchSize:map[MaxMessageCount:10 AbsoluteMaxBytes:99 MB PreferredMaxBytes:512 KB] Kafka:map[Brokers:[127.0.0.1:9092]] Organizations:<nil> OrdererType:solo Addresses:[127.0.0.1:7050]] Application:map[Organizations:<nil>]] SampleInsecureKafka:map[Orderer:map[Addresses:[127.0.0.1:7050] BatchTimeout:10s BatchSize:map[AbsoluteMaxBytes:99 MB PreferredMaxBytes:512 KB MaxMessageCount:10] Kafka:map[Brokers:[127.0.0.1:9092]] Organizations:<nil> OrdererType:kafka] Application:map[Organizations:<nil>]] SampleSingleMSPSolo:map[Orderer:map[OrdererType:solo Addresses:[127.0.0.1:7050] BatchTimeout:10s BatchSize:map[MaxMessageCount:10 AbsoluteMaxBytes:99 MB PreferredMaxBytes:512 KB] Kafka:map[Brokers:[127.0.0.1:9092]] Organizations:[map[Name:SampleOrg ID:DEFAULT MSPDir:msp BCCSP:map[Default:SW SW:map[Hash:SHA3 Security:256 FileKeyStore:map[KeyStore:<nil>]]] AnchorPeers:[map[Host:127.0.0.1 Port:7051]]]]] Application:map[Organizations:[map[Name:SampleOrg ID:DEFAULT MSPDir:msp BCCSP:map[Default:SW SW:map[Hash:SHA3 Security:256 FileKeyStore:map[KeyStore:<nil>]]] AnchorPeers:[map[Port:7051 Host:127.0.0.1]]]]]]] organizations:[map[Name:SampleOrg ID:DEFAULT MSPDir:msp BCCSP:map[Default:SW SW:map[Hash:SHA3 Security:256 FileKeyStore:map[KeyStore:<nil>]]] AnchorPeers:[map[Host:127.0.0.1 Port:7051]]]]] 108 2017/03/01 21:24:24 Generating genesis block 109 2017/03/01 21:24:24 Writing genesis block 110 2017/03/01 21:24:24 Inspecting block 111 2017/03/01 21:24:24 Parsing genesis block 112 Config for channel: foo 113 { 114 "": { 115 "Values": {}, 116 "Groups": { 117 "/Channel": { 118 "Values": { 119 "HashingAlgorithm": { 120 "Version": "0", 121 "ModPolicy": "", 122 "Value": { 123 "name": "SHA256" 124 } 125 }, 126 "BlockDataHashingStructure": { 127 "Version": "0", 128 "ModPolicy": "", 129 "Value": { 130 "width": 4294967295 131 } 132 }, 133 "OrdererAddresses": { 134 "Version": "0", 135 "ModPolicy": "", 136 "Value": { 137 "addresses": [ 138 "127.0.0.1:7050" 139 ] 140 } 141 } 142 }, 143 "Groups": { 144 "/Channel/Orderer": { 145 "Values": { 146 "ChainCreationPolicyNames": { 147 "Version": "0", 148 "ModPolicy": "", 149 "Value": { 150 "names": [ 151 "AcceptAllPolicy" 152 ] 153 } 154 }, 155 "ConsensusType": { 156 "Version": "0", 157 "ModPolicy": "", 158 "Value": { 159 "type": "solo" 160 } 161 }, 162 "BatchSize": { 163 "Version": "0", 164 "ModPolicy": "", 165 "Value": { 166 "maxMessageCount": 10, 167 "absoluteMaxBytes": 103809024, 168 "preferredMaxBytes": 524288 169 } 170 }, 171 "BatchTimeout": { 172 "Version": "0", 173 "ModPolicy": "", 174 "Value": { 175 "timeout": "10s" 176 } 177 }, 178 "IngressPolicyNames": { 179 "Version": "0", 180 "ModPolicy": "", 181 "Value": { 182 "names": [ 183 "AcceptAllPolicy" 184 ] 185 } 186 }, 187 "EgressPolicyNames": { 188 "Version": "0", 189 "ModPolicy": "", 190 "Value": { 191 "names": [ 192 "AcceptAllPolicy" 193 ] 194 } 195 } 196 }, 197 "Groups": {} 198 }, 199 "/Channel/Application": { 200 "Values": {}, 201 "Groups": {} 202 } 203 } 204 } 205 } 206 } 207 }