Thursday, August 5, 2021

.::: Install MongoDB 5.x on Centos/Redhat 7 using repository :::.

 
1. Create repo the /etc/yum.repos.d/mongodb-org-5.0.repo file for MongoDB.

[root@teguhth02 ~]# cat /etc/yum.repos.d/mongodb-org-5.0.repo
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
[root@teguhth02 ~]# 

2. Install MongoDB with the yum package manager.
[root@teguhth02 ~]# 
[root@teguhth02 ~]# yum install -y mongodb-org
[root@teguhth02 ~]# yum install -y mongodb-org
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.idroot.cloud
 * extras: vpsmurah.jagoanhosting.com
 * updates: mirror.idroot.cloud
Package mongodb-org-5.0.2-1.el7.x86_64 already installed and latest version
Nothing to do
[root@teguhth02 ~]# rpm -qa | grep mongodb
mongodb-org-server-5.0.2-1.el7.x86_64
mongodb-org-shell-5.0.2-1.el7.x86_64
mongodb-org-database-5.0.2-1.el7.x86_64
mongodb-database-tools-100.4.1-1.x86_64
mongodb-org-5.0.2-1.el7.x86_64
mongodb-org-database-tools-extra-5.0.2-1.el7.x86_64
mongodb-mongosh-1.0.4-1.el7.x86_64
mongodb-org-mongos-5.0.2-1.el7.x86_64
mongodb-org-tools-5.0.2-1.el7.x86_64
[root@teguhth02 ~]# 

3. restart service mongodb
[root@teguhth02 ~]# 
[root@teguhth02 ~]# systemctl enable mongod
[root@teguhth02 ~]# systemctl start mongod
[root@teguhth02 ~]# 

4. login to terminal/mongodb 

[root@teguhth02 ~]# mongo
MongoDB shell version v5.0.2
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("bfb5f3d3-59cf-4d6d-9faf-c281332e6509") }
MongoDB server version: 5.0.2
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
We recommend you begin using "mongosh".
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
---
The server generated these startup warnings when booting: 
        2021-08-05T11:10:54.441+07:00: The configured WiredTiger cache size is more than 80% of available RAM. See http://dochub.mongodb.org/core/faq-memory-diagnostics-wt
        2021-08-05T11:10:55.954+07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
        Enable MongoDB's free cloud-based monitoring service, which will then receive and display
        metrics about your deployment (disk utilization, CPU, operation statistics, etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring, run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---
> exit
bye
[root@teguhth02 ~]# 

5. create user 

db.createUser(
{ user: "aisyah",
pwd: "hanin",

roles:[{role: "userAdminAnyDatabase" , db:"admin"}]})
db.createUser( {user: "aisyah", pwd: "hanin", roles:[{role: "userAdminAnyDatabase" , db:"admin"}]}) ;

log sample 

> db.createUser( {user: "aisyah",pwd: "hanin", roles:[{role: "userAdminAnyDatabase" , db:"admin"}]}) ;
Successfully added user: {
"user" : "aisyah",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
> show users;
{
"_id" : "test.aisyah",
"userId" : UUID("742e5c4b-386e-4ea0-b751-8a20ff041710"),
"user" : "aisyah",
"db" : "test",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}

6. Create Database, table and insert 

1 comment:

  1. MongoDB is supported by GenexDb
    The world's leading open-source database, MongoDB, allows document-oriented database managementDatabase Training. Using GenexDB, you can build high quality, effective applications using MongoDB. We are in-sync with you right from installation to timely upgrades, leading you to success in every step of the way.Database Training

    ReplyDelete

Popular Posts