Ubuntu Installation with Self-Managed OpenSearch

The following article contains information on deploying Graylog with self-managed OpenSearch. Please note that Graylog Data Node is the preferred method of data management. See Get Started with Data Node for more information.

This guide describes the recommended way to install Graylog on Ubuntu 20.04 LTS and 22.04. All links and packages are present at the time of writing.

These installation steps also include installation of OpenSearch so that you can manage your search backend manually.

Warning: This guide does not cover security settings! The server administrator must make sure the Graylog server is not publicly exposed and is following security best practices.

Prerequisites

Hint: This guide assumes that any firewall is disabled and traffic can flow across all necessary ports.

Graylog 6.1 requires the following to maintain compatibility with its software dependencies: 

Graylog Version Minimum MongoDB Version Maximum MongoDB Version Minimum OpenSearch Version Maximum OpenSearch Version

6.1.x

5.0.7

7.x

1.1.x (or 1.3.x for Graylog Security)

2.15.x

Warning: We caution you not to install or upgrade to OpenSearch 2.16! It is not supported. Doing so will break your instance!

Additionally, we recommend you review the version notes specific to your preferred version of Graylog for guidance on installing and configuring your Graylog instance.

Server Timezone

To set a specific time zone on the Graylog server, you can use the following command. (For more information on setting a time zone, we recommend this blog post.)

Copy
sudo timedatectl set-timezone UTC

MongoDB

To install MongoDB on Ubuntu, the official MongoDB documentation provides a helpful tutorial.

1. First select your version of Ubuntu and begin the installation sequence: 

2. You can use a keyserver approach via a widget to incorporate proxies and other non-free environments. For example:

Copy
wget -qO- 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf5679a222c647c87527c2f8cb00a0bd1e2c63c11' | sudo apt-key add -

3. Enable MongoDB during the operating system’s start up and verify it is running.

Copy
sudo systemctl daemon-reload
sudo systemctl enable mongod.service
sudo systemctl restart mongod.service
sudo systemctl --type=service --state=active | grep mongod

4. Hold the currently installed version of the MongoDB package to prevent it from being automatically upgraded to a newer version when updates are installed.

Copy
sudo apt-mark hold mongodb-org

When you want to upgrade the package, be sure to remove the hold:

Copy
sudo apt-mark unhold <package-name>

In the above code line, replace <package-name> with the correct package name.

OpenSearch

Hint: The remainder of this guide assumes that you wish to use Graylog with a self-managed OpenSearch deployment. Should you prefer to enable the Graylog Data Node, which is designed to configure and optimize OpenSearch for use with Graylog, please proceed now to Install Graylog Data Node.

The recommended method of installation is to follow the user documentation provided by the OpenSearch service. To set up the OpenSearch service with your Graylog instance, follow the steps below.

The following example installs OpenSearch using the DEB package.

1. Import the public GPG key. This key is used to verify that the APT repository is signed.

Copy
curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring

2. Create an APT repository for OpenSearch.

Copy
echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-2.x.list

3. Verify that the repository was created successfully.

Copy
sudo apt-get update

4. With the repository information added, list all available versions of OpenSearch.

Copy
sudo apt list -a opensearch

5. Choose the version of OpenSearch you want to install. Unless otherwise indicated, the latest available version of OpenSearch is installed.

To install a specific version of OpenSearch, specify the version manually using opensearch=<version>.

Copy
sudo OPENSEARCH_INITIAL_ADMIN_PASSWORD=<custom-admin-password> apt-get -y install opensearch=2.15.0

Hint: OpenSearch 2.12 and greater now requires setting the OPENSEARCH_INITIAL_ADMIN_PASSWORD environment variable when installing. The password must be a minimum of eight characters with at least one uppercase letter, one lowercase letter, one number, and one special character.
For example: 
Copy
sudo OPENSEARCH_INITIAL_ADMIN_PASSWORD=<custom-admin-password> apt-get -y install opensearch

6. Hold the currently installed version of the OpenSearch package to prevent it from being automatically upgraded to a newer version when updates are installed.

Copy
sudo apt-mark hold opensearch

When you want to upgrade the package, be sure to remove the hold:

Copy
sudo apt-mark unhold <package-name>

In the above code line, replace <package-name> with the correct package name.

Graylog Configuration for OpenSearch

1. Begin by opening the yml file.

Copy
sudo nano /etc/opensearch/opensearch.yml

2. Update the following fields for a minimum unsecured running state (single node).

Copy
cluster.name: graylog
node.name: ${HOSTNAME}
path.data: /var/lib/opensearch
path.logs: /var/log/opensearch
discovery.type: single-node
network.host: 0.0.0.0
action.auto_create_index: false
plugins.security.disabled: true

To create multi-node OpenSearch clusters, see the documentation.

3. Enable JVM options.

Copy
sudo nano /etc/opensearch/jvm.options

4. Now, update the Xms & Xmx settings with half of the installed system memory.

Copy
-Xms1g
-Xmx1g

5. Configure the kernel parameters at runtime.

Copy
sudo sysctl -w vm.max_map_count=262144
echo 'vm.max_map_count=262144' | sudo tee -a /etc/sysctl.conf

6. Finally, enable the system service.

Copy
sudo systemctl daemon-reload
sudo systemctl enable opensearch.service
sudo systemctl start opensearch.service
sudo systemctl status opensearch.service

Graylog

1. Install the Graylog Open repository configuration and Graylog itself with the following commands:

Copy
wget https://packages.graylog2.org/repo/packages/graylog-6.1-repository_latest.deb
sudo dpkg -i graylog-6.1-repository_latest.deb
sudo apt-get update
sudo apt-get install graylog-server

If you are installing Graylog Enterprise, use the following commands:

Copy
wget https://packages.graylog2.org/repo/packages/graylog-6.1-repository_latest.deb
sudo dpkg -i graylog-6.1-repository_latest.deb
sudo apt-get update
sudo apt-get install graylog-enterprise

2. Mark the package on-hold so that package updates do not accidentally upgrade the Graylog server.

For Graylog Open:

Copy
sudo apt-mark hold graylog-server

For Graylog Enterprise:

Copy
sudo apt-mark hold graylog-enterprise

When you want to upgrade the package, be sure to remove the hold:

Copy
sudo apt-mark unhold <package-name>

In the above code line, replace <package-name> with the correct package name.

Edit the Graylog Configuration File

1. Begin by opening the Graylog configuration file. Review the configuration file and edit as needed according to your preferences and environment.

Copy
sudo nano /etc/graylog/server/server.conf

Warning: Add password_secret and root_password_sha2 values to the configuration file as these are mandatory and Graylog will not start without them.

2. To create your password_secret, run the following command:

Copy
< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-96};echo;

3. Use the following command to create your root_password_sha2:

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

4. To be able to connect to Graylog, set the http_bind_address value in the configuration file to the public host name or a public IP address for the machine to which you can connect. More information about these settings can be found in Configuring the Web Interface. Alternatively, you can also set this configuration using this command:

Copy
sudo sed -i 's/#http_bind_address = 127.0.0.1.*/http_bind_address = 0.0.0.0:9000/g' /etc/graylog/server/server.conf

Hint: If you’re operating a single-node setup and would like to use HTTPS for the Graylog web interface and the Graylog REST API, it’s possible to use NGINX or Apache as a reverse proxy.

5. Edit the elasticsearch_hosts setting to include a list of comma-separated URIs to one or more valid OpenSearch nodes. A sample specification may look as follows:

Copy
elasticsearch_hosts = http://es-node-1.example.org:9200/foo,https://someuser:somepassword@es-node-2.example.org:9200

Warning: If this setting is not adjusted before start up, then you will NOT be able to log into Graylog using your previously configured root password!

6. The last step is to enable Graylog during the operating system’s startup:

Copy
sudo systemctl daemon-reload
sudo systemctl enable graylog-server.service
sudo systemctl start graylog-server.service
sudo systemctl --type=service --state=active | grep graylog

Now you can ingest messages into Graylog!

Getting Started

Now that you have installed Graylog, you can review your initial configuration settings and connect to the web interface!

Cluster Setup

If you plan to have multiple servers assuming different roles in your cluster like we have in this big production setup you need to modify only a few settings. This is covered in our multi-node setup guide. The default file location guide lists the locations of the files you need to modify.