How to set up MongoDB for Demo how-to-setup-mongodb-for-demo
Introduction introduction
This tutorial describes how to set up MSRP for one author instance and one publish instance.
With this setup, the community content is accessible from both author and publish environments without needing to forward or reverse replicate user-generated content (UGC).
This configuration is suitable for non-production environments such as for development and/or demonstration.
A production environment should:
- Run MongoDB with a replica set
- Use SolrCloud
- Contain multiple publisher instances
MongoDB mongodb
Install MongoDB install-mongodb
-
Download MongoDB from https://www.mongodb.com/
-
Choice of OS:
- Linux®
- Mac 10.8
- Windows 7
-
Choice of version:
- At a minimum, use version 2.6
-
-
Basic configuration
-
Follow the MongoDB install instructions.
-
Configure for mongod:
- No need to configure mongos or sharding.
-
The installed MongoDB folder is called <mongo-install>.
-
The defined data directory path is called <mongo-dbpath>.
-
-
MongoDB may run on same host as AEM or run remotely.
Start MongoDB start-mongodb
- <mongo-install>/bin/mongod --dbpath <mongo-dbpath>
This starts a MongoDB server using default port 27017.
- For Mac, increase ulimit with start arg ‘ulimit -n 2048’
Demo Production Option: Setup MongoDB Replica Set demo-production-option-setup-mongodb-replica-set
The following commands are an example of setting up a replica set with 3 nodes on localhost:
-
bin/mongod --port 27017 --dbpath data --replSet rs0&
-
bin/mongo
cfg = {"_id": "rs0","version": 1,"members": [{"_id": 0,"host": "127.0.0.1:27017"}]}
rs.initiate(cfg)
-
bin/mongod --port 27018 --dbpath data1 --replSet rs0&
-
bin/mongod --port 27019 --dbpath data2 --replSet rs0&
-
bin/mongo
rs.add("127.0.0.1:27018")
rs.add("127.0.0.1:27019")
rs.status()
Solr solr
Install Solr install-solr
-
Download Solr from Apache Lucene:
- Suitable for any OS.
- Solr version 7.0.
- Solr requires Java™ 1.7 or greater.
-
Basic configuration
- Follow ‘example’ Solr setup.
- No service is needed.
- The installed Solr folder is called <solr-install>.
Configure Solr for AEM Communities configure-solr-for-aem-communities
To configure a Solr collection for MSRP for demo, there are two decisions to be made (select the links to main documentation for details):
- Run Solr in standalone or SolrCloud mode.
- Install standard or advanced multilingual search (MLS).
Standalone Solr standalone-solr
The method for running Solr may differ depending on the version and manner of installation. The Solr reference guide is the authoritative documentation.
For simplicity, using version 4.10 as an example, start Solr in standalone mode:
- cd to <solrinstall>/example
- Java™ -jar start.jar
This process starts a Solr HTTP server using default port 8983. You can browse to the Solr Console to get a Solr console for testing.
- default Solr console: http://localhost:8983/solr/
etc/hosts
file with a new entry for this hostname (for example, 127.0.0.1 user-macbook-pro) to star Solr properly.SolrCloud solrcloud
To run a basic (not production) solrCloud setup, start solr with:
java -Dbootstrap_confdir=./solr/collection1/conf -Dbootstrap_conf=true -DzkRun -jar start.jar
Identify MongoDB as Common Store identify-mongodb-as-common-store
Launch the author and publish AEM instances, if necessary.
If AEM was running before MongoDB was started, then the AEM instances must be restarted.
Follow the instructions on the main documentation page: MSRP - MongoDB Common Store
Test test
To test and verify the MongoDB common store, post a comment on the publish instance and view it on the author instance, and view the UGC in MongoDB and Solr:
-
On the publish instance, browse to the Community Components Guide page and select the Comments component.
-
Sign in to post a comment:
-
Enter text in the comment text entry box and click Post
-
Simply view the comment on the author instance (likely still signed in as admin / admin).
Note: While there are JCR nodes under the asipath on author, these nodes are for the SCF framework. The actual UGC is not in JCR, it is in the MongoDB.
-
View the UGC in mongodb Communities > Collections > Content
-
View the UGC in Solr:
- Browse to Solr dashboard: http://localhost:8983/solr/.
- User
core selector
to selectcollection1
. - Select
Query
. - Select
Execute Query
.
Troubleshooting troubleshooting
No UGC Appears no-ugc-appears
-
Make sure MongoDB is installed and running properly.
-
Make sure that MSRP has been configured to be the default provider:
-
On all author and publish AEM instances, revisit the Storage Configuration console, or check the AEM repository:
-
In JCR, if /etc/socialconfig does not contain an srpc node, it means that the storage provider is JSRP.
-
If the srpc node exists and contains node defaultconfiguration, the defaultconfiguration’s properties should define MSRP to be the default provider.
-
-
Make sure that AEM was restarted after MSRP selected.