How to set database on Hyperledger Fabric?

I think fabric had two parts to persist data:
1.storing transaction data on ledger as blockfiles .
i can set as the follow
sbt “run --port 6865 --role provision,time,ledger” -J-DfabricConfigFile=config-local.yaml
2.storing contract template and index in leveldb(like postgresql ,couchdb) .
while how to set the leveldb in daml ?
and all of my mind is right ?

Hi Hui Xin (apologies in advance on any misspellings of your name)

In terms of databases involved in the DAML on Fabric setup, there are two of concern

  1. The database used as the Fabric key/value store
  2. the database used as the DAML-specific index database.

For #1 the default Fabric key value store is LevelDB and that is what is used in the default daml-on-fabric setup. We have opted for this as we have found it to be more performant than CouchDB. If you want to use CouchDB instead the instructions on how to do this are documented in the more detailed in the src/test/fixture directory daml-on-fabric/ at 98dcdd98570180c00ee98615c0556c7276515f6f · digital-asset/daml-on-fabric · GitHub

For #2 the default local indexDB used for CI and in the default configuration is in-memory H2 – this can be switched to be a persistent Postgres instance by changing the jdbcUrl connection string passed at startup

Default (H2 in memory)

To use Postgres instead

where PG_HOST is your Postgres database hostname, PG_PORT is the port of the database and PG_DATABASE is the database name.

jdbcUrl can be passed as a parameter as part of the set run command so something like

sbt “run --port 6865 --role provision,time,ledger --jdbcUrl=jdbc:postgresql://{PG_HOST}:{PG_PORT}/${PG_DATABASE}” -J-DfabricConfigFile=config-local.yaml

Hope this helps