Add OpenNMS repository GPG key
sudo apt-key adv --fetch-keys https://debian.opennms.org/OPENNMS-GPG-KEY
Add apt repository
sudo add-apt-repository -s 'deb https://debian.opennms.org stable main'
The message with conflicting distributions stable but got opennms-xx can be safely ignored.
Install OpenNMS Horizon with built-in dependencies (optional)
sudo apt -y install opennms
Installing R package for trending and forcasting (optional)

If you want time series trending and forecast functions you have to install the R project packages. The additional download size for packages is ~152 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 are planning on performing 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