fabric-docs-i18n icon indicating copy to clipboard operation
fabric-docs-i18n copied to clipboard

[ja_JP] Architecture Reference / CouchDB as the State Database

Open shimos opened this issue 2 years ago • 0 comments

Original HTML: https://hyperledger-fabric.readthedocs.io/en/release-2.5/couchdb_as_state_database.html Original Source: https://github.com/hyperledger/fabric/blob/e1e8e2e52aa4fc543360d245fe6554a0eaf81183/docs/source/couchdb_as_state_database.rst

diff --git a/docs/source/couchdb_as_state_database.rst b/docs/source/couchdb_as_state_database.rst
index 5375df47b..c0b047d7a 100644
--- a/docs/source/couchdb_as_state_database.rst
+++ b/docs/source/couchdb_as_state_database.rst
@@ -67,9 +67,9 @@ can be utilized with either LevelDB or CouchDB state database, e.g. ``GetState``
 ``GetStateByRange``, ``GetStateByPartialCompositeKey``. Additionally when you utilize CouchDB as
 the state database and model assets as JSON in chaincode, you can perform JSON queries against
 the data in the state database by using the ``GetQueryResult`` API and passing a CouchDB query string.
-The query string follows the `CouchDB JSON query syntax <http://docs.couchdb.org/en/2.1.1/api/database/find.html>`__.
+The query string follows the `CouchDB JSON query syntax <http://docs.couchdb.org/en/stable/api/database/find.html>`__.
 
-The `asset transfer Fabric sample <https://github.com/hyperledger/fabric-samples/blob/master/asset-transfer-ledger-queries/chaincode-go/asset_transfer_ledger_chaincode.go>`__
+The `asset transfer Fabric sample <https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-ledger-queries/chaincode-go/asset_transfer_ledger_chaincode.go>`__
 demonstrates use of CouchDB queries from chaincode. It includes a ``queryAssetsByOwner()`` function
 that demonstrates parameterized queries by passing an owner id into chaincode. It then queries the
 state data for JSON documents matching the docType of "asset" and the owner id using the JSON query
@@ -132,7 +132,7 @@ any JSON query with a sort. Indexes enable you to query data from chaincode when
 a large amount of data on your ledger. Indexes can be packaged alongside chaincode
 in a ``/META-INF/statedb/couchdb/indexes`` directory. Each index must be defined in
 its own text file with extension ``*.json`` with the index definition formatted in JSON
-following the `CouchDB index JSON syntax <http://docs.couchdb.org/en/3.1.1/api/database/find.html#db-index>`__.
+following the `CouchDB index JSON syntax <http://docs.couchdb.org/en/stable/api/database/find.html#db-index>`__.
 For example, to support the above marble query, a sample index on the ``docType`` and ``owner``
 fields is provided:
 
@@ -140,7 +140,7 @@ fields is provided:
 
   {"index":{"fields":["docType","owner"]},"ddoc":"indexOwnerDoc", "name":"indexOwner","type":"json"}
 
-The sample index can be found `here <https://github.com/hyperledger/fabric-samples/blob/master/asset-transfer-ledger-queries/chaincode-go/META-INF/statedb/couchdb/indexes/indexOwner.json>`__.
+The sample index can be found `here <https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-ledger-queries/chaincode-go/META-INF/statedb/couchdb/indexes/indexOwner.json>`__.
 
 Any index in the chaincode’s ``META-INF/statedb/couchdb/indexes`` directory
 will be packaged up with the chaincode for deployment. The index will be deployed
@@ -171,6 +171,9 @@ indexes may not get created. If this occurs, you need to reinstall the chaincode
 CouchDB Configuration
 ---------------------
 
+Peer configuration for CouchDB
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 CouchDB is enabled as the state database by changing the ``stateDatabase`` configuration option from
 goleveldb to CouchDB. Additionally, the ``couchDBAddress`` needs to configured to point to the
 CouchDB to be used by the peer. The username and password properties should be populated with
@@ -218,39 +221,30 @@ Below is the ``stateDatabase`` section from *core.yaml*:
          internalQueryLimit: 1000
          # Limit on the number of records per CouchDB bulk update batch
          maxBatchUpdateSize: 1000
-         # Warm indexes after every N blocks.
-         # This option warms any indexes that have been
-         # deployed to CouchDB after every N blocks.
-         # A value of 1 will warm indexes after every block commit,
-         # to ensure fast selector queries.
-         # Increasing the value may improve write efficiency of peer and CouchDB,
-         # but may degrade query response time.
-         warmIndexesAfterNBlocks: 1
-
-CouchDB hosted in docker containers supplied with Hyperledger Fabric have the
-capability of setting the CouchDB username and password with environment
-variables passed in with the ``COUCHDB_USER`` and ``COUCHDB_PASSWORD`` environment
-variables using Docker Compose scripting.
-
-For CouchDB installations outside of the docker images supplied with Fabric,
-the
-`local.ini file of that installation
-<http://docs.couchdb.org/en/3.1.1/config/intro.html#configuration-files>`__
-must be edited to set the admin username and password.
-
-Docker compose scripts only set the username and password at the creation of
-the container. The *local.ini* file must be edited if the username or password
-is to be changed after creation of the container.
-
-If you choose to map the fabric-couchdb container port to a host port, make sure you
-are aware of the security implications. Mapping the CouchDB container port in a
-development environment exposes the CouchDB REST API and allows you to visualize
-the database via the CouchDB web interface (Fauxton). In a production environment
-you should refrain from mapping the host port to restrict access to the CouchDB
-container. Only the peer will be able to access the CouchDB container.
 
 .. note:: CouchDB peer options are read on each peer startup.
 
+CouchDB container configuration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Although full CouchDB configuration is beyond the scope of this document, some common considerations are provided in this section.
+
+If using Docker compose, the environment variables ``COUCHDB_USER`` and ``COUCHDB_PASSWORD``
+can be used to set the CouchDB user and password when the CouchDB container gets created.
+
+Alternatively, set the CouchDB user and password in the CouchDB
+`local.ini configuration file <http://docs.couchdb.org/en/stable/config/intro.html#configuration-files>`__.
+
+To change the CouchDB user and password after CouchDB container creation, the ``local.ini`` configuration approach must be used.
+
+As of CouchDB 3.0.0 ``max_document_size`` defaults to ``8000000`` (8MB).
+``max_document_size`` can be set as high as ``4294967296`` (4GB) if you need to store large JSON documents to the state database.
+For more details see the CouchDB `max_document_size documentation <https://docs.couchdb.org/en/stable/config/couchdb.html#couchdb/max_document_size>`__.
+
+In a production environment the CouchDB container port should only be exposed to the relevant peer.
+In a development environment you may expose the CouchDB container port to allow for REST API interaction or CouchDB Fauxton user interface interaction,
+for example to ensure that you have correct indexes defined for a given query.
+
 Good practices for queries
 --------------------------
 

shimos avatar Sep 28 '23 00:09 shimos