Bug #17834

support running candlepin database on a seperate host

Added by Neil Hanlon over 5 years ago. Updated over 2 years ago.

Target version:
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:


I migrated my postgres db off of the main server and updated all the necessary configs, however it appears that cpdb does not read from /etc/candlepin/candlepin.conf. Therefore to run this step I had to run

/usr/share/candlepin/cpdb --update --password <pass> -d"//<myhost>:5432/candlepin"

Upgrade Step: migrate_candlepin...

########## ERROR ############
Error running command: liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql-jdbc.jar:/var/lib/tomcat/webapps/candlepin/WEB-INF/classes/ --changeLogFile=db/changelog/changelog-update.xml --url=jdbc:postgresql:candlepin --username=candlepin  --password=<redacted> migrate -Dcommunity=False
Status code: 65280
Command output: Liquibase update Failed: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Migrating candlepin database
Traceback (most recent call last):
  File "/usr/share/candlepin/cpdb", line 245, in <module>
  File "/usr/share/candlepin/cpdb", line 69, in update
  File "/usr/share/candlepin/cpdb", line 92, in _run_liquibase
  File "/usr/share/candlepin/cpdb", line 38, in run_command
    error_out(command, status, output)
  File "/usr/share/candlepin/cpdb", line 46, in error_out
    raise Exception("Error running command")
Exception: Error running command

Upgrade step migrate_candlepin failed. Check logs for more information.


#1 Updated by Justin Sherrill over 5 years ago

  • Subject changed from migrate_candlepin step fails if postgres is no longer running on the host to support running candlepin database on a seperate host
  • Legacy Backlogs Release (now unused) set to 114
  • Difficulty set to medium

#2 Updated by Pascal Pascher over 5 years ago

I encountered the same issue moving my candlepin db to a separate postgresql server (where the foreman db itself was running already). I somehow managed to get everything working again but it feels very stitched together. Are there any installer options to set the candlepin db host? Also I would like to completely remove postgresql-server from the katello vm as it is no longer needed.

Here is what I did:

- create database user 'candlepin' on postgresql server
- modify pg_hba.conf to allow access for candlepin user
- create a psql dump of current candlepin db on katello vm and import on postgresql server

vim /etc/candlepin/candlepin.conf


To get foreman-installer to work I also had to modify a katello-installer file:

vim /usr/share/katello-installer-base/hooks/pre/30-upgrade.rb

-- Kafo::Helpers.execute("/usr/share/candlepin/cpdb --update --password #{Kafo::Helpers.read_cache_data('candlepin_db_password')}")
++ Kafo::Helpers.execute("/usr/share/candlepin/cpdb --update --password #{Kafo::Helpers.read_cache_data('candlepin_db_password')} -d \"//\"")

vim /usr/share/katello-installer-base/modules/candlepin/templates/_candlepin_database.conf.erb

-- jpa.config.hibernate.connection.url=jdbc:<%= @db_type %>://<%= @db_host %>:<%= @db_port %>/<%= @db_name %>
++ jpa.config.hibernate.connection.url=jdbc:<%= @db_type %>://<%= @db_port %>/<%= @db_name %>
-- org.quartz.dataSource.myDS.URL=jdbc:<%= @db_type %>://<%= @db_host %>:<%= @db_port %>/<%= @db_name %>
++ org.quartz.dataSource.myDS.URL=jdbc:<%= @db_type %>://<%= @db_port %>/<%= @db_name %>

Now I could upgrade without errors:
foreman-installer --scenario katello --upgrade

#3 Updated by Justin Sherrill over 2 years ago

  • Triaged set to Yes
  • Status changed from New to Resolved

This should work now, its possible to deploy with an external database:

--katello-candlepin-db-* options

see 'foreman-installer --full-help | grep candlepin-db' for more details

Also available in: Atom PDF