Skip to content

Commit 7b05cfa

Browse files
Update readme.
Shorten MongoDB setup section and add missing anchors. Original Pull Request: #3833
1 parent a16a9fe commit 7b05cfa

File tree

1 file changed

+25
-85
lines changed

1 file changed

+25
-85
lines changed

README.adoc

+25-85
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,19 @@ If you want to raise an issue, please follow the recommendations below:
255255
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using, the JVM version, Stacktrace, etc.
256256
* If you need to paste code, or include a stack trace use https://guides.github.com/features/mastering-markdown/[Markdown] code fences +++```+++.
257257

258+
[[guides]]
259+
== Guides
260+
261+
The https://spring.io/[spring.io] site contains several guides that show how to use Spring Data step-by-step:
262+
263+
* https://spring.io/guides/gs/accessing-data-mongodb/[Accessing Data with MongoDB] is a very basic guide that shows you how to create a simple application and how to access data using repositories.
264+
* https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] is a guide to creating a REST web service exposing data stored in MongoDB through repositories.
265+
266+
[[examples]]
267+
== Examples
268+
269+
* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail.
270+
258271
[[building-from-source]]
259272
== Building from Source
260273

@@ -272,109 +285,46 @@ However, if you want to try out the latest and greatest, Spring Data can be easi
272285
and minimally JDK 8 (https://www.oracle.com/java/technologies/downloads/[JDK downloads]).
273286

274287
In order to build Spring Data MongoDB, first you will need to https://www.mongodb.com/try/download/community[download]
275-
and install a MongoDB distribution. Select "_On-premises (MongoDB locally)_", then "_MongoDB Community Server_"
276-
and in the page form, select the platform matching your system along with the version of MongoDB on which Spring Data
277-
MongoDB is based (https://github.com/spring-projects/spring-data-mongodb/blob/3.2.5/pom.xml#L30[for example]).
288+
and https://docs.mongodb.com/manual/installation/[install a MongoDB distribution].
278289

279290
Once you have installed MongoDB, you need to start a MongoDB server. It is convenient to set an environment variable to
280291
your MongoDB installation (e.g. `MONGODB_HOME`).
281292

293+
To run the full test suite a https://docs.mongodb.com/manual/tutorial/deploy-replica-set/[MongoDB Replica Set] is required.
294+
282295
To run the MongoDB server enter the following command from a command-line:
283296

284297
[source,bash]
285298
----
286299
$ $MONGODB_HOME/bin/mongod --dbpath $MONGODB_HOME/runtime/data --ipv6 --port 27017 --replSet rs0
287300
...
288-
{"t":{"$date":"2021-09-22T11:22:05.490-07:00"},"s":"I", "c":"NETWORK", "id":20113, "ctx":"LogicalSessionCacheReap",
289-
"msg":"Successfully connected to host","attr":{"connString":"127.0.0.1:27017","numOpenConns":1,"socketTimeoutSecs":0.0}}
301+
"msg":"Successfully connected to host"
290302
----
291303

292304
Once the MongoDB server starts up, you should see the message (`msg`), "_Successfully connected to host_".
293305

294306
Notice the `--dbpath` option to the `mongod` command. You can set this to anything you like, but in this case, we set
295307
the absolute path to a sub-directory (`runtime/data/`) under the MongoDB installation directory (in `$MONGODB_HOME`).
296-
You might have other sub-directories as well, such as `runtime/logs/` for instance, if you wish to write your logs to
297-
a file rather than standard out, using the `--logpath` option to the `mongod` command. In this way, all your "runtime"
298-
files for the MongoDB server are conveniently located in one place.
299308

300-
Next, you need to initialize the MongoDB replica set the first time the MongoDB server is started. Replicas are used by
301-
the Spring Data MongoDB transactional tests. This only needs to be done once after the initial start. If you restart
302-
your MongoDB server, you will need to initialize the replica set again. However, you can continue to use the same
303-
MongoDB server for multiple builds of Spring Data MongoDB.
304-
305-
To initialize the replica set, you must start a mongo client:
309+
You need to initialize the MongoDB replica set only once on the first time the MongoDB server is started.
310+
To initialize the replica set, start a mongo client:
306311

307312
[source,bash]
308313
----
309314
$ $MONGODB_HOME/bin/mongo
310-
MongoDB server version: 4.4.8
311-
---
312-
The server generated these startup warnings when booting:
313-
2021-09-22T11:26:50.752-07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
314-
2021-09-22T11:26:50.752-07:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
315-
2021-09-22T11:26:50.752-07:00: Soft rlimits too low
316-
2021-09-22T11:26:50.752-07:00: currentValue: 256
317-
2021-09-22T11:26:50.752-07:00: recommendedMinimum: 64000
318-
---
319-
---
320-
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
321-
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
322-
323-
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
324-
and anyone you share the URL with. MongoDB may use this information to make product
325-
improvements and to suggest MongoDB products and deployment options to you.
326-
327-
To enable free monitoring, run the following command: db.enableFreeMonitoring()
328-
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
329-
---
330-
rs0:PRIMARY>
315+
MongoDB server version: 5.0.0
316+
...
331317
----
332318

333319
Then enter the following command:
334320

335321
[source,bash]
336322
----
337-
rs0:PRIMARY> rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: '127.0.0.1:27017' } ] })
338-
{
339-
"operationTime" : Timestamp(1632335237, 1),
340-
"ok" : 0,
341-
"errmsg" : "already initialized",
342-
"code" : 23,
343-
"codeName" : "AlreadyInitialized",
344-
"$clusterTime" : {
345-
"clusterTime" : Timestamp(1632335237, 1),
346-
"signature" : {
347-
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
348-
"keyId" : NumberLong(0)
349-
}
350-
}
351-
}
352-
rs0:PRIMARY>
323+
mongo> rs.initiate({ _id: 'rs0', members: [ { _id: 0, host: '127.0.0.1:27017' } ] })
353324
----
354325

355-
Finally, you may need to adjust the `ulimit` on your UNIX-based system (for example, Linux or Mac OS X). Currently,
356-
the MongoDB client/server combination uses many Socket connections (which equate to file descriptors on a UNIX-based
357-
system) throughout the Spring Data MongoDB test suite lifecycle. You can inspect your current `ulimit` with
358-
the following command:
359-
360-
[source,bash]
361-
----
362-
$ ulimit -a
363-
core file size (blocks, -c) 0
364-
data seg size (kbytes, -d) unlimited
365-
file size (blocks, -f) unlimited
366-
max locked memory (kbytes, -l) unlimited
367-
max memory size (kbytes, -m) unlimited
368-
open files (-n) 256
369-
pipe size (512 bytes, -p) 1
370-
stack size (kbytes, -s) 8192
371-
cpu time (seconds, -t) unlimited
372-
max user processes (-u) 5568
373-
virtual memory (kbytes, -v) unlimited
374-
----
375-
376-
In this case, we are interested in the `ulimit` setting for "_open files_". As you can see above, this is set to 256.
377-
You will need to adjust this with the following command (we recommend 32768):
326+
Finally, on UNIX-based system (for example, Linux or Mac OS X) you may need to adjust the `ulimit`.
327+
In case you need to, you can adjust the `ulimit` with the following command (32768 is just a recommendation):
378328

379329
[source,bash]
380330
----
@@ -406,17 +356,7 @@ Building the documentation builds also the project without running tests.
406356

407357
The generated documentation is available from `target/site/reference/html/index.html`.
408358

409-
== Guides
410-
411-
The https://spring.io/[spring.io] site contains several guides that show how to use Spring Data step-by-step:
412-
413-
* https://spring.io/guides/gs/accessing-data-mongodb/[Accessing Data with MongoDB] is a very basic guide that shows you how to create a simple application and how to access data using repositories.
414-
* https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] is a guide to creating a REST web service exposing data stored in MongoDB through repositories.
415-
416-
== Examples
417-
418-
* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail.
419-
359+
[[license]]
420360
== License
421361

422362
Spring Data MongoDB is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].

0 commit comments

Comments
 (0)