Switching Hyperledger Fabric peers from LevelDB to CouchDB

Fabric peers cannot convert their state database in place, so moving from LevelDB to CouchDB means standing up replacement peers and cutting clients over. This page explains the work, the sequence and what drives effort.

On this page

Why switching Hyperledger Fabric peers from LevelDB to CouchDB means replacing them

The state database on a Fabric peer cannot be converted in place from LevelDB to CouchDB. Because of data incompatibilities between the two, the database choice must be finalized before a production peer is deployed, and the choice cannot be changed afterward. Moving to CouchDB for rich JSON queries therefore means standing up new peers configured with CouchDB, not reconfiguring the existing ones. The state database is selected with the ledger.state.stateDatabase parameter in the peer configuration, with LevelDB as the default, so the first decision is confirming which peers will be replaced and which will remain on LevelDB. The CouchDB as the state database documentation is the reference for the constraints that apply.

Plan the move as a parallel run and cutover. New CouchDB peers join the affected channels alongside the LevelDB peers, catch up on the ledger, and are validated against the same transactions before client applications and audit reporting are pointed at them. Cutover then retires the LevelDB peers once nothing depends on them. Confirm with your own team which applications, scheduled reports and endorsement policies reference specific peers, because those references must be updated during cutover. Confirm also that the new peers have the storage, memory and network capacity that the CouchDB instances need, and that the operations and backup procedures cover the CouchDB data as well as the ledger.

Effort depends on several factors that you should size before asking for a quote: the size of the existing ledgers on each channel, the number of channels that the peers serve, how many JSON queries and indexes the audit and reporting requirements need, and how many client applications depend on the peers being replaced. Using CouchDB can support auditing and reporting needs that LevelDB does not, through JSON queries and indexes, so the query and index design should be settled early because it determines how the new peers are configured and tested. Ask any implementation partner to break the work into peer build, channel join and catch-up, application repointing, validation and cutover, each with its own written acceptance criteria.

What carries over from LevelDB and what needs rebuilding on CouchDB

This table compares how the peer state database behaves under LevelDB and CouchDB, from data model and query support to configuration and operations. Read it to see what your chaincode, indexes and operational runbooks must change, and what cannot move at all. The main takeaway is that the ledger does not convert between the two databases, so the choice has to be settled before a production peer is deployed.

AreaLevelDB (default)CouchDB
Data modelKey-value state stored in the default embedded databaseJSON documents stored per key, so chaincode can read document fields
Ledger data on conversionNot convertible to or from CouchDB; the state database choice is fixedNot convertible to or from LevelDB; the state database choice is fixed
How chaincode reads stateGet by key and range queries on keysGet by key and range queries, plus rich JSON queries on document fields
Query capabilityNo JSON queries; auditing and reporting must work from keys or external dataJSON queries support auditing and reporting needs that key lookups cannot meet
IndexesNo JSON query indexesIndexes packaged with chaincode to support JSON queries; they must be designed and tested
Peer configurationDefault when ledger.state.stateDatabase is not changedSelected with ledger.state.stateDatabase in the peer configuration, set before the production peer is deployed
Replacement peersRebuilt peers must use the same database type as the channel's existing peersRebuilt peers must use CouchDB; check the channel configuration before adding a peer
Backups and monitoringBack up the peer ledger and confirm restore steps for the file-based storeBack up CouchDB alongside the peer ledger and add CouchDB health and resource monitoring; confirm details in the CouchDB section of the Fabric docs

Why the state database cannot be converted in place

A peer's state database cannot be switched from LevelDB to CouchDB on a live peer, because the two engines store and index world state in incompatible ways. LevelDB is a key-value store, so the peer reads state by key. CouchDB stores each value as a JSON document and builds indexes over its fields, which is what makes rich queries possible. The data written by one engine cannot be read by the other, so there is no in-place conversion step to plan for. The choice is effectively permanent for that peer's ledger.

The database is selected with the ledger.state.stateDatabase key in the peer's core.yaml, and LevelDB is the default. Because the choice is locked in before the peer holds production data, it must be made during peer planning, not after go-live. If a team later needs JSON queries for auditing or reporting, the practical answer is a new peer configured with CouchDB, joined to the channel and synchronized from the ledger, with the old peer retired or kept for its existing role. Plan the replacement, including its identity, endpoints and any client routing that points at the old peer, before the cutover date is set.

Before deciding to keep one database type per channel, confirm with the Fabric documentation how peers with different state databases are handled within the same channel, and whether any behavior differs for private data or chaincode queries. Ask your Fabric platform team to document which peers in each channel run which database, and make that inventory part of your change records. Treat the answer as a design requirement, not an assumption, because it determines whether a mixed estate is supportable at all.

Documented paths for moving state onto replacement peers

The Fabric docs give no in-place route from LevelDB to CouchDB, so the practical path is a replacement peer configured for CouchDB from the start. The cards below cover the documented settings, the planning and upgrade guidance behind that choice, and the points you must confirm before any data moves.

State database selection parameter

The ledger.state.stateDatabase key in the peer configuration selects the state database, and LevelDB is the default. Setting this value is the first decision on a replacement peer, and it must match the database type you plan for every channel that peer joins. Check the value in the peer's core configuration before the peer receives any blocks, and record it in your deployment templates so a rebuilt peer cannot silently fall back to the default.

Peer planning docs

CouchDB state database guidance

The CouchDB guidance explains why the choice cannot be converted later: data incompatibilities between LevelDB and CouchDB mean the database type must be settled before a production peer is deployed. It also describes the JSON query and index support that makes CouchDB suitable for auditing and reporting queries. Read this page to confirm the indexes your reporting needs will require, and to plan how those indexes ship with your chaincode.

CouchDB docs

Production peer planning

The production peer planning guidance is where the state database choice belongs alongside decisions about peer resources, storage and deployment layout. Treat the database type as part of the peer's identity, not a tuning option. When you plan replacement peers, confirm the storage and resource needs of CouchDB against your current peers, since a peer that is sized only for LevelDB may not carry the same load once the query workload starts.

Back up ledger and MSPs first

The upgrade guide advises backing up the ledger and MSPs before making changes to components. Apply the same discipline before retiring any LevelDB peer, and keep the backup until the replacement peer has caught up and its ledger has been verified against the original. Confirm with your operations team where backups are stored and who can restore them, because the MSP material on a peer is as important to recover as the ledger itself.

Upgrade guide

Confirm no in-place converter

The supplied documentation does not describe an in-place converter that turns a LevelDB state database into CouchDB. Before you plan any cutover, confirm this with the current Fabric docs for your release line. Any approach that copies or snapshots ledger data to a new peer must be checked against those docs and tested in a non-production environment before anyone uses it on a production channel.

How replacement CouchDB peers run beside the LevelDB peers

The flow starts with confirming that rich JSON queries are needed and deciding the state database before any production peer is deployed. Replacement peers are configured with the ledger.state.stateDatabase setting, joined to the channel, and validated for queries and indexes while LevelDB peers keep serving clients. Client applications move to the new peers only after that validation, and the LevelDB peers are retired last. The key check is that each channel keeps one database type across its peers.

Replacement CouchDB peers join the channel and are validated beside the LevelDB peers before cutover.

Sequence from inventory to decommission with a parallel run

This sequence moves query-dependent workloads from LevelDB peers to CouchDB peers without losing ledger data or interrupting clients, and it keeps a tested rollback path until the new peers have carried real traffic.

  1. Inventory channels, peers, chaincodes and queries

    The network operator and the application owners list every channel that needs rich JSON queries, the peers that host its ledger, the chaincodes that will run CouchDB-backed queries, and each client query that depends on them. Chaincode owners flag any function that uses selectors, indexes or range-and-filter logic that LevelDB cannot serve. This step is complete when each channel has a named owner, a peer list and a written set of queries, and the team has confirmed which channels can stay on LevelDB. Do not start until the target channels and their membership are confirmed in the current channel configuration.

  2. Confirm the state database decision for production

    The governance group and the network architect confirm in writing that CouchDB is the state database for the new peers. Because the choice must be finalized before a production peer is deployed and cannot be converted later, this sign-off is a gate. Record the decision with the channel list, the peer organizations affected and the reason, and confirm that no existing peer in the target scope is a candidate for in-place conversion. The step is done when the decision record is approved by every organization that operates a peer on those channels.

  3. Back up ledgers and MSP material

    Each peer operator takes a backup of the existing peer ledger and the MSP and TLS material for the peers that will be retired, and stores it outside the peer's host. Ask the team to confirm the backup restores on a separate host before anyone relies on it. This step must finish before any new peer joins a channel, because the LevelDB peers remain the rollback path. It is complete when each backup has a checksum, a recorded location and a tested restore on a non-production host.

  4. Deploy CouchDB peers and join channels

    Operators deploy new peers configured with the CouchDB state database through the ledger.state.stateDatabase setting, rather than the LevelDB default, and attach them to the same organization's MSP. Each new peer joins the target channels and receives blocks from the ordering service. The check is that each new peer reports the expected channel membership, has caught up to the current block height, and has the chaincode definitions installed. Confirm the CouchDB instances are reachable from each peer and secured with the access controls your organization requires before any join.

  5. Design and test indexes against representative data

    Chaincode owners package JSON indexes with the chaincode and test each rich query against a copy of ledger data that matches production volume and shape. Testing confirms that each query uses an index, that results match what the client expects, and that response times are acceptable to the application owners. Record which queries lack an index and decide whether to add one or change the query. The step is complete when every query on the inventory has a passing test against representative data and the index files are in source control.

  6. Run both peer sets in parallel

    Both the LevelDB peers and the CouchDB peers serve the same channel for a period agreed by the operators and application owners. Clients can be pointed at either set, and the team compares query results, endorsement behavior and block heights between them. Watch for divergence in chaincode responses, lagging peers and CouchDB resource pressure. The parallel run is complete when the team has signed off on result parity and on operational stability, and the rollback path has been exercised at least once on a non-production copy.

  7. Cut over clients to CouchDB peers

    Application owners move client traffic, including the queries that depend on JSON indexes, to the CouchDB peers through their connection configuration. Keep the LevelDB peers online and joined to the channel, so that the rollback is a configuration change and not a restore. Confirm each application reconnects, that event listeners resume, and that the queries that previously failed now return results. The step is done when all client applications on the channel run against the CouchDB peers and the monitoring dashboards show normal endorsement and query activity.

  8. Retain rollback window, then decommission LevelDB peers

    Keep the LevelDB peers in place through an agreed rollback window while the CouchDB peers carry live traffic. The governance group sets the window length, and the operators confirm it in writing before cutover begins. Once the window closes with no rollback needed, remove the LevelDB peers from the channels, revoke or retire their identities through the certificate process, and archive their backups under the retention policy. The step closes when the decommission record lists each peer, the removal date, the archive location and the owner who approved it.

Which path fits: new peers on existing channels or a new channel

When a channel is already live on LevelDB, the state database cannot be converted in place. The Fabric docs state that the database choice must be finalized before a production peer is deployed and cannot be converted later, so moving to CouchDB means standing up replacement peers that use ledger.state.stateDatabase set to CouchDB and letting them rebuild their state from the channel's ledger. Existing peers keep running LevelDB until they are retired.

  • Member impact: Each organization that wants rich queries must deploy new peers, join them to the channel, and move its applications to those peers. Old LevelDB peers remain members until removed.
  • Mixed state databases: During the transition, one channel can hold peers using different state databases. Confirm with the Fabric docs and your own test network how this mixed state appears to chaincode queries and to clients.
  • Replacement peer identity: New peers need MSP identities and TLS material from your existing CA setup. Confirm the enrollment steps before the cutover date.
  • Decisions first: Decide which organizations need CouchDB, who owns the replacement peers, and when the old peers are decommissioned.

Confirm the exact join and rebuild sequence for your Fabric version in the peer planning documentation before scheduling the change.

What drives the effort and cost of a peer replacement

This table lists the drivers that change how much work a LevelDB to CouchDB peer replacement takes and which items to request in a quote. Read each row as a question to answer about your own network before asking for a fixed-scope proposal. The main takeaway is that design work on queries and indexes is one-time, while CouchDB operation and index upkeep recur for as long as the peers run.

DriverWhy it mattersWhat to ask for in a quote
Ledger size and growthReplacement peers must rebuild state from blocks or a snapshot, so larger ledgers lengthen sync and cutover windows. Growth rate sets the storage plan for CouchDB.Current ledger size per channel, expected growth, the rebuild method (block replay or snapshot), and the storage sizing assumed for CouchDB.
Number of channels and chaincodesEach channel carries its own state database, and each chaincode's data must be checked for JSON fit and query needs. Every channel is a separate cutover decision.Channel and chaincode inventory, which channels need rich queries, and whether any channel stays on LevelDB.
Rich queries and indexesIndex design and query tuning are one-time design work. Each index adds write cost and needs review when chaincode data shapes change.Count of queries to support, index definitions to write and test, and a plan for index review after chaincode upgrades.
Client applications and query codeApplications that call rich queries must handle paging, bookmarks and query limits. Code written for LevelDB range queries may need rework.Number of client applications touched, the query code changes expected, and the test coverage planned for each.
Organizations replacing peersEach member organization replaces its own peers on its own schedule, so coordination across the consortium drives the calendar more than the technical work.Number of organizations, agreed cutover order, and who communicates the state database change to each member.
Testing and parallel-run scopeQueries must return the same results on CouchDB as on the existing peers before cutover. Test scope grows with channels, queries and data volume.Test environments, data sets used, comparison method for query results, and the length of the parallel run the provider plans.
HSM or custom image needs for MSP keysIf MSP keys sit in an HSM, the peer image must be built with PKCS#11 support because the prebuilt Docker images are not built with it. TLS keys stay file-based.Whether a custom image is needed, who builds and maintains it, and how HSM access is retested on the new peers.
Monitoring and backup changesCouchDB adds a service to monitor and back up. Operations runbooks, the peer operations endpoints and backup jobs must cover it.Updated monitoring and backup scope, runbook changes, and recurring operating tasks the provider will hand over.
One-time versus recurring workDesign, build, testing and cutover are one-time. Operating CouchDB peers, reviewing indexes and patching the database recur for the life of the network.A split of one-time and recurring items, the support model after cutover, and whether ongoing operations are a separate retainer.

What usually goes wrong in a LevelDB to CouchDB switch and how to prevent it

Most problems in this switch come from timing and assumptions: teams expect the state database to be converted, choose it after go-live, or skip testing the queries their applications depend on. Each card below names one of these risks and the check that prevents it before peers change.

Assuming the ledger converts in place

Teams often assume an existing LevelDB peer can be switched to CouchDB like a configuration toggle. The state database cannot be converted later because of data incompatibilities between the two, so the choice must be final before a production peer is deployed. Confirm the path with your Fabric vendor or operator before planning any cutover, and plan for replacement peers that rebuild state on the new database.

CouchDB docs

Deciding the database type after go-live

A database choice made once production traffic is flowing forces either a rebuild onto new peers or an extended period of running two peer types. Set the value of ledger.state.stateDatabase during design, not during an incident. Record the decision, who approved it and the query requirements behind it, so the reason survives staff changes.

Indexes missing for real queries

CouchDB supports JSON queries and indexes that help with auditing and reporting, but only if the indexes match the queries clients run. Missing or poorly designed indexes produce slow or heavy queries on the peers. Collect the actual query patterns from application owners and auditors, then build and test indexes against a realistic data volume before go-live.

Mixing database types on one channel

Running peers with different state databases on the same channel is a design decision that needs checking against the Fabric documentation, not an assumption. Before any peer on a channel changes, confirm which database types the channel's peers may use and document the rule. Treat the choice as a channel-level standard that new peers must follow.

Client applications not tested on new peers

Applications that depend on rich queries, or that were built around LevelDB behavior, may fail or return different results on CouchDB peers. Test each client against CouchDB peers in a staging network, including queries, pagination and error handling. Check that the client library version in use supports the network version in place, since the Fabric Gateway client API is compatible with both v2.5 and v3.0.

Upgrade docs

No backup or rollback window

Removing LevelDB peers before the CouchDB peers have run correctly removes the fallback path. Back up the ledger and MSP material before any change, and keep the LevelDB peers running until the new peers have served all production queries for an agreed period. Write down the rollback steps and who can execute them, and rehearse them in a non-production environment.

How much does a LevelDB to CouchDB switch cost and how long does it take?

What does a LevelDB to CouchDB switch cost?

No price is published here, and the cost depends on the written scope, which is the basis for any quote. The main cost components are planning and inventory work, building replacement peers on CouchDB, moving or rebuilding ledger state, validating query results, and handing the work to your operators. Who pays for what should be spelled out in the quote: which steps your team performs, which DeployOpen performs, and whether any CouchDB hosting or peer capacity is provided by you. Ask the quote to separate one-time work from recurring items such as monitoring, patching and retainer support, if you want them.

What drives the cost of moving peers to CouchDB?

The main drivers are the number of peers and channels that need replacement, the number of chaincodes and rich queries that depend on CouchDB, the number of index definitions to write and test, and how many organizations must coordinate their change windows. Environment complexity also matters: how peers are deployed (Kubernetes or virtual machines), how CouchDB is hosted and secured, and how much existing data must be validated after the switch. Ask for the scope to list each of these counts so the quote can be compared line by line.

How long does the switch take, and why is no duration given here?

No duration is given here because the timeline depends on the channel count, the peer count, the number of organizations involved and the agreed change windows, none of which are known in advance. A single-channel test network and a multi-organization production network differ widely in effort. The written scope and quote set the schedule, including the planning, build, validation and cutover phases. Ask for milestones and the dependencies that could move them, such as approvals from other organizations or capacity for CouchDB hosts.

What must our team provide before the engagement starts?

Your team should provide a channel and chaincode inventory, including which chaincodes need rich queries and which already run on LevelDB. Prepare the list of queries and indexes the business needs, the change windows agreed with each member organization, and access to the peers and CouchDB hosts, including the environment details needed to deploy and test. Also name the people who can approve configuration changes on each channel. Missing inputs usually become the largest source of schedule slippage, so confirm them in the written scope.

Can an internal team switch peers to CouchDB on its own?

An internal team with Fabric operations experience can perform the switch, provided it has enough time, access and review capacity. The work includes creating replacement peers with the CouchDB state database, managing channel membership and chaincode behavior, testing queries and indexes, and coordinating with other organizations. Teams that have not run Fabric in production often underestimate the coordination and validation effort. Ask a partner to show how the work splits between your team and theirs, and decide based on the skills and staff time you have available.

Can the switch be done without downtime?

Whether the switch causes downtime depends on the network design, channel membership and how transactions are routed during cutover. A common approach is to bring up replacement peers on CouchDB alongside existing peers, validate them, then move client traffic, but the exact sequence must be confirmed for your network. Peers cannot be converted in place, so the replacement path is the central question. Ask for the cutover plan and rollback steps in the written scope before agreeing to a window.

What does a fixed-scope engagement cover?

A fixed-scope engagement covers the work, deliverables and timeline agreed in writing before work starts. For this switch, that typically means the inventory and design, replacement peer builds, the CouchDB configuration and index definitions, validation of query results, cutover support and handover documentation. It should also state what is excluded, such as application rewrites or CouchDB hosting. Ongoing support, upgrades and continuous testing are available as retainers and are priced separately from the initial scope.

How DeployOpen scopes and runs a Fabric CouchDB peer migration

DeployOpen treats the move from LevelDB to CouchDB as a planned change to peer identity and ledger state, not a configuration toggle. The work is scoped in writing, built on replacement peers inside your own infrastructure, and handed over with runbooks your team can operate.

How we scope

  • Confirm which channels need JSON queries and which reporting or audit questions the CouchDB indexes must answer
  • Inventory existing peers, their ledger state and the chaincode that reads or writes state on each channel
  • Agree in writing whether the peers are replaced, rebuilt or added alongside the current set, with the cutover sequence
  • Record which CouchDB version, hosting model and storage your organization approves before any build starts

How we build

  • Deploy replacement peers configured with ledger.state.stateDatabase set to CouchDB before they join any channel
  • Create and test the CouchDB indexes that chaincode queries depend on, using representative data from a non-production channel
  • Confirm the peer operations service health checks, logging and Prometheus metrics are wired into your monitoring before cutover
  • Verify that every channel on the migrated peers uses one database type, and that no LevelDB peer remains in the same channel's membership

How we hand over

  • Deliver a written record of the scope, peer inventory, configuration values and index definitions used in the build
  • Provide a cutover runbook covering join order, ledger catch-up checks, rollback points and decommissioning of retired peers
  • Document the query test cases and results so your team and auditors can repeat them on later changes
  • Walk your operators through routine CouchDB backups, index maintenance and what to check after a peer restart

How we support

  • Support after handover can be provided through a retainer covering patching, upgrades and continued testing
  • Retainer scope, response expectations and any upgrade work are agreed in writing before they start
  • Revisit indexes and query tests when chaincode or reporting requirements change on a live channel
  • Ask us to confirm the scope of any follow-on work against your current Fabric release line before it begins

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.