While installing Postgres as an APM database, the installation fails with an error "Postgres Instance already exists" even though Postgres has been uninstalled. The following error is reported:
Postgres Instance already exists. If you have an existing PostgreSQL-<version> instance, please uninstall it and then install a new instance. You may also use the existing instance to create new APM schema.
No files are present in the target Postgres installation directory and this occurs regardless of how the validateDatabase and validateSchema properties are set during install.
Any Unix based OS with Postgres used as the APM 10.x database.
This issue typically occurs when installing Postgres on a server where a manual uninstall of Postgres has already been performed. The error occurs because the installer checks for the presence of a Postgres script inside the /etc/init.d directory.
To address this issue, login as a root user and remove this script:
cd /etc/init.d
rm -f postgresql-<version>