Skip to content

Commit a3db153

Browse files
committed
Getting Started Updates
add "Clean up" section with docker-compose down add grep IPAddress to docke inspect command Docker additions in troubleshooting to help resolve DNS errors. Hard code orderer and peer IP addresses so they can resolve change command to exec into cli change optional section to create a new channel this will better demonstrate multichannel [ci skip] Change-Id: I7a0b12dd4134a9aca0767f8dc8e176249a1404d4 Signed-off-by: Nick Gaski <[email protected]>
1 parent a4d294f commit a3db153

File tree

1 file changed

+111
-41
lines changed

1 file changed

+111
-41
lines changed

docs/gettingstarted.md

+111-41
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ automatically download, extract, and run when you execute the `docker-compose` c
6969
## Commands
7070

7171
The channel commands are:
72-
* "create" - create and name a channel in the `orderer` and get back a genesis
72+
73+
* `create` - create and name a channel in the `orderer` and get back a genesis
7374
block for the channel. The genesis block is named in accordance with the channel name.
74-
* "join" - use the genesis block from the `create` command to issue a join
75-
request to a Peer.
75+
* `join` - use the genesis block from the `create` command to issue a join
76+
request to a peer.
7677

7778
## Use Docker to spawn network entities & create/join a channel
7879

@@ -84,7 +85,7 @@ Create network entities, create channel, join peers to channel:
8485
```bash
8586
docker-compose -f docker-compose-gettingstarted.yml up -d
8687
```
87-
Behind the scenes this started six containers (3 peers, a "solo" orderer, CLI and CA)
88+
Behind the scenes this started six containers (3 peers, a "solo" orderer, cli and CA)
8889
in detached mode. A script - `channel_test.sh` - embedded within the
8990
`docker-compose-gettingstarted.yml` issued the create channel and join channel
9091
commands within the CLI container. In the end, you are left with a network and
@@ -95,18 +96,17 @@ View your containers:
9596
# if you have no other containers running, you will see six
9697
docker ps
9798
```
98-
9999
Ensure the channel has been created and peers have successfully joined:
100100
```bash
101-
docker exec -it cli sh
101+
docker exec -it cli bash
102102
```
103103
You should see the following in your terminal:
104104
```bash
105105
/opt/gopath/src/github.com/hyperledger/fabric/peer #
106106
```
107107
To view results for channel creation/join:
108108
```bash
109-
cat results.txt
109+
more results.txt
110110
```
111111
You're looking for:
112112
```bash
@@ -116,15 +116,20 @@ SUCCESSFUL JOIN CHANNEL on PEER1
116116
SUCCESSFUL JOIN CHANNEL on PEER2
117117
```
118118

119-
To verify the genesis block for the channel was created you can issue:
119+
To view genesis block:
120+
```bash
121+
more myc1.block
122+
```
123+
124+
Exit the cli container:
120125
```bash
121-
ls -ltr myc1.block
126+
exit
122127
```
123128

124129
## Curl the application source code and SDK modules
125130

126131
* Prior to issuing the command, make sure you are in the same working directory
127-
where you curled the network code.
132+
where you curled the network code. AND make sure you have exited the cli container.
128133
* Execute the following command:
129134
```bash
130135
curl -OOOOOO https://raw.githubusercontent.com/hyperledger/fabric-sdk-node/master/examples/balance-transfer/{config.json,deploy.js,helper.js,invoke.js,query.js,package.json}
@@ -147,93 +152,147 @@ the provisioned Certificate Authority. Once the client is properly authenticate
147152
the programs will demonstrate basic chaincode functionalities - deploy, invoke, and query. Make
148153
sure you are in the working directory where you pulled the source code before proceeding.
149154

155+
Upon success of each node program, you will receive a "200" response in the terminal.
156+
150157
Register/enroll & deploy chaincode (Linux or OSX):
151158
```bash
159+
# Deploy initializes key value pairs of "a","100" & "b","200".
152160
GOPATH=$PWD node deploy.js
153161
```
154162
Register/enroll & deploy chaincode (Windows):
155163
```bash
164+
# Deploy initializes key value pairs of "a","100" & "b","200".
156165
SET GOPATH=%cd%
157166
node deploy.js
158167
```
159-
Issue an invoke. Move units from "a" to "b":
168+
Issue an invoke. Move units 100 from "a" to "b":
160169
```bash
161170
node invoke.js
162171
```
163-
Query against key value "a":
172+
Query against key value "b":
164173
```bash
174+
# this should return a value of 300
165175
node query.js
166176
```
167-
You will receive a "200 response" in your terminal if each command is successful.
168-
Explore the various javascript programs to better understand the SDK and APIs.
177+
Explore the various node.js programs, along with `example_cc.go` to better understand
178+
the SDK and APIs.
169179

170-
## Manually create and join channel (optional)
180+
## Manually create and join peers to a new channel
181+
182+
Use the cli container to manually exercise the create channel and join channel APIs.
183+
184+
Channel - `myc1` already exists, so let's create a new channel named `myc2`.
171185

172-
To manually exercise the create channel and join channel APIs through the CLI container, you will
173-
need to edit the Docker Compose file. Use an editor to open `docker-compose-gettingstarted.yml` and
174-
comment out the `channel_test.sh` command in your cli image. Simply place a `#` to the left
175-
of the command. For example:
176-
```bash
177-
cli:
178-
container_name: cli
179-
<CONTENT REMOVED FOR BREVITY>
180-
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
181-
# command: sh -c './channel_test.sh; sleep 1000'
182-
# command: /bin/sh
183-
```
184186
Exec into the cli container:
185187
```bash
186-
docker exec -it cli sh
188+
docker exec -it cli bash
187189
```
188190
If successful, you should see the following in your terminal:
189191
```bash
190192
/opt/gopath/src/github.com/hyperledger/fabric/peer #
191193
```
192194
Send createChannel API to Ordering Service:
193195
```
194-
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer channel create -c myc1
196+
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer channel create -c myc2
195197
```
196-
This will return a genesis block - `myc1.block` - that you can issue join commands with.
198+
This will return a genesis block - `myc2.block` - that you can issue join commands with.
197199
Next, send a joinChannel API to `peer0` and pass in the genesis block as an argument.
198200
The channel is defined within the genesis block:
199201
```
200-
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc1.block
202+
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc2.block
201203
```
202204
To join the other peers to the channel, simply reissue the above command with `peer1`
203205
or `peer2` specified. For example:
204206
```
205-
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer1:7051 peer channel join -b myc1.block
207+
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer1:7051 peer channel join -b myc2.block
206208
```
207209
Once the peers have all joined the channel, you are able to issues queries against
208210
any peer without having to deploy chaincode to each of them.
209211

210-
## Use cli to deploy, invoke and query (optional)
212+
## Use cli to deploy, invoke and query
211213

212214
Run the deploy command. This command is deploying a chaincode named `mycc` to
213-
`peer0` on the Channel ID `myc1`. The constructor message is initializing `a` and
215+
`peer0` on the Channel ID `myc2`. The constructor message is initializing `a` and
214216
`b` with values of 100 and 200 respectively.
215217
```
216-
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode deploy -C myc1 -n mycc -p github.com/hyperledger/fabric/examples -c '{"Args":["init","a","100","b","200"]}'
218+
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode deploy -C myc2 -n mycc -p github.com/hyperledger/fabric/examples -c '{"Args":["init","a","100","b","200"]}'
217219
```
218220
Run the invoke command. This invocation is moving 10 units from `a` to `b`.
219221
```
220-
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode invoke -C myc1 -n mycc -c '{"function":"invoke","Args":["move","a","b","10"]}'
222+
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode invoke -C myc2 -n mycc -c '{"function":"invoke","Args":["move","a","b","10"]}'
221223
```
222224
Run the query command. The invocation transferred 10 units from `a` to `b`, therefore
223225
a query against `a` should return the value 90.
224226
```
225-
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode query -C myc1 -n mycc -c '{"function":"invoke","Args":["query","a"]}'
227+
CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 peer chaincode query -C myc2 -n mycc -c '{"function":"invoke","Args":["query","a"]}'
226228
```
227229
You can issue an `exit` command at any time to exit the cli container.
228230

231+
## Creating your initial channel through the cli
232+
233+
If you want to manually create the initial channel through the cli container, you will
234+
need to edit the Docker Compose file. Use an editor to open `docker-compose-gettingstarted.yml` and
235+
comment out the `channel_test.sh` command in your cli image. Simply place a `#` to the left
236+
of the command. (Recall that this script is executing the create and join channel
237+
APIs when you run `docker-compose up`) For example:
238+
```bash
239+
cli:
240+
container_name: cli
241+
<CONTENT REMOVED FOR BREVITY>
242+
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
243+
# command: sh -c './channel_test.sh; sleep 1000'
244+
# command: /bin/sh
245+
```
246+
247+
Then use the cli commands from the prior two sections.
248+
229249
## Troubleshooting (optional)
230250

231-
If you have existing containers running you may receive an error indicating that a port is
251+
If you have existing containers running, you may receive an error indicating that a port is
232252
already occupied. If this occurs, you will need to kill the container that is using said port.
233253

234254
If a file cannot be located, make sure your curl commands executed successfully and make
235255
sure you are in the directory where you pulled the source code.
236256

257+
If you are receiving timeout or GRPC communication errors, try restarting your
258+
failing docker process. For example:
259+
```bash
260+
docker stop peer0
261+
```
262+
Then:
263+
```bash
264+
docker start peer0
265+
```
266+
267+
Another approach to GRPC and DNS errors (peer failing to resolve with orderer and vice
268+
versa) is to hardcode the IP addresses for each. You will know if there is a DNS
269+
issue, because a `more results.txt` command within the cli container will display
270+
something similar to:
271+
```bash
272+
ERROR CREATING CHANNEL
273+
PEER0 ERROR JOINING CHANNEL
274+
```
275+
276+
Issue a `docker inspect <container_name>` to ascertain the IP address. For example:
277+
```bash
278+
docker inspect peer0 | grep IPAddress
279+
```
280+
AND
281+
```bash
282+
docker inspect orderer | grep IPAddress
283+
```
284+
Take these values and hard code them into your cli commands. For example:
285+
```bash
286+
CORE_PEER_COMMITTER_LEDGER_ORDERER=172.21.0.2:7050 peer channel create -c myc1
287+
```
288+
AND THEN
289+
```bash
290+
CORE_PEER_COMMITTER_LEDGER_ORDERER=<IP_ADDRESS> CORE_PEER_ADDRESS=<IP_ADDRESS> peer channel join -b myc1.block
291+
```
292+
293+
If you are seeing errors while using the node SDK, make sure you have a current version
294+
of node.js and npm installed on your machine.
295+
237296
If you ran through the automated channel create/join process (i.e. did not comment out
238297
`channel_test.sh` in the `docker-compose-gettingstarted.yml`), then channel - `myc1` - and
239298
genesis block - `myc1.block` - have already been created and exist on your machine.
@@ -259,8 +318,9 @@ Then join:
259318
CORE_PEER_COMMITTER_LEDGER_ORDERER=orderer:7050 CORE_PEER_ADDRESS=peer0:7051 peer channel join -b myc2.block
260319
```
261320

262-
If you do choose to create a new channel, you will also need to edit the "channelID" parameter
263-
in the `config.json` file to match the new channel's name. For example:
321+
If you do choose to create a new channel, and want to run deploy/invoke/query with
322+
the node.js programs, you also need to edit the "channelID" parameter in the
323+
`config.json` file to match the new channel's name. For example:
264324
```
265325
{
266326
"chainName":"fabric-client1",
@@ -271,7 +331,17 @@ in the `config.json` file to match the new channel's name. For example:
271331
```
272332

273333
OR, if you want your channel called - `myc1` -, remove your docker containers and
274-
then follow the same commands in the __Manually create and join channel__ section.
334+
then follow the same commands in the __Manually create and join peers to a new channel__
335+
section.
336+
337+
## Clean up
338+
339+
Shut down your containers:
340+
```bash
341+
docker-compose -f docker-compose-gettingstarted.yml down
342+
```
343+
344+
## Helpful Docker tips
275345

276346
Remove a specific docker container:
277347
```bash

0 commit comments

Comments
 (0)