immer Fehler: "verbindungen über Unix-domain-socket "/var/run/postgresql/.s.PGSQL.5432"?" beim Versuch, erstellen Sie einen Benutzer mit postgresql unter centos

vollständige Fehlermeldung:

Creating 'pcore' PostgreSQL user... psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

Connecting to PostgreSQL as 'pcore'... 
 ** Error occurred during execution: FATAL:  Ident authentication failed for user "pcore"

postgresql:

psql -U postgres template1
psql (8.4.9)
Type "help" for help.

template1=# \l
                                  List of databases
   Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                             : postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                             : postgres=CTc/postgres
(3 rows)

linux:

lsb_release -a
LSB Version:    :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 5.7 (Final)
Release:    5.7
Codename:   Final

auch:

ps -ef | grep post

user   25055 25032  0 11:13 pts/1    00:00:00 grep post
postgres 32104     1  0 Jan20 ?        00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data

Gibt es kein Benutzer-pcore in /etc/passwd
Könnte dies das problem sein, dass postgresql erwartet eins-zu-eins Zuordnung zwischen linux-Benutzer-und postgresql-Benutzer ?

Ich versuche einen Benutzer erstellen, wenn dieser Fehler Auftritt:

# Database imports
import pgdb as psql

# This will create the 'pcore' user using `su` to run the
# command as the postgres system user
def createPsqlPcoreUser(new_pass):
    print "Creating 'pcore' PostgreSQL user...",
    sys.stdout.flush()
    cmd_list = ['su', '-', 'postgres', '-c','psql --host=%s -c '\
        '"CREATE USER pcore WITH PASSWORD \'%s\' CREATEDB"' % \
        (PSQL_SOCKET_PATH, new_pass)]
    p1 = subprocess.Popen(cmd_list,
        stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    p1.wait()
    print p1.communicate()[0]

Zusätzlich:

 sudo -u postgres createuser pcore -P
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) y
createuser: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[root@localhost pcore]# service postgresql status
postmaster (pid 28901 28900 28899 28898 28896 28894) is running...
[root@localhost pcore]# ps -ef | grep post
postgres 28894     1  0 00:21 ?        00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres 28896 28894  0 00:21 ?        00:00:00 postgres: logger process                          
postgres 28898 28894  0 00:21 ?        00:00:00 postgres: writer process                          
postgres 28899 28894  0 00:21 ?        00:00:00 postgres: wal writer process                      
postgres 28900 28894  0 00:21 ?        00:00:00 postgres: autovacuum launcher process             
postgres 28901 28894  0 00:21 ?        00:00:00 postgres: stats collector process   
  • Der erste Fehler: eine Anwendung versucht, eine (postgres) Benutzer, kann aber nicht verbinden. Der zweite Fehler ist: die app versucht zu verbinden, da eine nicht-vorhandene Benutzer.
  • Was hast du ausgeführt, dass produziert den Fehler ?
  • angehängt in Frage zu stellen, aufgrund fehlender Formatierungen in Kommentar-Abschnitt
  • ich denke, das hat zu tun mit PGDATA , nicht in dem erwarteten Platz
  • Es gibt eine offensichtliche Diskrepanz zwischen der ersten aufgelisteten Fehler und der Letzte Fehler (unter zusätzlich). Dies zeigt, dass es beim Auffinden der Unix-socket. Die erste ist auf der Suche nach einer socket - /var/run/postgresql/.s.PGSQL.5432 und die zweite /tmp/.s.PGSQL.5432. Prüfen Sie, wo diese zu finden sein soll, indem Sie das Feld "unix_socket_directory" in postgresql.conf (wahrscheinlich unter /etc/postgresql/<version>/<cluster>/). Dann überprüfen Sie es eigentlich gibt, indem eine ls -lA socket_dir.
InformationsquelleAutor kamal | 2012-01-22
Schreibe einen Kommentar