Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 11.06 minutes in March 2021 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

How to Install Graylog on CentOS 7 with Elasticsearch and MongoDB

by | Jan 21, 2021

Wondering how to install Graylog on CentOS 7? We can help you.

Rsyslog is installed in CentOS by default. However, it requires more work to get the configuration right and it is a difficult task. While figuring out the log management technique we found out that Graylog is easy to use as it has a web interface.

Here, at Bobcares, we assist our customers with several installations as part of our Server Management Services.

Today, let us see how to install Graylog 3.0 on CentOS 7.


Graylog on CentOS 7

Rsyslog is the most popular Syslog implementation used for log management. Since it requires more work to get the configuration right, some of our customers suggest us to install Graylog, which is a complete logging solution.

Graylog is an open-source powerful log management tool that has many use cases, from monitoring SSH logins and unusual activity to debugging applications. It is based on Elasticsearch, Java, and MongoDB.

Components of Graylog

Graylog has four main components:

  • Graylog Server

A worker that receives and processes messages, and communicates with all other non-server components is a Graylog server. Its performance is CPU dependent.

  • Elasticsearch

Since it stores the log messages from the Graylog server, we have a facility to search them according to our needs. We need to allocate more memory and use SAS or SAN disks as it does indexing of data. Its performance is RAM and disk I/O dependent.

  • MongoDB

MongoDB stores metadata and does not experience much load.

  • Web Interface

It is the user interface.

Moving ahead, let us see an effective method our Support Techs employ on how to install Graylog 3.0 on CentOS 7.


How to Install Graylog on CentOS 7

In order to begin, our Support Engineers suggest having the following requisites.

  1. CentOS 7 server with at least 2GB of RAM.
  2. A user with root or superuser access.
  3. EPEL repository.
    # yum install epel-release
  4. Java on the machine.
    # yum install -y java-1.8.0-openjdk-headless

    Verify the Java version.

    # java -version

    Our output will be similar to:

    openjdk version “1.8.0_191”
    OpenJDK Runtime Environment (build 1.8.0_191-b12)
    OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
  5. An updated system.
    # yum update -y


  • Install MongoDB

As we mentioned earlier, MongoDB acts as a database that stores the configurations and meta information. Its installation is easy and quick.

Here, we will use MongoDB’s official repository to get the latest version of MongoDB.

# vi /etc/yum.repos.d/mongodb-org-4.0.repo

Add repository information to the above file.

name=MongoDB Repository

We install the community edition of MongoDB using the following command.

# yum install -y mongodb-org

Then we start the MongoDB service and enable it to the system start-up.

# systemctl start mongod
# systemctl enable mongod

Eventually, the service will be up and running.


  • Install Elasticsearch

An important component in the Graylog setup, it stores the data from Graylog input and displays the messages whenever a user request over the Graylog built-in web interface.

Its primary use is to index the data/logs and provide the search functionality when the Graylog web interface request any information.

Before the installation we need to import the GPG signing key:

# rpm –import

Then we create a repository file to get the latest version of the Elasticsearch package from the official repository.

# vi /etc/yum.repos.d/elasticsearch.repo

Subsequently, we need to add the below content to the above file.

name=Elasticsearch repository for 6.x packages

Now, we can install the Elasticsearch package with the yum command.

# yum install -y elasticsearch

Reload the systemctl daemon and enable Elasticsearch to start automatically on the system startup.

# systemctl daemon-reload
# systemctl enable elasticsearch

We need to edit the elasticsearch.yml file and set the cluster name to Graylog for Elasticsearch to work with Graylog setup.

# vi /etc/elasticsearch/elasticsearch.yml

The update should be like this: graylog

Later, restart the Elasticsearch service.

# systemctl restart elasticsearch

It will take about one minute for the Elasticsearch to restart. Elastisearch will now listen to 9200 for processing HTTP requests.

In case we want to check the response, we can use the CURL command:

# curl -X GET http://localhost:9200

The cluster name should be Graylog.

Then, we need to perform a health check of the Elasticsearch cluster.

# curl -XGET ‘http://localhost:9200/_cluster/health?pretty=true’

Make sure the cluster status comes as green.


  • Install Graylog Server

Graylog server accepts and processes the log messages coming from the various inputs. It will also display data to requests that come from the Graylog web interface.

In order to download and install Graylog 3.x repository we run:

# rpm -Uvh

We install the Graylog server using the following command.

# yum -y install graylog-server

Then edit the server.conf file to begin the Graylog configuration.

# vi /etc/graylog/server/server.conf
We use the following command to create a secret
pwgen -N 1 -s 96

Our output will be similar to:


Place the secret below in server.conf

password_secret = OH9wXpsNZVBA8R5vJQSnkhTB1qDOjCxAh3aE3LvXddtfDlZlKYEyGS24BJAiIxI0sbSTSPovTTnhLkkrUvhSSxodTlzDi5gP

Set the hash password for the root user, i.e., admin of Graylog. We need this password to login into the Graylog web.

We can edit/update the server.conf with a hashed password if we want to change/reset the forgotten password of the admin.

To generate a hash password use the below command. Replace yourpassword with our choice.

# echo -n yourpassword | sha256sum

Our output will be similar to:


Here, place the hash password.

root_password_sha2 = e3c652f0ba0b4801205814f8b6bc49672c4c74e25b497770bb89b22cdeb4e951

Subsequently, we can set up an email address for the admin user.

root_email = “”

Set timezone of root (admin) user.

root_timezone = UTC

Set only one master node by defining the below variable, the default setting is true.

If this server is our second Graylog node in our environment, set it to false to make this node a slave.

is_master = true

Set the number of log messages to keep per index. It is recommended to have several smaller indices instead of larger ones.

elasticsearch_max_docs_per_index = 20000000

The following parameter defines to have a total number of indices. When it reaches this number the old index will be deleted..

elasticsearch_max_number_of_indices = 20

Shards setting relies on the number of nodes in the particular Elasticsearch cluster. If we have only one node, set it as 1.

elasticsearch_shards = 1

This defines the number of replicas for our indices. If we have only one node in the Elasticsearch cluster, set it as 0.

elasticsearch_replicas = 0


  • Install Graylog Web Interface

We need to edit the server.conf file to enable the Graylog web interface.

# vi /etc/graylog/server/server.conf

To let Graylog Web Interface connect to the Graylog server, we modify the entries. Replace with proper IP address.

http_bind_address =

Then we restart Graylog service.

# systemctl daemon-reload
# systemctl restart graylog-server

Make Graylog server start automatically on system startup.

# systemctl enable graylog-server

We can check out the server startup logs, which will be useful to troubleshoot Graylog for any issues.

# tailf /var/log/graylog-server/server.log

If everything goes well, we will see the below message in the server.log file.

2021-01-20T21:00:23.157+05:30 INFO [ServerBootstrap] Graylog server up and running.


  • Firewall & SELinux

In CentOS 7/RHEL 7, firewall rules are set to block most of the traffic coming from the external machines by default. We need to add allow rules for Graylog to work correctly.

$ firewall-cmd –permanent –add-port=9000/tcp

Reload firewalld to take effect of the new rules.

$ firewall-cmd –reload

If we have SELinux enabled on the system, then we will need to add a few exceptions in SELinux policies.

$ setsebool -P httpd_can_network_connect 1
$ semanage port -a -t http_port_t -p tcp 9000
$ semanage port -a -t http_port_t -p tcp 9200
$ semanage port -a -t mongod_port_t -p tcp 27017


  • Configure Graylog to Receive Syslog messages

Log into Graylog Web Interface

In the web browser, go to port 9000 of the server’s public IP address:


We should see a login screen. Enter admin as username and the admin password set earlier.

The red number at the top will show a message that says we have a node without any running inputs.


  • Create Syslog UDP Input

To add an input to receive Syslog messages, click on the System drop-down in the top menu.

Now, from the drop-down menu, select Inputs.

Then select Syslog UDP from the drop-down menu and click the Launch new input button.

A “Launch a new input: Syslog UDP” modal window will pop up. Enter the following information:

  1. Title: syslog
  2. Port: 8514
  3. Bind address: graylog_private_IP

Then click Launch.

We should now see an input named “syslog” in the Local inputs section (with a green box that says “running” next to it).

Now the Graylog server is ready to receive syslog messages on port 8514 from the servers.


  • Configure Rsyslog to Send Syslogs to Graylog Server

Once we have created the inputs, configure Rsyslog or forward any system logs to our Graylog server.

Perform the following steps on all the client servers that we want to send syslog messages to Graylog.

Initially, edit the Rsyslog configuration file.

# vi /etc/rsyslog.conf

Typical Rsyslog configuration will look like below to send logs on UDP 8514.

*.info;mail.none;authpriv.none;cron.none @graylog_private_IP:8514

Then we restart the Rsyslog service to send logs.

# systemctl restart rsyslog

After configuring rsyslog on all the servers to monitor, go back to the Graylog web interface.


  • View Graylog Sources

In the web browser, go to port 9000 of the server’s public IP address:

In a web browser: http://graylog_public_IP:9000/

Then click on Sources in the top bar. It will have a list of all of the servers that we configured rsyslog on.

The hostname of the sources is on the left, with the number of messages received by Graylog on the right.


  • Search Graylog Data

After letting Graylog collect messages for some time, we will be able to search through the messages.

For example, if we search for “sshd” to see what kind of SSH activity is happening on our servers, we will get results that reveal sshd logs for various servers, and failed root login attempts.

The results may vary. However, it can help to identify many issues, including how unauthorized users are attempting to access the servers.

Searching through data in Graylog is useful, for example, if we want to review the logs of a server or several servers after an incident.

Centralized logging makes it easier to correlate related incidents because we do not need to log into multiple servers to see all the occurrences.

[Find it hard to process Graylog? We are here for you]



To conclude, we saw how to install Graylog on CentOS 7. Our Support Engineers suggest this as an effective and easy method to make the logs more structured and searchable.


Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.