Recently I had an issue in my homelab environment. Because of some power outages, my vCenter Appliance hadn’t been shutdown correctly and now vCenter didn’t start correctly anymore. After some searching I found that the database could not be loaded. In the VMware KBs I couldn’t find anything that fixes the start up of the database it self. Mostly it is about resetting the database, but even though my environment is quite small, I had VSAN running in it and was afraid about what would happen if I connect a clean vCenter to the existing hosts. So I decided to dive in and try and fix it at the database level.
To see what was going on, I first check the vpxd.log ( /var/log/vmware/vpxd/vpxd.log) and found that a login to the database was not possible:
info vpxd[7FF9A8AD97A0] [Originator@6876 sub=vpxdVdb] [VpxdVdb::SetDBType] Logging in to DSN: VMware VirtualCenter with username vc error vpxd[7FF9A8AD97A0] [Originator@6876 sub=vpxdVdb] [VpxdVdb::SetDBType] Failed to connect to database: ODBC error: (08001) - [unixODBC]Could not connect to the server; --> Connection refused [127.0.0.1:5432]. Retry attempt: 1 ...
2016-09-10 19:02:12.294 UTC 57d458b4.21d8 0 LOG: database system was interrupted; last known up at 2016-05-16 22:58:35 UTC 2016-09-10 19:02:14.920 UTC 57d458b4.21d8 0 LOG: unexpected pageaddr E/C8000000 in log segment 000000010000000E000000CC, offset 0 2016-09-10 19:02:14.920 UTC 57d458b4.21d8 0 LOG: invalid primary checkpoint record 2016-09-10 19:02:14.920 UTC 57d458b4.21d8 0 LOG: unexpected pageaddr E/C8000000 in log segment 000000010000000E000000CC, offset 0 2016-09-10 19:02:14.920 UTC 57d458b4.21d8 0 LOG: invalid secondary checkpoint record 2016-09-10 19:02:14.920 UTC 57d458b4.21d8 0 PANIC: could not locate a valid checkpoint record 2016-09-10 19:02:14.920 UTC 57d458b1.20bf 0 LOG: startup process (PID 8664) was terminated by signal 6: Aborted 2016-09-10 19:02:14.920 UTC 57d458b1.20bf 0 LOG: aborting startup due to startup process failure
/opt/vmware/vpostgres/9.3/bin/pg_resetxlog -f {Location of the database}
EMB_DB_STORAGE='/storage/db/vpostgres'
/opt/vmware/vpostgres/9.3/bin/pg_resetxlog -f /storage/db/vpostgres You must run pg_resetxlog as the PostgreSQL superuser
su vpostgres -s /bin/sh /opt/vmware/vpostgres/9.3/bin/pg_resetxlog -f /storage/db/vpostgres