Skip to content
This repository was archived by the owner on Jan 29, 2022. It is now read-only.

Commit 8537fd0

Browse files
Ubuntupankajgoyal2
authored andcommitted
Added compose file to setup multinode Raft network on different physical machines.
Signed-off-by: Pankaj Goyal <pankaj.goyal@intel.com>
1 parent 0bc81a3 commit 8537fd0

3 files changed

Lines changed: 403 additions & 0 deletions

File tree

swarm/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
TAG=latest
2+
node1=
3+
node2=
4+
node3=

swarm/raft_3_nodes.yml

Lines changed: 362 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
1+
# Copyright 2019 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ------------------------------------------------------------------------------
15+
16+
version: "3.4"
17+
18+
networks:
19+
raftnetwork:
20+
external:
21+
name: raftnetwork
22+
23+
services:
24+
25+
validator-1:
26+
image: "hyperledger/sawtooth-validator:${TAG}"
27+
networks:
28+
raftnetwork:
29+
aliases:
30+
- validator-1
31+
deploy:
32+
mode: replicated
33+
replicas: 1
34+
placement:
35+
constraints: ["node.hostname == ${node1}"]
36+
hostname: validator-1
37+
volumes:
38+
- /home/${USER}/validator_keys:/validator_keys
39+
expose:
40+
- 4004
41+
- 8800
42+
- 5005
43+
working_dir: /root
44+
command: "bash -c \"\
45+
cp /validator_keys/validator-1.priv /etc/sawtooth/keys/validator.priv; \
46+
cp /validator_keys/validator-1.pub /etc/sawtooth/keys/validator.pub; \
47+
sawset genesis \
48+
-k /etc/sawtooth/keys/validator.priv \
49+
-o config-genesis.batch && \
50+
sawset proposal create \
51+
-k /etc/sawtooth/keys/validator.priv \
52+
sawtooth.consensus.algorithm.name=raft \
53+
sawtooth.consensus.algorithm.version=0.1 \
54+
sawtooth.gossip.time_to_live=0
55+
sawtooth.consensus.raft.peers=\\['\\\"'$$(cat /validator_keys/validator-1.pub)'\\\"','\\\"'$$(cat /validator_keys/validator-2.pub)'\\\"','\\\"'$$(cat /validator_keys/validator-3.pub)'\\\"'\\]
56+
sawtooth.consensus.raft.period=6000 \
57+
sawtooth.consensus.raft.heartbeat_tick=40 \
58+
sawtooth.consensus.raft.election_tick=200 \
59+
sawtooth.consensus.raft.leader_change_block_interval=0 \
60+
sawtooth.consensus.raft.leader_change_time_interval=360000 \
61+
sawtooth.publisher.max_batches_per_block=70 \
62+
-o config.batch && \
63+
sawadm genesis \
64+
config-genesis.batch config.batch && \
65+
echo $$(cat /etc/sawtooth/keys/validator.pub); \
66+
sawtooth-validator -v \
67+
--endpoint tcp://validator-1:8800 \
68+
--bind component:tcp://eth0:4004 \
69+
--bind network:tcp://eth0:8800 \
70+
--bind consensus:tcp://eth0:5050 \
71+
--peering static \
72+
--scheduler parallel \
73+
--maximum-peer-connectivity 1000 \
74+
\""
75+
stop_signal: SIGKILL
76+
77+
validator-2:
78+
image: "hyperledger/sawtooth-validator:${TAG}"
79+
networks:
80+
raftnetwork:
81+
aliases:
82+
- validator-2
83+
deploy:
84+
mode: replicated
85+
replicas: 1
86+
placement:
87+
constraints: ["node.hostname == ${node2}"]
88+
hostname: validator-2
89+
volumes:
90+
- /home/${USER}/validator_keys:/validator_keys
91+
expose:
92+
- 4004
93+
- 8800
94+
command: "bash -c \"\
95+
cp /validator_keys/validator-2.priv /etc/sawtooth/keys/validator.priv; \
96+
cp /validator_keys/validator-2.pub /etc/sawtooth/keys/validator.pub; \
97+
echo $$(cat /etc/sawtooth/keys/validator.pub); \
98+
sawtooth-validator -v \
99+
--endpoint tcp://validator-2:8800 \
100+
--bind component:tcp://eth0:4004 \
101+
--bind network:tcp://eth0:8800 \
102+
--bind consensus:tcp://eth0:5050 \
103+
--peering static \
104+
--peers tcp://validator-1:8800
105+
--scheduler parallel \
106+
--maximum-peer-connectivity 1000 \
107+
\""
108+
stop_signal: SIGKILL
109+
110+
validator-3:
111+
image: "hyperledger/sawtooth-validator:${TAG}"
112+
networks:
113+
raftnetwork:
114+
aliases:
115+
- validator-3
116+
deploy:
117+
mode: replicated
118+
replicas: 1
119+
placement:
120+
constraints: ["node.hostname == ${node3}"]
121+
hostname: validator-3
122+
volumes:
123+
- /home/${USER}/validator_keys:/validator_keys
124+
expose:
125+
- 4004
126+
- 8800
127+
command: "bash -c \"\
128+
cp /validator_keys/validator-3.priv /etc/sawtooth/keys/validator.priv; \
129+
cp /validator_keys/validator-3.pub /etc/sawtooth/keys/validator.pub; \
130+
echo $$(cat /etc/sawtooth/keys/validator.pub); \
131+
sawtooth-validator -v \
132+
--endpoint tcp://validator-3:8800 \
133+
--bind component:tcp://eth0:4004 \
134+
--bind network:tcp://eth0:8800 \
135+
--bind consensus:tcp://eth0:5050 \
136+
--peering static \
137+
--peers tcp://validator-1:8800,tcp://validator-2:8800
138+
--scheduler parallel \
139+
--maximum-peer-connectivity 1000 \
140+
\""
141+
stop_signal: SIGKILL
142+
143+
raft-1:
144+
image: hyperledger/sawtooth-raft-engine:${TAG}
145+
networks:
146+
raftnetwork:
147+
aliases:
148+
- raft-1
149+
deploy:
150+
mode: replicated
151+
replicas: 1
152+
placement:
153+
constraints: ["node.hostname == ${node1}"]
154+
hostname: raft-1
155+
command: raft-engine --connect tcp://validator-1:5050 -vv
156+
stop_signal: SIGKILL
157+
158+
raft-2:
159+
image: hyperledger/sawtooth-raft-engine:${TAG}
160+
networks:
161+
raftnetwork:
162+
aliases:
163+
- raft-2
164+
deploy:
165+
mode: replicated
166+
replicas: 1
167+
placement:
168+
constraints: ["node.hostname == ${node2}"]
169+
hostname: raft-2
170+
command: raft-engine --connect tcp://validator-2:5050 -vv
171+
stop_signal: SIGKILL
172+
173+
raft-3:
174+
image: hyperledger/sawtooth-raft-engine:${TAG}
175+
networks:
176+
raftnetwork:
177+
aliases:
178+
- raft-3
179+
deploy:
180+
mode: replicated
181+
replicas: 1
182+
placement:
183+
constraints: ["node.hostname == ${node3}"]
184+
hostname: raft-3
185+
command: raft-engine --connect tcp://validator-3:5050 -vv
186+
stop_signal: SIGKILL
187+
188+
rest-api-1:
189+
image: "hyperledger/sawtooth-rest-api:${TAG}"
190+
networks:
191+
raftnetwork:
192+
aliases:
193+
- rest-api-1
194+
deploy:
195+
mode: replicated
196+
replicas: 1
197+
placement:
198+
constraints: ["node.hostname == ${node1}"]
199+
hostname: rest-api-1
200+
expose:
201+
- 4004
202+
- 8008
203+
command: sawtooth-rest-api --connect tcp://validator-1:4004 --bind rest-api-1:8008 -v
204+
stop_signal: SIGKILL
205+
206+
rest-api-2:
207+
image: "hyperledger/sawtooth-rest-api:${TAG}"
208+
networks:
209+
raftnetwork:
210+
aliases:
211+
- rest-api-2
212+
deploy:
213+
mode: replicated
214+
replicas: 1
215+
placement:
216+
constraints: ["node.hostname == ${node2}"]
217+
hostname: rest-api-2
218+
expose:
219+
- 4004
220+
- 8008
221+
command: sawtooth-rest-api --connect tcp://validator-2:4004 --bind rest-api-2:8008 -v
222+
stop_signal: SIGKILL
223+
224+
rest-api-3:
225+
image: "hyperledger/sawtooth-rest-api:${TAG}"
226+
networks:
227+
raftnetwork:
228+
aliases:
229+
- rest-api-3
230+
deploy:
231+
mode: replicated
232+
replicas: 1
233+
placement:
234+
constraints: ["node.hostname == ${node3}"]
235+
hostname: rest-api-3
236+
expose:
237+
- 4004
238+
- 8008
239+
command: sawtooth-rest-api --connect tcp://validator-3:4004 --bind rest-api-3:8008 -v
240+
stop_signal: SIGKILL
241+
242+
intkey-tp-1:
243+
image: "hyperledger/sawtooth-intkey-tp-python:${TAG}"
244+
networks:
245+
raftnetwork:
246+
aliases:
247+
- intkey-tp-1
248+
deploy:
249+
mode: replicated
250+
replicas: 1
251+
placement:
252+
constraints: ["node.hostname == ${node1}"]
253+
hostname: intkey-tp-1
254+
expose:
255+
- 4004
256+
command: intkey-tp-python -C tcp://validator-1:4004 -v
257+
stop_signal: SIGKILL
258+
259+
intkey-tp-3:
260+
image: "hyperledger/sawtooth-intkey-tp-python:${TAG}"
261+
networks:
262+
raftnetwork:
263+
aliases:
264+
- intkey-tp-3
265+
deploy:
266+
mode: replicated
267+
replicas: 1
268+
placement:
269+
constraints: ["node.hostname == ${node3}"]
270+
hostname: intkey-tp-3
271+
expose:
272+
- 4004
273+
command: intkey-tp-python -C tcp://validator-3:4004 -v
274+
stop_signal: SIGKILL
275+
276+
intkey-tp-2:
277+
image: "hyperledger/sawtooth-intkey-tp-python:${TAG}"
278+
networks:
279+
raftnetwork:
280+
aliases:
281+
- intkey-tp-2
282+
deploy:
283+
mode: replicated
284+
replicas: 1
285+
placement:
286+
constraints: ["node.hostname == ${node2}"]
287+
hostname: intkey-tp-2
288+
expose:
289+
- 4004
290+
command: intkey-tp-python -C tcp://validator-2:4004 -v
291+
stop_signal: SIGKILL
292+
293+
settings-tp-1:
294+
image: "hyperledger/sawtooth-settings-tp:${TAG}"
295+
networks:
296+
raftnetwork:
297+
aliases:
298+
- settings-tp-1
299+
deploy:
300+
mode: replicated
301+
replicas: 1
302+
placement:
303+
constraints: ["node.hostname == ${node1}"]
304+
hostname: settings-tp-1
305+
expose:
306+
- 4004
307+
command: settings-tp -C tcp://validator-1:4004 -v
308+
stop_signal: SIGKILL
309+
310+
settings-tp-2:
311+
image: "hyperledger/sawtooth-settings-tp:${TAG}"
312+
networks:
313+
raftnetwork:
314+
aliases:
315+
- settings-tp-2
316+
deploy:
317+
mode: replicated
318+
replicas: 1
319+
placement:
320+
constraints: ["node.hostname == ${node2}"]
321+
hostname: settings-tp-2
322+
expose:
323+
- 4004
324+
command: settings-tp -C tcp://validator-2:4004 -v
325+
stop_signal: SIGKILL
326+
327+
settings-tp-3:
328+
image: "hyperledger/sawtooth-settings-tp:${TAG}"
329+
networks:
330+
raftnetwork:
331+
aliases:
332+
- settings-tp-3
333+
deploy:
334+
mode: replicated
335+
replicas: 1
336+
placement:
337+
constraints: ["node.hostname == ${node3}"]
338+
hostname: settings-tp-3
339+
expose:
340+
- 4004
341+
command: settings-tp -C tcp://validator-3:4004 -v
342+
stop_signal: SIGKILL
343+
344+
shell:
345+
image: hyperledger/sawtooth-all:latest
346+
networks:
347+
raftnetwork:
348+
aliases:
349+
- shell
350+
deploy:
351+
mode: replicated
352+
replicas: 1
353+
placement:
354+
constraints: ["node.hostname == ${node1}"]
355+
hostname: shell
356+
depends_on:
357+
- rest-api-1
358+
- rest-api-2
359+
- rest-api-3
360+
entrypoint: "bash -c \"\
361+
tail -f /dev/null \
362+
\""

0 commit comments

Comments
 (0)