postgresql 安装损坏

postgresql 安装损坏

我于 25 日按照 (help.ubuntu.com/community/PostgreSQL) 上的说明使用以下命令安装了 postgresql

sudo apt-get install postgres postgresql-contrib

一切运行正常。然后在 27 日,我按照另一个教程安装了 postgres-xc,之后出现了错误“致命错误:未找到 postgres 角色”。

我的安装日志:

2015-07-25 18:11:40 install postgresql-contrib-9.3:amd64 <none> 9.3.9-0ubuntu0.14.04
2015-07-25 18:11:42 install postgresql-contrib:all <none>    9.3+154ubuntu1
2015-07-25 18:15:42 install pgadmin3-data:all <none> 1.18.1-2
2015-07-25 18:15:44 install pgadmin3:amd64 <none> 1.18.1-2
2015-07-25 18:15:47 install pgagent:amd64 <none> 3.3.0-1
2015-07-27 20:53:45 install postgres-xc-client:amd64 <none> 1.1-2ubuntu2
2015-07-27 20:54:32 install postgres-xc:amd64 <none> 1.1-2ubuntu2

安装完成后,安装程序建议我运行自动删除功能。以下是已删除文件的日志:

2015-07-27 20:53:25 remove postgresql:all 9.3+154ubuntu1 <none>
2015-07-27 20:53:26 remove postgresql-9.1:amd64 9.1.13-0ubuntu0.13.10 <none>
2015-07-27 20:53:29 remove postgresql-contrib:all 9.3+154ubuntu1 <none>
2015-07-27 20:53:30 remove postgresql-contrib-9.3:amd64 9.3.9-0ubuntu0.14.04 <none>
2015-07-27 20:53:32 remove postgresql-9.3:amd64 9.3.9-0ubuntu0.14.04 <none>
2015-07-27 20:53:35 remove postgresql-client:all 9.3+154ubuntu1 <none>
2015-07-27 20:53:35 remove postgresql-client-9.1:amd64 9.1.13-0ubuntu0.13.10 <none>
2015-07-27 20:53:37 remove postgresql-client-9.3:amd64 9.3.9-0ubuntu0.14.04 <none>
2015-07-27 20:53:37 remove postgresql-common:all 154ubuntu1 <none>
2015-07-27 20:53:39 remove postgresql-client-common:all 154ubuntu1 <none>
2015-07-27 20:55:15 remove libossp-uuid16:amd64 1.6.2-1.3ubuntu1 <none>

我使用 apt-get 安装 postgres-xc。请告诉我如何让我的系统重新运行?


尝试了@saji89 的建议如下:

sudo useradd -r -s /bin/false postgres

结果是

ashutosh@ashUbuntu:~$ sudo useradd -r -s /bin/false postgres
[sudo] password for ashutosh: 
useradd: user 'postgres' already exists

尝试重新安装 postgresql 出现以下失败:

sudo apt-get install --reinstall postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgresql : Depends: postgresql-9.3 but it is not going to be installed
 postgresql-contrib : Depends: postgresql-contrib-9.3 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

尝试过链接上的解决方案https://dba.stackexchange.com/questions/61850/after-installing-postgresql-and-postgres-xc-with-apt-get-i-have-psql-but-not-po

上面两行是命令。第一个命令没有输出。第二个命令有输出。但问题仍然存在。

ashutosh@ashUbuntu:~$ sudo updatedb
ashutosh@ashUbuntu:~$ sudo locate initdb
/usr/bin/initdb
/usr/share/locale/cs/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/de/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/es/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/fr/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/it/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/ja/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/ko/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/pl/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/pt_BR/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/ro/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/ru/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/sv/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/tr/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/zh_CN/LC_MESSAGES/initdb-9.2.mo
/usr/share/locale/zh_TW/LC_MESSAGES/initdb-9.2.mo
/usr/share/man/man1/initdb.1.gz
ashutosh@ashUbuntu:~$ 

答案1

使用步骤如何卸载 postgres-x卸载。

然后使用重新安装 postgresql

sudo apt-get install --reinstall postgresql postgresql-contrib

确保检查您的端口号,因为它可能已被更改(在我的情况下它已被更改)。

select *
postgres-# from pg_settings
postgres-# where name = 'port';

另一个引用的链接

相关内容