Another Japan in the World

Jun Aruga's blog, who lived in Japan, Singapore, live in Czech Republic. Mainly about IT and travel.

Install MongoDB 3.4.3 on Fedora 26

Use the RPM packages.

In case of Fedora MongoDB RPM Package, mongodb RPM includes the client commands "mongo". mongodb-server RPM includes the server files and the commands such as "mongod" and "mongos".

Install

Install is easy. Just type dnf install.

Build single non-sharding and single server, as it is used as a local development.

$ sudo dnf install mongo mongodb-server
$ rpm -q mongodb mongodb-server
mongodb-3.4.3-1.fc26.x86_64
mongodb-server-3.4.3-1.fc26.x86_64
$ rpm -ql mongodb
/usr/bin/mongo
/usr/bin/mongobridge
/usr/bin/mongoperf
/usr/share/doc/mongodb
/usr/share/doc/mongodb/README
/usr/share/licenses/mongodb
/usr/share/licenses/mongodb/APACHE-2.0.txt
/usr/share/licenses/mongodb/GNU-AGPL-3.0.txt
/usr/share/man/man1/mongo.1.gz
/usr/share/man/man1/mongoperf.1.gz
$ rpm -ql mongodb-server
/etc/logrotate.d/mongodb
/etc/mongod.conf
/etc/mongos.conf
/etc/sysconfig/mongod
/etc/sysconfig/mongos
/usr/bin/mongod
/usr/bin/mongos
/usr/lib/systemd/system/mongod.service
/usr/lib/systemd/system/mongos.service
/usr/lib/tmpfiles.d/mongodb.conf
/usr/share/man/man1/mongod.1.gz
/usr/share/man/man1/mongos.1.gz
/var/lib/mongodb
/var/log/mongodb
/var/run/mongodb
$ cat /etc/passwd | grep mongodb
mongodb:x:184:184:MongoDB Database Server:/var/lib/mongodb:/sbin/nologin

Configuration

Change the database directory's partition.

As /var/lib/mongodb used as storage directory is in small sized partition, I changed it to bigger /home partition.

$ mkdir -p /home/jaruga/var/lib/mongodb

$ sudo chown mongodb:root /home/jaruga/var/lib/mongodb

$ ls -dl /home/jaruga/var/lib/mongodb
drwxrwxr-x 2 mongodb root 4096 Nov 12 22:18 /home/jaruga/var/lib/mongodb

$ chmod 755 /home/jaruga
$ cd /var/lib

$ sudo rm -rf mongodb

$ sudo ln -s /home/jaruga/var/lib/mongodb mongodb

$ ls -l /var/lib/mongodb
lrwxrwxrwx 1 root root 28 Nov 12 22:26 /var/lib/mongodb -> /home/jaruga/var/lib/mongodb/

Run

$ sudo systemctl start mongod

$ systemctl status mongod | grep Active
   Active: active (running) since Sun 2017-11-12 23:32:19 CET; 14min ago

$ mongo
MongoDB shell version v3.4.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.3
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
  http://docs.mongodb.org/
Questions? Try the support group
  http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2017-11-12T22:36:29.770+0100 I STORAGE  [initandlisten] 
2017-11-12T22:36:29.770+0100 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-11-12T22:36:29.770+0100 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-11-12T22:36:30.232+0100 I CONTROL  [initandlisten] 
2017-11-12T22:36:30.232+0100 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-11-12T22:36:30.232+0100 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2017-11-12T22:36:30.232+0100 I CONTROL  [initandlisten] 
2017-11-12T22:36:30.232+0100 I CONTROL  [initandlisten] 
2017-11-12T22:36:30.232+0100 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 30566 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
>
> db
test

> use test
switched to db test

> exit
bye

$ sudo systemctl stop mongod

It works.

Reference: Install MongoDB Community Edition on Red Hat Enterprise or CentOS Linux — MongoDB Manual 3.4

Remove all ads