You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: daprdocs/content/en/reference/components-reference/supported-state-stores/setup-mongodb.md
+18-24
Original file line number
Diff line number
Diff line change
@@ -47,67 +47,60 @@ spec:
47
47
The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}).
48
48
{{% /alert %}}
49
49
50
-
If you wish to use MongoDB as an actor store, append the following to the yaml.
50
+
### Actor state store and transactions support
51
+
52
+
When using as an actor state store or to leverage transactions, MongoDB must be running in a [Replica Set](https://www.mongodb.com/docs/manual/replication/).
53
+
54
+
If you wish to use MongoDB as an actor store, add this metadata option to your Component YAML:
| server | Y<sup>*</sup> | The server to connect to, when using DNS SRV record | `"server.example.com"`
63
-
| host | Y<sup>*</sup> | The host to connect to | `"mongo-mongodb.default.svc.cluster.local:27017"`
65
+
| server | Y<sup>1</sup> | The server to connect to, when using DNS SRV record | `"server.example.com"`
66
+
| host | Y<sup>1</sup> | The host to connect to | `"mongo-mongodb.default.svc.cluster.local:27017"`
64
67
| username | N | The username of the user to connect with (applicable in conjunction with `host`) | `"admin"`
65
68
| password | N | The password of the user (applicable in conjunction with `host`) | `"password"`
66
69
| databaseName | N | The name of the database to use. Defaults to `"daprStore"` | `"daprStore"`
67
70
| collectionName | N | The name of the collection to use. Defaults to `"daprCollection"` | `"daprCollection"`
68
71
| writeConcern | N | The write concern to use | `"majority"`
69
72
| readConcern | N | The read concern to use | `"majority"`, `"local"`,`"available"`, `"linearizable"`, `"snapshot"`
70
73
| operationTimeout | N | The timeout for the operation. Defaults to `"5s"` | `"5s"`
71
-
| params | N<sup>**</sup> | Additional parameters to use | `"?authSource=daprStore&ssl=true"`
74
+
| params | N<sup>2</sup> | Additional parameters to use | `"?authSource=daprStore&ssl=true"`
72
75
73
-
> <sup>[*]</sup> The `server` and `host` fields are mutually exclusive. If neither or both are set, Dapr will return an error.
76
+
> <sup>[1]</sup> The `server` and `host` fields are mutually exclusive. If neither or both are set, Dapr returns an error.
74
77
75
-
> <sup>[**]</sup> The `params` field accepts a query string that specifies connection specific options as `<name>=<value>` pairs, separated by `"&"` and prefixed with `"?"`. e.g. to use "daprStore" db as authentication database and enabling SSL/TLS in connection, specify params as `"?authSource=daprStore&ssl=true"`. See [the mongodb manual](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-connection-options) for the list of available options and their use cases.
78
+
> <sup>[2]</sup> The `params` field accepts a query string that specifies connection specific options as `<name>=<value>` pairs, separated by `&` and prefixed with `?`. e.g. to use "daprStore" db as authentication database and enabling SSL/TLS in connection, specify params as `?authSource=daprStore&ssl=true`. See [the mongodb manual](https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-connection-options) for the list of available options and their use cases.
76
79
77
80
## Setup MongoDB
78
81
79
82
{{< tabs "Self-Hosted" "Kubernetes" >}}
80
83
81
84
{{% codetab %}}
82
-
You can run MongoDB locally using Docker:
85
+
You can run a single MongoDB instance locally using Docker:
83
86
84
-
```
87
+
```sh
85
88
docker run --name some-mongo -d mongo
86
89
```
87
90
88
-
You can then interact with the server using `localhost:27017`.
89
-
90
-
If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`.
91
+
You can then interact with the server at `localhost:27017`. If you do not specify a `databaseName` value in your component definition, make sure to create a database named `daprStore`.
91
92
93
+
In order to use the MongoDB state store for transactions and as an actor state store, you need to run MongoDB as a Replica Set. Refer to [the official documentation](https://www.mongodb.com/compatibility/deploying-a-mongodb-cluster-with-docker) for how to create a 3-node Replica Set using Docker.
92
94
{{% /codetab %}}
93
95
94
96
{{% codetab %}}
95
-
The easiest way to install MongoDB on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/mongodb):
96
-
97
-
```
98
-
helm install mongo stable/mongodb
99
-
```
100
-
97
+
You can conveniently install MongoDB on Kubernetes using the [Helm chart packaged by Bitnami](https://github.com/bitnami/charts/tree/main/bitnami/mongodb/). Refer to the documentation for the Helm chart for deploying MongoDB, both as a standalone server, and with a Replica Set (required for using transactions and actors).
101
98
This installs MongoDB into the `default` namespace.
102
99
To interact with MongoDB, find the service with: `kubectl get svc mongo-mongodb`.
103
-
104
-
For example, if installing using the example above, the MongoDB host address would be:
105
-
100
+
For example, if installing using the Helm defaults above, the MongoDB host address would be:
106
101
`mongo-mongodb.default.svc.cluster.local:27017`
107
-
108
-
109
102
Follow the on-screen instructions to get the root password for MongoDB.
110
-
The username is `admin` by default.
103
+
The username is typically `admin` by default.
111
104
{{% /codetab %}}
112
105
113
106
{{< /tabs >}}
@@ -117,6 +110,7 @@ The username is `admin` by default.
117
110
This state store supports [Time-To-Live (TTL)]({{< ref state-store-ttl.md >}}) for records stored with Dapr. When storing data using Dapr, you can set the `ttlInSeconds` metadata property to indicate when the data should be considered "expired".
118
111
119
112
## Related links
113
+
120
114
- [Basic schema for a Dapr component]({{< ref component-schema >}})
121
115
- Read [this guide]({{< ref "howto-get-save-state.md#step-2-save-and-retrieve-a-single-state" >}}) for instructions on configuring state store components
122
116
- [State management building block]({{< ref state-management >}})
0 commit comments