Open source software (IBMZ/LinuxONE). MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time
At a high level, MongoDB enables developers that use data to build easily, adapt quickly, and scale reliably. In this tutorial, We will be using RHEL 7.8
- Request access to LinuxONE Community Cloud. Follow instructions here
1.1 Create a repo file so that you can install MongoDB enterprise directly using yum
For RHEL 7.8:
# sudo vi /etc/yum.repos.d/mongodb-enterprise-4.4.repo
#[mongodb-enterprise-4.4]
name=MongoDB Enterprise Repository
baseurl=https://repo.mongodb.com/yum/redhat/$releasever/mongodb-enterprise/4.4/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
1.2 Save and quite vi
# wq:
2.1 Install MongoDB Install the MongoDB Enterprise packages For RHEL 7.8:
# sudo yum install -y mongodb-enterprise
3.1 Start MongoDB
# sudo systemctl start mongod
If you receive an error similar to the following when starting mongod:
Failed to start mongod.service: Unit mongod.service not found.
Run the following command first:
# sudo systemctl daemon-reload
3.2 Enable MongoDB
# sudo systemctl enable mongod
3.3 Check status of the MongoDB server
# sudo systemctl status mongod
3.4 MongoDB Shell
# mongo
4.1 Show existing database
# show dbs;
4.2 Create database
# use demo_db
4.3 Create Collection
# db.createCollection('user');
The output of the above should result:
{ "ok" : 1 }
4.4 Show collections
# show collections;
The output of the above should result:
user
4.5 Insert
# db.user.insert({"name":"Phila"});
4.6 Find collection
# db.user.find();
The output of the above should result:
{ "_id" : ObjectId("5f3b6b0a3b6976978ce646c1"), "name" : "Phila" }
4.7 Delete collection
# db.user.drop()
The output of the above should result:
true
4.8 Show collections
# show collections;