5

I am trying to install PostgreSQL on my Linux Debian 7.2 server but it fails.

this is what I did :

user ~ $ sudo apt-get install postgresql
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances
Lecture des informations d'état... Fait
Les paquets supplémentaires suivants seront installés :
  postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common
Paquets suggérés :
  oidentd ident-server locales-all postgresql-doc-9.1
Les NOUVEAUX paquets suivants seront installés :
  postgresql postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common
0 mis à jour, 5 nouvellement installés, 0 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 0 o/4 518 ko dans les archives.
Après cette opération, 22,0 Mo d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer [O/n] ? O
Préconfiguration des paquets...
Sélection du paquet postgresql-client-common précédemment désélectionné.
(Lecture de la base de données... 51752 fichiers et répertoires déjà installés.)
Dépaquetage de postgresql-client-common (à partir de .../postgresql-client-common_134wheezy4_all.deb) ...
Sélection du paquet postgresql-client-9.1 précédemment désélectionné.
Dépaquetage de postgresql-client-9.1 (à partir de .../postgresql-client-9.1_9.1.14-0+deb7u1_amd64.deb) ...
Sélection du paquet postgresql-common précédemment désélectionné.
Dépaquetage de postgresql-common (à partir de .../postgresql-common_134wheezy4_all.deb) ...
Ajout de « détournement de /usr/bin/pg_config en /usr/bin/pg_config.libpq-dev par postgresql-common »
Sélection du paquet postgresql-9.1 précédemment désélectionné.
Dépaquetage de postgresql-9.1 (à partir de .../postgresql-9.1_9.1.14-0+deb7u1_amd64.deb) ...
Sélection du paquet postgresql précédemment désélectionné.
Dépaquetage de postgresql (à partir de .../postgresql_9.1+134wheezy4_all.deb) ...
Traitement des actions différées (« triggers ») pour « man-db »...
Paramétrage de postgresql-client-common (134wheezy4) ...
Paramétrage de postgresql-client-9.1 (9.1.14-0+deb7u1) ...
update-alternatives: utilisation de « /usr/share/postgresql/9.1/man/man1/psql.1.gz » pour fournir « /usr/share/man/man1/psql.1.gz » (psql.1.gz) en mode automatique
Paramétrage de postgresql-common (134wheezy4) ...
Ajout de l'utilisateur postgres au groupe ssl-cert
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Paramétrage de postgresql-9.1 (9.1.14-0+deb7u1) ...
Creating new cluster (configuration: /etc/postgresql/9.1/main, data: /var/lib/postgresql/9.1/main)...
Moving configuration file /var/lib/postgresql/9.1/main/postgresql.conf to /etc/postgresql/9.1/main...
Moving configuration file /var/lib/postgresql/9.1/main/pg_hba.conf to /etc/postgresql/9.1/main...
Moving configuration file /var/lib/postgresql/9.1/main/pg_ident.conf to /etc/postgresql/9.1/main...
Configuring postgresql.conf to use port 5432...
update-alternatives: utilisation de « /usr/share/postgresql/9.1/man/man1/postmaster.1.gz » pour fournir « /usr/share/man/man1/postmaster.1.gz » (postmaster.1.gz) en mode automatique
[....] Starting PostgreSQL 9.1 database server: main[....] The PostgreSQL server failed to start. Please check the log output: 2014-12-28 14:05:24 CET FATAL: n'a pas pu charger le fichier de cl? priv?e << server.key >> : key values misma[FAIL.. failed!
 failed!
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: erreur de traitement de postgresql-9.1 (--configure) :
 le sous-processus script post-installation installé a retourné une erreur de sortie d'état 1
dpkg: des problèmes de dépendances empêchent la configuration de postgresql :
 postgresql dépend de postgresql-9.1 ; cependant :
 Le paquet postgresql-9.1 n'est pas encore configuré.

dpkg: erreur de traitement de postgresql (--configure) :
 problèmes de dépendances - laissé non configuré
Des erreurs ont été rencontrées pendant l'exécution :
 postgresql-9.1
 postgresql
[ Rootkit Hunter version 1.4.0 ]
File updated: searched for 169 files, found 136
E: Sub-process /usr/bin/dpkg returned an error code (1)

And when I check log file it only says

2014-12-28 14:05:24 CET FATAL: n'a pas pu charger le fichier de cl? priv?e << server.key >> : key values mismatch

(unable to load private key file << server.key >> : key values mismatch

I have tried to completely uninstall and reinstall but still not work. Any help pls ?

3
  • It's a problem with the data directory contents, probably caused by a mismatch between the server's SSL certificate and SSL key. This could mean that it's using the system Snakeoil certs and they're broken, or that it's using its own and they're misconfigured. If you don't have any data of value in the PostgreSQL install, the first thing you should do is apt-get --purge remove postgresql-9.1 then delete the data directory (this will permanently and unrecoverably destroy your database contents) which in Ubuntu is IIRC located in /var/lib/pgsql/9.4. Dec 28, 2014 at 14:24
  • @CraigRinger Thx for answer. I have already tried to completely purge and uninstall postgresql, and delete all dirs. But the error remains on reinstalling. Yes it seems there's an error with certificates, but I don't know how to figure it out. Dec 28, 2014 at 14:44
  • Sounds like it's an issue with the system default 'snakeoil' certs then. Regenerate them maybe. See ptspts.blogspot.com.au/2010/01/… for example. Dec 28, 2014 at 15:48

4 Answers 4

2

I was having this problem aswell. I fixed this by doing:

cd /var/lib/postgresql/9.1/main #Change 9.1 to your version

Remove the symlink to the old certificates

sudo rm server.* 

Then regenerate the certificates

openssl genrsa -des3 -out server.key 2048
openssl rsa -in server.key -out server.key.insecure
mv server.key server.key.secure
mv server.key.insecure server.key

openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Then set the permissions

chown postgres.postgres server.*
chmod 640 server.*

Hope this helps

1
  • I had to use 0600 permission rather than 640, with 640 I got an error message stating the permission should be 0600, sure enough chmod 0600 server.* did fix the issue.
    – Melardev
    May 8, 2021 at 15:30
1

The same error message appears if you ssl_cert_file points to a certificate chain, not just to a single certificate.

0

I also had this issue today and the issue was caused, because the referenced certificate and the private key file do not belong to each other (copy-paste error).

Replacing the certificate+key-files with a matching pair also fixed the issue for me.

0

I faced similar issue when I was trying to create self signed certificate using our own CA following below steps:

  • openssl genpkey -out test.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048 - Step1
  • openssl req -new -nodes -key test.key -out test.csr -subj /CN=* - Step2
  • openssl x509 -req -in test.csr -CA cm-ca.pem -CAkey cm-ca.key -CAcreateserial -out test.pem -days 365 -sha256 - Step3 I faced this error when I was mounting CA Key in the pod rather than using Key generated from Step1. Make sure you are using correct Certificate+Key combination.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .