Install GnuPG and add OpenNMS repository GPG key
sudo apt -y install gnupg ca-certificates
sudo apt-key adv --fetch-keys https://debian.opennms.org/OPENNMS-GPG-KEY
Add Apt repository
sudo apt -y install software-properties-common
sudo add-apt-repository -s 'deb https://debian.opennms.org stable main'
sudo apt update
You can safely ignore the message about conflicting distributions (expected stable but got opennms-xx).
Install OpenNMS Horizon with built-in dependencies
sudo apt -y install opennms
Install R packages for trending and forcasting (optional)

If you want time series trending and forecast functions you must install the R project packages. The additional download size for packages is ~134 MB.

sudo apt -y install r-recommended
Disable the OpenNMS Horizon repository after installation to prevent unwanted upgrades when upgrading other packages on the server. After upgrade, Horizon requires manual steps to upgrade configuration files or migrate database schemas to a new version. We recommend that you exclude the Horizon packages from update except when you plan perform an upgrade.
sudo apt-mark hold libopennms-java \
              libopennmsdeps-java \
              opennms-common \
              opennms-db
Verify directory structure with the tree command
sudo apt -y install tree
tree /usr/share/opennms -L 1
Directory structure after successful installation
/usr/share/opennms
├── bin
├── data
├── deploy
├── etc -> /etc/opennms
├── jetty-webapps
├── lib -> ../java/opennms
├── logs -> /var/log/opennms
├── share -> /var/lib/opennms
└── system