Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to configure CouchDB for the Peer node of Fabric in HyperLedger

Shulou Source: shulou.com Published: 2022-06-01 17:04:14 10月04日 Update

Editor to share with you how to configure CouchDB for Fabric's Peer node in HyperLedger. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

Description

The Peer data storage of the current (1.1-1.2) version of Fabric supports both LevelDB and CouchDB, and the default is LevelDB.

LevelDB is an efficient kv database implemented by Google, which can be applied to many platforms and is the underlying storage scheme of many big data systems.

CouchDB is a document database under Apache, which provides a variety of data operations and supports data synchronization. For technical details, please see CouchDB Technical Overview.

Document database is relative to relational data. Document database can store and fetch text containing a variety of information directly. Compared with relational database with pre-designed table structure, document database can cope with changing and diverse data.

Fabric's Peer stores json data in CouchDB, and all data written to Fabric needs to be converted to json format.

Switching between CouchDB and LevelDB is not supported after Fabric deployment!

CouchDB deployment startup

Installation on Unix-like systems provides a variety of ways to install on a variety of systems, the CentOS system used here.

Create the file / etc/yum.repos.d/bintray-apache-couchdb-rpm.repo with the following contents:

[bintray--apache-couchdb-rpm] name=bintray--apache-couchdb-rpmbaseurl= http://apache.bintray.com/couchdb-rpm/el7/$basearch/gpgcheck=0repo_gpgcheck=0enabled=1

Installation:

Yum-y install epel-release & & yum install couchdb

Installed by default in the / opt/couchdb/ directory:

$ls / opt/couchdb/LICENSE bin data erts-8.3.5 etc lib releases share var

Start:

Systemctl start couchdb

Default listens to 127.0.0.1purl 5984:

$curl 127.0.0.1 version 5984 {"couchdb": "Welcome", "version": "2.1.2", "features": ["scheduler"], "vendor": {"name": "The Apache Software Foundation"} CouchDB configuration and console use

The configuration file is located in the / opt/couchdb/etc/ directory:

$ls etc/default.d/ default.ini local.d/ local.ini vm.args

Default.d and default.ini are overwritten when the version is updated, so the self-configured parameters are modified in local.ini and local.d.

Create a file ending in .ini in local.d, couchdb.ini:

[chttpd] port = 5984bind_address = 0.0.0.0 [admins] admin = password

Then restart couchdb:

Systemctl restart couchdb

Port 5984 provides a web console, which is accessed using the following url:

Http://192.168.88.10:5984/_utils

If no couchdb.ini is created, the default configuration is used. At startup, everyone can access it by default, and they are all administrators.

You can set the administrator name and password in the web console.

Other contents of CouchDB

You can create databases and documents directly in the web console, or you can use CouchDB API

Login authentication: CouchDB Authentication

Configure CouchDB for each Peer

Modify the core.yaml file for each Peer and set the

Ledger: blockchain: state: stateDatabase: CouchDB # modify goleveldb to CouchDB couchDBConfig: couchDBAddress: 127.0.0.1 state 5984 username: admin password: password

Then restart and start Peer.

Note: if you previously used goleveldb, after switching to non-CouchDB, the previous data will not be transferred to CouchDB!

CouchDB in first-network

You can take a look at couchdb in the All-in-One deployment provided by HyperLedgerFabric, where Fabric1.2.0 is used directly.

Create a directory for 1.2.0 files:

Mkdir fabric-1.2.0-examplecd fabric-1.2.0-example/

Download the program file of fabric1.2.0, the mac version used here:

Wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/darwin-amd64-1.2.0/hyperledger-fabric-darwin-amd64-1.2.0.tar.gzwget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/darwin-amd64-1.2.0/hyperledger-fabric-darwin-amd64-1.2.0.tar.gz.md5tar-xvf hyperledger-fabric-darwin-amd64-1.2.0.tar.gz

Download the Fabric1.2.0 matching image:

. / bin/get-docker-images.sh

If the download fails, for example:

. / bin/get-docker-images.shPulling hyperledger/fabric-peer:amd64-1.2.0-stable

This is because there is no 1.2.0-stable tag on docker hub.

Modify. / bin/get-docker-images.sh:

ARCH=amd64#VERSION=1.2.0-stableVERSION=1.2.0

Tags: Data configuration database file document content console directory control node mode time article system storage support multiple container more tag Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei Microsoft vpn Apple