---
# System prepended metadata

title: Graylog on Ubuntu 22.04

---


## MongoDB

Ensure GnuPG is installed and add Mongo PGP keys
```bash
sudo apt-get install -y install lsb-release ca-certificates curl gnupg2
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
```

Using the following commands, add the repository to your system
```bash
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
```

Install MongoDB 6.0
```bash
sudo apt update && sudo apt install mongodb-org
```

After successful installation, Check MongoDB installed version:
```bash
mongod --version
```


Start/enable MongoDB and check its status:
```bash
sudo systemctl enable --now mongod

sudo systemctl status mongod
```
MongoDB should now be installed and exposed on port 27017




## OpenSearch Installation

Import GPG key
```bash
curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | sudo apt-key add -
```
Add APT repository
```bash
echo "deb https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/opensearch-2.x.list
```

Verify that the repository was added successfully.
```bash
sudo apt-get update
```
With the repository information added, list all available versions of OpenSearch:
```bash
sudo apt list -a opensearch
```

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

```bash
sudo apt-get install opensearch
sudo systemctl start opensearch
sudo systemctl status opensearch
sudo systemctl enable opensearch
```



## OpenSearch Configuration


Edit JVM options:

```bash
sudo nano /etc/opensearch/jvm.options
```
Update the `Xms` & `Xmx` settings with half of the installed system memory. (For example 12GB system memory):
```
-Xms6g
-Xmx6g
```

_Configure the kernel parameters at runtime:_
```bash
sudo sysctl -w vm.max_map_count=262144
sudo echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
```

_Finally, enable the system service:_
```bash
sudo systemctl daemon-reload
sudo systemctl enable opensearch.service
sudo systemctl start opensearch.service
sudo systemctl status opensearch.service
```


## Graylog

### Install

Repository information is provided through .deb
```bash
wget https://packages.graylog2.org/repo/packages/graylog-5.0-repository_latest.deb
sudo dpkg -i graylog-5.0-repository_latest.deb
sudo apt-get update && sudo apt-get install graylog-server
``` 
### GrayLog Configuration

To create your root_password_sha2, run the following command:

```bash
echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
```
_You will then need to use the following command to create your password_secret:_
```bash
< /dev/urandom tr -dc A-Z-a-z-0-9 | head -c${1:-96};echo;
```
_then edit this file with the 2 passwords from above._
```bash
sudo nano /etc/graylog/server/server.conf
```
_To be able to connect to Graylog, set http_bind_address to the public host name or a public IP address of the machine with which you can connect._
    
_The last step is to enable Graylog during the operating system’s startup:_
    
```bash
sudo systemctl daemon-reload
sudo systemctl enable graylog-server.service
sudo systemctl start graylog-server.service
sudo systemctl --type=service --state=active | grep graylog
```