Não é possível conectar-se ao PostgreSQL

2

Eu tinha o PostgreSQL 9.3 funcionando bem, mas quando tentei atualizar para o 9.5 comecei a encontrar erros. Então, eu removi o Postgres do meu sistema seguindo a primeira resposta desta pergunta .

Então eu instalei o postgres 9.5 usando

apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-doc-9.5

Tudo bem baixado. Estes são os logs:

sudo apt-get install postgresql-9.5 postgresql-contrib-9.5 postgresql-doc-9.5


Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libntdb1 libossp-uuid16 python-ntdb
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  postgresql-client-9.5 postgresql-client-common postgresql-common
Suggested packages:
  locales-all libdbd-pg-perl
The following NEW packages will be installed:
  postgresql-9.5 postgresql-client-9.5 postgresql-client-common
  postgresql-common postgresql-contrib-9.5 postgresql-doc-9.5
0 upgraded, 6 newly installed, 0 to remove and 14 not upgraded.
Need to get 1,867 kB/7,685 kB of archives.
After this operation, 40.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg/main postgresql-doc-9.5 all 9.5.3-1.pgdg14.04+1 [1,867 kB]
Fetched 1,867 kB in 15s (118 kB/s)                                             
Preconfiguring packages ...
Selecting previously unselected package postgresql-client-common.
(Reading database ... 219906 files and directories currently installed.)
Preparing to unpack .../postgresql-client-common_174.pgdg14.04+1_all.deb ...
Unpacking postgresql-client-common (174.pgdg14.04+1) ...
Selecting previously unselected package postgresql-client-9.5.
Preparing to unpack .../postgresql-client-9.5_9.5.3-1.pgdg14.04+1_amd64.deb ...
Unpacking postgresql-client-9.5 (9.5.3-1.pgdg14.04+1) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_174.pgdg14.04+1_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (174.pgdg14.04+1) ...
Selecting previously unselected package postgresql-9.5.
Preparing to unpack .../postgresql-9.5_9.5.3-1.pgdg14.04+1_amd64.deb ...
Unpacking postgresql-9.5 (9.5.3-1.pgdg14.04+1) ...
Selecting previously unselected package postgresql-contrib-9.5.
Preparing to unpack .../postgresql-contrib-9.5_9.5.3-1.pgdg14.04+1_amd64.deb ...
Unpacking postgresql-contrib-9.5 (9.5.3-1.pgdg14.04+1) ...
Selecting previously unselected package postgresql-doc-9.5.
Preparing to unpack .../postgresql-doc-9.5_9.5.3-1.pgdg14.04+1_all.deb ...
Unpacking postgresql-doc-9.5 (9.5.3-1.pgdg14.04+1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for doc-base (0.10.5) ...
Processing 1 added doc-base file...
Setting up postgresql-client-common (174.pgdg14.04+1) ...
Setting up postgresql-client-9.5 (9.5.3-1.pgdg14.04+1) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (174.pgdg14.04+1) ...
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
  en_us
Removing obsolete dictionary files:
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-doc-9.5 (9.5.3-1.pgdg14.04+1) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man3/SPI_connect.3.gz to provide /usr/share/man/man3/SPI_connect.3.gz (SPI_connect.3.gz) in auto mode
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-9.5 (9.5.3-1.pgdg14.04+1) ...
Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale en_IN
  socket /var/run/postgresql
  port   5432
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
 * Starting PostgreSQL 9.5 database server                                                                                              [ OK ] 
Setting up postgresql-contrib-9.5 (9.5.3-1.pgdg14.04+1) ...

Agora, quando tentei executar o comando rails

bundle exec rake db:setup

Eu recebi o seguinte erro

rake aborted!
PG::ConnectionBad: 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.5433"?

Na verdade, se eu tentar conectar através da interface do usuário, recebo o mesmo erro.

Este é o mesmo problema que eu estava enfrentando quando tentei atualizar para o 9.5 inicialmente. Eu tenho lutado com isso por 5 horas. Qualquer ajuda seria incrível.

Muito obrigado antecipadamente:)

    
por NiroshaDogra 23.05.2016 / 15:21

1 resposta

0

Observe que o número da porta é 5433 em seu erro, mas a instalação está usando 5432. Quando um segundo postgres é instalado, ele verifica se há uma instalação em execução, consulta sua porta e usa a próxima. Isso permite que você tenha as duas instalações em execução simultaneamente, para permitir a validação da verificação antes de desativar a antiga. Você pode editar manualmente o arquivo /etc/postgresql/9.5/main/postgresql.conf e mudar a porta para o que você quiser usar. Eu não sei o que o rake faz, talvez tenha uma porta em um arquivo de configuração também.

Reconfigure / reinicie o rake para fazer com que ele use a porta 5432, já que está falhando na porta 5433.

    
por ubfan1 23.05.2016 / 17:32