Explore information related to mongodb


Monitor MongoDB with Nagios XI - How to perform this ?


This article covers  how to monitor a MongoDB server with Nagios XI using the MongoDB Server Configuration Wizard in order to monitor the health of your server. The

wizard supplies checks to monitor the following: number of queries per second, memory usage, the number of databases on the server, and percentage of free connections available.


To Connect to MongoDB with the appropriate privileges:

Connect to mongod or mongos with the privileges specified in the Prerequisites section.

The following procedure uses the myUserAdmin created in Enable Access Control:

mongo --port 27017 -u myUserAdmin -p 'abc123' --authenticationDatabase 'admin'

The myUserAdmin has privileges to create roles in the admin as well as other databases.


To Modify Access for an Existing User in MongoDB:

  • You must have the grantRole action on a database to grant a role on that database.
  • You must have the revokeRole action on a database to revoke a role on that database.
  • To view a role's information, you must be either explicitly granted the role or must have the viewRole action on the role's database.

Read More



MongoDB service is not starting up - Fix it now


This article covers how to resolve the the problem of starting MongoDB server when running the command mongod which may arise due to file permission or ownership issues.


The reason was the dbpath variable in /etc/mongodb.conf. 

To fix, you only had to change the owner of the /data/db directory recursively.

Also For ubunto , what made it happen and was real simple is to install mongodb package:

$sudo apt-get install  mongodb


Also, You can use the below-mentioned command for mongodb service is not starting up:-

$sudo rm /var/lib/mongodb/mongod.lock 

$mongod --repair 

$sudo service mongodb start


Mongodb service is not starting up:

This can also happen if your file permissions get changed somehow. 

Removing the lock file didn't help, and we were getting errors in the log file like:

2016-01-20T09:14:58.210-0800 [initandlisten] warning couldn't write to / rename file /var/lib/mongodb/journal/prealloc.0: couldn't open file    /var/lib/mongodb/journal/prealloc.0 for writing errno:13 Permission denied

2016-01-20T09:14:58.288-0800 [initandlisten] couldn't open /var/lib/mongodb/local.ns errno:13 Permission denied

2016-01-20T09:14:58.288-0800 [initandlisten] error couldn't open file /var/lib/mongodb/local.ns terminating


So, went to check permissions:

ls -l /var/lib/mongodb

total 245780

drwxr-xr-x 2 mongodb mongodb     4096 Jan 20 09:14 journal

drwxr-xr-x 2 root    root        4096 Jan 20 09:11 local

-rw------- 1 root    root    67108864 Jan 20 09:11 local.0

-rw------- 1 root    root    16777216 Jan 20 09:11 local.ns

-rwxr-xr-x 1 mongodb nogroup        0 Jan 20 09:14 mongod.lock

Read More



Unable to connect to MongoDB in Docker container - How to fix this error


This article covers solution to the error "Unable to connect to MongoDB in docker container".

Basically, this Docker error happens when there is a port issue.

if a container listens on 127.0.0.1, then the host can't map ports to it.

You need to listen on 0.0.0.0 or similar, and then the -p can reach the container's interface.


How do Docker ports work?

The -P command opens every port the container exposes. 

Docker identifies every port the Dockerfile exposes and the ones that are exposed with the Docker container build --expose parameter. 

Every exposed port is bound directly on a “random” port of the host machine.

The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in the specified PATH or URL . 

The build process can refer to any of the files in the context. 

For example, your build can use a COPY instruction to reference a file in the context.

Read More



Advantages of NoSQL Databases - Get to know them now


This article covers the advantages of NoSQL Databases. #SQL databases are vertically scalable, NoSQL databases are horizontally scalable. SQL databases are table based, while NoSQL databases are document, key-value, graph or wide-column stores. 

SQL #databases are better for multi-row transactions, #NoSQL are better for unstructured data like documents or JSON.

#MongoDB, CouchDB, CouchBase, Cassandra, HBase, Redis, Riak, Neo4J are the popular NoSQL databases examples.

The structure of many different forms of data is more easily handled and evolved with a NoSQL database. 

NoSQL databases are often better suited to storing and modeling structured, semi-structured, and unstructured data in one database.


Main purpose of NoSQL?

NoSQL Database is a non-relational Data Management System, that does not require a fixed schema. 

It avoids joins, and is easy to scale. 

The major purpose of using a NoSQL database is for distributed data stores with humongous data storage needs. 

NoSQL is used for Big data and real-time web apps.


Reasons to Use a NoSQL Database includes:

1. Storing large volumes of data without structure. A NoSQL database doesn't limit storable data types.

2. Using cloud computing and storage. Cloud-based storage is a great solution, but it requires data to be easily spread across multiple servers for scaling.

3. Rapid development.


Main types of NoSQL databases?

There are four big NoSQL types: 

1. Key-value store

2. Document store, 

3. Column-oriented database,

4. Graph database. 

Each type solves a problem that can't be solved with relational databases. 

Actual implementations are often combinations of these. 

OrientDB, for example, is a multi-model database, combining NoSQL types.

Read More



MongoDB failed to load list of databases - Fix it now


This article covers how to resolve the error 'MongoDB failed to load the list of databases' can occur due to various reasons that include failed database user/password authentication, outdated Robo 3T version, and so on.

The error 'MongoDB failed to load the list of databases' means that you can't connect if there are no databases to list. 


To fix the error 'MongoDB failed to load the list of databases':

1. You can fix this issue with 1.2 connecting to a new mongo 4.2.

It's fixed when using robo3t version 1.3, which supports newer version of mongo.

2. You can create a database and a collection for it. 

Once you create a database and a collection, it works.

3. You will need to upgrade mongodb to the last version, so you can to connect in your local database.

Read More



MongoDB error network is unreachable - Fix it now


This article covers methods to resolve the error 'MongoDB error network is unreachable' which can occur due to many reasons that include network issues, if the mongo server is not started, and so on.

To resolve this #MongoDB #error:
1. On Ubuntu server, to open mongo shell run:

$ mongo

2. Inside mongo shell, type following command to create new a admin user.

> use admin;
> db.createUser({user:"admin", pwd:"password", roles:[{ role: "root", db: "admin" }]});

3. By default mongodb is configured to allow connections only from localhost(IP 127.0.0.1).
We need to allow remote connections from any ip address. The following change should only be done in your development server. Open up etc/mongod.conf file and do the following change.

# network interfaces
net:
port: 27017
bindIp: 0.0.0.0   #default value is 127.0.0.1


Also in the same mongod.conf file uncomment security option and add authorization option as shown below:

security:
authorization: enabled    


4. Save and exit the mongod.conf file and restart mongodb server:

$ sudo servcie mongod restart

Read More



MongoDB error topology was destroyed - Fix it now


This article covers method to fix the error 'MongoDB error topology was destroyed' which happens due to many reasons that include interruption of the node server’s connection to the MongoDB instance while it was trying to write to it. If the mongo driver drops the connection for any reason.
Another reason could be mongoose disconnecting before the creation of mongo document indexes.
You might try updating mongo.
There's also a mongo config setting that can easily in the database using too much memory and being killed by the kernel.

Read More



Install Graylog on CentOS 7 How to do it


This article will guide you on steps to #Graylog on #CentOS 7 and an effective method to make the logs more structured and searchable.

Graylog is a leading centralized log management solution built to open standards for capturing, storing, and enabling real-time analysis of terabytes of #machine data. 

Graylog is an open source log management platform which enables you to aggregate up to terabytes of log data, from multiple log sources, DCs, and geographies with the capability to scale horizontally in your data center, #cloud, or both.

To #Install Graylog 3 with Elasticsearch on CentOS 7:

1. Configure #SELinux. 

2. Add required #repositories 

3. Install #Java, #Elasticsearch, and #MongoDB. 

4. Configure Elasticsearch for Graylog. 

5. Install Graylog 3 on CentOS 7. 

6. Start Graylog service on CentOS 7.

Read More



Monitor MongoDB Performance


This article will guide you on some useful monitoring utilities and #database commands for #reporting #statistics about the state of a running #MongoDB instance.

The motivation of the MongoDB language is to implement a data store that provides high performance, high availability, and automatic #scaling. MongoDB is extremely simple to install and implement. MongoDB uses JSON or BSON documents to #store #data.

Read More



Backup, Restore and Migrate a MongoDB database on CentOS 8


MongoDB is highly scalable, using shards. Horizontal scalability is a big plus in most #NoSQL databases. MongoDB is no exception. It is also highly reliable due to its replica sets, and the data is replicated in more nodes asynchronously.

This article will guide you on the steps to perform #backup, #restore and #migrate a #MongoDB #database on #CentOS 8.

Read More



MongoDB connection timeout


This article will help you to fix common MongoDB errors such as MongoDB connection timeout which generally occurs due to the wrong settings in the MongoDB server, bad connection parameters and so on.

Read More



MongoDB installation on Ubuntu


This article will guide you on how to install MongoDB on Ubuntu.

Read More



Configure MongoDB Authentication on Ubuntu


This article will put you through the steps you need to take to enable authentication for MongoDB on Ubuntu by modifying MongoDB configuration file.

Read More



MongoDB remote access configuration for Ubuntu


This article will guide you through the steps you can take to configure remote access for MongoDB on Ubuntu 18.04.

Read More



Solve Mongodb Socket error address already in use


Best Method to get rid of Mongodb Socket  error address already in use in Linux.

Read More



Solve fassert failure error in Mongodb


Effective method to fix Mongodb Fassert() failure error.

Read More



Move MongoDB database files


Need to move your MongoDB database files to another server? Read on...

Read More




For Linux Tutorials

We create Linux HowTos and Tutorials for Sys Admins. Visit us on LinuxAPT.com

Also for Tech related tips, Visit forum.outsourcepath.com or General Technical tips on www.outsourcepath.com






Focus on your business, not your servers.

Click Here to Learn More