We will installing and configuring MongoDB on CentOS 6 as Part 2 of our series on Monitoring your systems with logstash and Graylog2. ::Part 1::Part 3::Part 4::, in order to support our Graylog2 server.
Our goals are simple:
- Run as an unprivileged user
- Consistent installation, logging, and configuration locations
- Ability to scale to securely monitor other remote systems
- Automating the installation
The installation overview:
- Add 10gen as a yum repository
- Download and install MongoDB
- Configure MongoDB
- Start MongoDB
- Create Admin User
- Create Greylog2 database
- Create Greylog2 user
We will assume you know the basics of system administration (ie.file permissions, ownership, etc.).
So let’s get this working!
We’ll first configure yum to check the 10gen repository for the lastest MongoDB
We’ll just echo the meager contents to create our file as root.
Below is for x86_64 CentOS
And below would be for the i386 32 bit CentOS
Next we’ll download and install MongoDB using yum, again as root:
Next we edit the MongoDB config file “/etc/mongod.conf” with our favorite editor
We want to set the following options
Now we will create the data directory and set permissions so mongod can write to the database. Again as root:
Now we’re ready to start MongoDB. As root:
Our next step is to create our default admin user. As normal user:
We next first authenticate, then create the graylog2 database.
That’s all there is to creating the database. Just too easy!
Next we create the graylog2 user and password for connecting to the database. Note the credentials for configuring the graylog2 server
We are now finished with configuring MongoDB, I hope it took just a few minutes. If you’d like to read up on MongoDB security, just head on over to the documentation.