由于postgresql-common错误,Postgresql服务器安装失败
在Ubuntu 12.04中安装postgresql服务器失败。 它似乎是由于postgresql-common软件包的配置不完整。 我清除了所有与postgresql相关的软件包,试图只重新安装postgresql-common软件包。 仍然出现错误。
错误是:
$ sudo apt-get install postgresql-common Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: postgresql-common 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/96.5 kB of archives. After this operation, 442 kB of additional disk space will be used. Preconfiguring packages ... Selecting previously unselected package postgresql-common. (Reading database ... 176855 files and directories currently installed.) Unpacking postgresql-common (from .../postgresql-common_129ubuntu1_all.deb) ... Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common' Processing triggers for ureadahead ... Processing triggers for man-db ... Setting up postgresql-common (129ubuntu1) ... adduser: The user `postgres' does not exist. dpkg: error processing postgresql-common (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: postgresql-common E: Sub-process /usr/bin/dpkg returned an error code (1)
知道如何克服/解决这个问题吗?
注意:
- 我更新并再次尝试,发生了同样的错误。
- 我清除了postgresql相关的软件包并尝试安装
postgresql-8.4
和postgresql-9.1
,在这两种情况下,由于对postgresql-common
软件包的依赖,它失败了。
问题是postgres
用户没有被创建。(看起来像包配置脚本的错误,但不确定)然后我使用以下方法手动创建用户:
sudo useradd -r -s /bin/false postgres
上面的命令是创建一个没有主目录的用户。( 礼貌 )
之后我尝试再次安装,它成功了,没有任何问题。
注意:
Ubuntu IRC频道的一些人帮助我解决了这个问题。
更新:
重启后postgresql
服务器无法访问,所以试图重启postgresql
服务器,并得到以下错误:
$ sudo service postgresql restart [sudo] password for username: * Restarting PostgreSQL 8.4 database server * The PostgreSQL server failed to start. Please check the log output: 2014-04-03 09:54:22 IST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied [fail]
通过编辑postgresql.conf
文件解决了这个问题。 我们必须查找以unix_socket_directory
开头的行并将其更改为如下所示:
unix_socket_directory='/tmp'
现在使用以下命令启动postgresql服务器:
sudo service postgresql start
问题是因为
Ubuntu中锁定文件的默认目录已更改为/ var / run / postgresql,这不是全局可写的。 但是,只是更改目录的写权限不起作用; 它们在默认初始化脚本运行时重置。
礼貌: http : //eclecticquill.com/2013/02/26/postgresql-fails-to-start-on-ubuntu-12-10/
从这个链接获得更多信息:
但是,如果您尝试运行本地用户拥有的PostgreSQL服务器实例,则需要确保拥有PostgreSQL服务器进程的用户可以写入unix套接字目录。 尝试:
unix_socket_directory = ‘/ TMP’
简而言之:
我们必须这样做,因为我们手动创建了postgres
用户。