Tuesday, June 24, 2025

.::: Install MongoDB 8 in Centos 9 (mongodb-org-server, mongodb-mongosh) :::.

  
1. download

wget https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.0/x86_64/RPMS/mongodb-org-server-8.0.10-1.el9.x86_64.rpm

2. create repository

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


3. Install mongodb server & mongosh
 
install yum install mongodb-org-server-8*  mongodb-mongosh -y 

4. enable start & start mongodb 

5. console 


mongosh

[root@teguhth ~]# mongosh
Current Mongosh Log ID: 685a2fbca43f3c3987e94969
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.4
Using MongoDB:          8.0.10
Using Mongosh:          2.3.4
mongosh 2.5.3 is available for download: https://www.mongodb.com/try/download/shell

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/

------
   The server generated these startup warnings when booting
   2025-06-24T11:53:15.143+07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2025-06-24T11:53:15.144+07:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
   2025-06-24T11:53:15.144+07:00: We suggest setting the contents of sysfsFile to 0.
   2025-06-24T11:53:15.144+07:00: vm.max_map_count is too low
   2025-06-24T11:53:15.145+07:00: We suggest setting swappiness to 0 or 1, as swapping can cause performance problems.
------

test> use teguhth
switched to db teguhth
teguhth> show collections;
barang
Barang
customer
pasok
pembelian
suplier
teguhth>


6. if fail (Result: exit-code)

ls -l /tmp/mongodb-27017.sock
rm -f /tmp/mongodb-27017.sock
systemctl restart mongod
systemctl status mongod
mongosh

[root@teguhth ~]# systemctl status mongod
× mongod.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Tue 2025-06-24 11:52:00 WIB; 54s ago
   Duration: 210ms
       Docs: https://docs.mongodb.org/manual
    Process: 1846 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)
   Main PID: 1846 (code=exited, status=14)
        CPU: 77ms

Jun 24 11:52:00 teguhth systemd[1]: Started MongoDB Database Server.
Jun 24 11:52:00 teguhth mongod[1846]: {"t":{"$date":"2025-06-24T04:52:00.301Z"},"s":"I",  "c":"CONTROL",  "id":7484500, "ctx":"main","msg":"Environment variable >
Jun 24 11:52:00 teguhth systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
Jun 24 11:52:00 teguhth systemd[1]: mongod.service: Failed with result 'exit-code'.
lines 1-13/13 (END)
^C
[root@teguhth ~]# ls -l /tmp/mongodb-27017.sock
srwx------ 1 root root 0 Jun 23 14:41 /tmp/mongodb-27017.sock
[root@teguhth ~]# rm -f /tmp/mongodb-27017.sock
[root@teguhth ~]# systemctl restart mongod
[root@teguhth ~]# systemctl status mongod
? mongod.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; preset: disabled)
     Active: active (running) since Tue 2025-06-24 11:53:14 WIB; 2s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 1904 (mongod)
     Memory: 296.3M
        CPU: 935ms
     CGroup: /system.slice/mongod.service
             +-1904 /usr/bin/mongod -f /etc/mongod.conf

Jun 24 11:53:14 teguhth systemd[1]: Started MongoDB Database Server.
Jun 24 11:53:14 teguhth mongod[1904]: {"t":{"$date":"2025-06-24T04:53:14.050Z"},"s":"I",  "c":"CONTROL",  "id":7484500, "ctx":"main","msg":"Environment variable >
lines 1-12/12 (END)
^C
[root@teguhth ~]# mongosh
Current Mongosh Log ID: 685a2f465da36c688be94969
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.4
Using MongoDB:          8.0.10
Using Mongosh:          2.3.4
mongosh 2.5.3 is available for download: https://www.mongodb.com/try/download/shell

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/

------
   The server generated these startup warnings when booting
   2025-06-24T11:53:15.143+07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2025-06-24T11:53:15.144+07:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
   2025-06-24T11:53:15.144+07:00: We suggest setting the contents of sysfsFile to 0.
   2025-06-24T11:53:15.144+07:00: vm.max_map_count is too low
   2025-06-24T11:53:15.145+07:00: We suggest setting swappiness to 0 or 1, as swapping can cause performance problems.
------

test>

No comments:

Post a Comment

Popular Posts