Migration from Kafka to RAFT in Hyperledegr Fabric 1.4.3

Pavan Adhav
Coinmonks
10 min readDec 9, 2019

--

Download the fabric sample for here. Please visit the [installation instructions](link) to ensure you have the correct prerequisites installed.

Download the latest binaries and Docker images with 1.4.3. All installation instructions will utilize `scripts/bootstrap.sh`
If you did not find any script/bootstrap.sh` file,
# Fetch bootstrap.sh from fabric repository using the following command

curl -sS https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh -o ./scripts/bootstrap.sh

# Change file mode to executable
chmod +x ./scripts/bootstrap.sh

Execute the following command from a fabric sample directory.

./scripts/bootstrap.sh

Default it will download the latest binaries and latest docker images if you want to download specific, execute the following command by giving specific version

./scripts/bootstrap.sh [version] [ca version] [thirdparty_version].

You can see all binaries are downloaded /bin folder.

Go to the first-network folder cd first-network

Before creating certificates please make the following changes in crypto-config.yaml the the file, comment the EnableNodeOUs: true and add CA as shown below(bold). For version 1.4.3, cryptogen tool is generating Node Organization unit (OU) as a client for orderer, For peer, it's creating correct as expected(Node ou as Admin).

Discover and review best Blockchain softwares

Generate the certificate using the following command(default it uses cryptogen tool)

./byfn generate -o kafka

The next step is up the network using the following command. Here we are using state database as couch DB and ordering service node using Kafka zookeeper.

./byfn.sh up -o kafka -s couchdb

Once the network is up, you will be able to see the following success message.

You could see all containers are running by execauting command

`docker ps ` or docker container list

For any kind of configuration block change, we follow the same steps as below.

We need to follow following three steps for migration Kafka to RAFT

.1) Switch on Maintenance Mode
2) Change Consensus type to etcdraft
3) Switch Off Maintenance mode

STEP1

Switch ON Maintenace mode
Login to cli container

If we’re upgrading from v1.3 to v1.4.3, we need to set the system channel name to testchainid:

If we’re upgrading from v1.4.1 to v1.4.3, we need to set the system channel name to byfn-sys-channel:

Note: Make sure that you are using the system channel name correctly

Execute the following commands for mychannel

Expected output:

Do the same procedure for the system channel as well.

Expected output

Restart all necessary container by running following command

STEP 2
Change consensus type in configuration block

Login to cli container

docker exec -it cli bash

execute following commands

Open Config_mod.json do the following update in this file. The file should be available in location workdir/switch_to_raft_mychannel

Replace the following block in config_mod.json file

The client_tls_cert and server_tls_cert fields are actually equal and should contain the base64-encoded orderer service certificate. You can obtain this value by executing the following command in the CLI container we’ve already opened.

Expected Output

Do the same above step for system channel

Open Config_mod.json do the following update in this file. File should be available in location workdir/switch_to_raft_byfn-sys-channel

Replace the following block in config_mod.json file

The client_tls_cert and server_tls_cert fields are actually equal and should contain the base64-encoded orderer service certificate. You can obtain this value by executing the following command in the CLI container we’ve already opened.

Execute following on CLI

Expected Output

Exit CLI and restart all related to the fabric

after 20 sec, check orderer log it should show like below

you can search with “etcdraft migration detected”, you will be able to see logs of raft ordering service.

STEP 3
Switch OFF maintenance Mode

Now we have updated the necessary configuration, we need to disable the MAINTENANCE mode to NORMAL mode for both channel(mychannel and sys-channel)

Login to CLIcontainer

Run the following code in CLI

Repeat the same for sys-channel

Exit the CLI container and restart all containers with the following command

For checking data persistence and invoking login into

Invoke and query chaincode with following commands

Get Best Software Deals Directly In Your Inbox

--

--