Operating System CentOS

How to Install Graylog Server on AlmaLinux 9 and Rocky Linux 9

Install Graylog with MongoDB and Graylog Data Node on AlmaLinux 9 or Rocky Linux 9, complete the preflight setup and start receiving syslog messages.

This guide installs a current Graylog log management server on AlmaLinux 9 or Rocky Linux 9: MongoDB for configuration data, Graylog Data Node for log storage and search, and the Graylog server with its web interface. At the end you can log in on port 9000 and receive syslog messages from other machines.

CentOS 7 is end-of-life and is not a supported platform for current Graylog releases; Graylog's RPM repository supports RHEL 8 and 9 and their rebuilds, AlmaLinux and Rocky Linux. The architecture has also changed since Graylog 2.x. Elasticsearch is no longer used: Graylog stores messages in OpenSearch, and the recommended way to run it is Graylog Data Node, a package that installs and manages OpenSearch for you. You also no longer install Java yourself, and the web interface is served by the Graylog server directly.

Requirements

  • Two servers running AlmaLinux 9 or Rocky Linux 9: one for Graylog and MongoDB (graylog01, 203.0.113.10) and one for Data Node (datanode01, 203.0.113.11). Graylog's documentation says Data Node should run on its own node, separate from Graylog and MongoDB. For a small test you can put everything on one machine, but give it plenty of memory.
  • Enough RAM for the heaps you will configure: Data Node's OpenSearch heap is set to half the system memory, and so is Graylog's.
  • A user with sudo rights on both servers. Graylog recommends an XFS file system for storage, which is the default on these distributions.

The commands below install Graylog 7.2, the release documented in Graylog's Red Hat installation guide at the time of writing, with MongoDB 8.0. Graylog 7.x requires MongoDB 7.x or newer. Check the compatibility matrix before choosing other versions.

Graylog expects consistent time across nodes; setting the servers to UTC is optional but convenient:

sudo timedatectl set-timezone UTC

Install MongoDB on the Graylog server

On graylog01, create /etc/yum.repos.d/mongodb-org-8.0.repo:

[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc

Install MongoDB and lock the package so a routine update cannot move it to a version Graylog does not support:

sudo dnf install -y mongodb-org
sudo dnf install -y python3-dnf-plugin-versionlock
sudo dnf versionlock add mongodb-org

MongoDB listens only on localhost by default, but Data Node on the second server has to reach it. Edit the net section of /etc/mongod.conf so it also binds to the server's own address:

net:
  port: 27017
  bindIp: 127.0.0.1,203.0.113.10

Start MongoDB:

sudo systemctl daemon-reload
sudo systemctl enable mongod.service
sudo systemctl start mongod.service

This basic setup has no MongoDB authentication. Restrict port 27017 with the firewall as shown below, and enable authentication before you rely on the system.

Install Graylog Data Node

On datanode01, install Graylog's repository package and Data Node. Do not install OpenSearch yourself.

sudo rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-7.2-repository_latest.rpm
sudo dnf install -y graylog-datanode

OpenSearch needs vm.max_map_count to be at least 262144:

echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.d/99-graylog-datanode.conf
sudo sysctl --system
cat /proc/sys/vm/max_map_count

Generate a secret. You will use the same value on both servers, so keep it at hand:

openssl rand -hex 32

Edit /etc/graylog/datanode/datanode.conf and set these values. opensearch_heap is not in the file by default; add it and set it to half of the server's RAM, up to 31 GB (the example suits a 16 GB server):

password_secret = PASTE_THE_GENERATED_SECRET
opensearch_heap = 8g
mongodb_uri = mongodb://203.0.113.10:27017/graylog

Start Data Node:

sudo systemctl daemon-reload
sudo systemctl enable graylog-datanode.service
sudo systemctl start graylog-datanode

Install the Graylog server

Back on graylog01:

sudo rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-7.2-repository_latest.rpm
sudo dnf install -y graylog-server

Create the SHA-256 hash of the password you want for the admin account. The command prompts for the password and prints the hash:

echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1

Edit /etc/graylog/server/server.conf:

password_secret = PASTE_THE_SAME_SECRET_AS_ON_THE_DATA_NODE
root_password_sha2 = PASTE_THE_HASH
http_bind_address = 0.0.0.0:9000

http_bind_address is commented out by default; without it the web interface is only reachable from the server itself. Next, set the Java heap in /etc/sysconfig/graylog-server to half of the system memory (16 GB at most), with the minimum and maximum equal. For a server with 4 GB of RAM:

GRAYLOG_SERVER_JAVA_OPTS="-Xms2g -Xmx2g -server -XX:+UseG1GC -XX:-OmitStackTraceInFastThrow"

Start Graylog:

sudo systemctl daemon-reload
sudo systemctl enable graylog-server.service
sudo systemctl start graylog-server.service

Open the firewall

Graylog's installation guide assumes the required ports are open. With firewalld, allow the web interface from outside and the internal ports only between the two servers. On graylog01:

sudo firewall-cmd --permanent --add-port=9000/tcp
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.11" port port="27017" protocol="tcp" accept'
sudo firewall-cmd --reload

On datanode01, let the Graylog server reach the OpenSearch API (9200) and the Data Node API (8999):

sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="9200" protocol="tcp" accept'
sudo firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.10" port port="8999" protocol="tcp" accept'
sudo firewall-cmd --reload

Complete the preflight setup

On first start Graylog runs a preflight wizard that connects it to the Data Node. The one-time login for it is written to the Graylog log when the service starts:

sudo tail -n 50 /var/log/graylog-server/server.log

Open http://203.0.113.10:9000, sign in with the initial credentials from the log and follow the wizard to set up certificates for the Data Node and provision it. When it finishes, Graylog restarts into normal operation and you log in as admin with the password you hashed earlier.

Receive your first logs

In the web interface go to System, Inputs, choose Syslog UDP and launch a new input on a port above 1024, for example 1514 (Graylog does not run as root, so it cannot bind the standard port 514). Open the port on graylog01:

sudo firewall-cmd --permanent --add-port=1514/udp
sudo firewall-cmd --reload

On a client that uses rsyslog, create /etc/rsyslog.d/90-graylog.conf with a forwarding rule and restart rsyslog:

*.* @203.0.113.10:1514;RSYSLOG_SyslogProtocol23Format
sudo systemctl restart rsyslog

Messages should appear on the Search page within seconds.

Troubleshooting

  • Service state and logs: sudo systemctl status graylog-server graylog-datanode mongod and sudo journalctl -u graylog-datanode -e.
  • Data Node does not appear in the preflight wizard: the password_secret values differ, Data Node cannot reach MongoDB on port 27017, or the Graylog server cannot reach ports 8999 and 9200.
  • mongod exits immediately with an illegal-instruction error: current MongoDB releases need a CPU with AVX support, which some older or budget virtual servers do not expose.
  • Blocked by SELinux: Graylog's guide does not cover SELinux policy. If a service fails only in enforcing mode, look for denials with sudo ausearch -m avc -ts recent.

Frequently asked questions

Can I still use Elasticsearch with Graylog?

Not with current releases. Graylog moved to OpenSearch, either managed for you by Data Node or as a self-managed OpenSearch cluster within the version range listed in the compatibility matrix.

Do I need Nginx in front of Graylog?

Not to make it work; Graylog serves the web interface and API itself on port 9000. A reverse proxy is still the usual way to add HTTPS on port 443. When you use one, set http_external_uri in server.conf to the public address.

Which Graylog package should I install?

graylog-server is Graylog Open. graylog-enterprise contains the Enterprise and Security products and needs a licence. The installation steps are otherwise identical.

How do I upgrade later?

Each Graylog minor release has its own repository package, so dnf update only brings patch releases. For a new minor version, read that version's upgrade notes, install the new repository package and upgrade Data Node and Graylog together. Check the MongoDB range in the compatibility matrix before removing the version lock.

Share story:

Continue reading other guides on How VPS.