在 12.10 中启动 postgresql 时出错

在 12.10 中启动 postgresql 时出错
The following NEW packages will be installed:
  libpq5 postgresql-9.1 postgresql-client-9.1 postgresql-client-common postgresql-common
0 upgraded, 5 newly installed, 0 to remove and 2 not upgraded.
Need to get 0 B/3,389 kB of archives.
After this operation, 15.8 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Preconfiguring packages ...
Selecting previously unselected package libpq5.
(Reading database ... 58862 files and directories currently installed.)
Unpacking libpq5 (from .../libpq5_9.1.9-0ubuntu12.10_amd64.deb) ...
Selecting previously unselected package postgresql-client-common.
Unpacking postgresql-client-common (from .../postgresql-client-common_136_all.deb) ...
Selecting previously unselected package postgresql-client-9.1.
Unpacking postgresql-client-9.1 (from .../postgresql-client-9.1_9.1.9-0ubuntu12.10_amd64.deb) ...
Selecting previously unselected package postgresql-common.
Unpacking postgresql-common (from .../postgresql-common_136_all.deb) ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Selecting previously unselected package postgresql-9.1.
Unpacking postgresql-9.1 (from .../postgresql-9.1_9.1.9-0ubuntu12.10_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up libpq5 (9.1.9-0ubuntu12.10) ...
Setting up postgresql-client-common (136) ...
Setting up postgresql-client-9.1 (9.1.9-0ubuntu12.10) ...
Setting up postgresql-common (136) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Processing triggers for ureadahead ...
Setting up postgresql-9.1 (9.1.9-0ubuntu12.10) ...
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: using /usr/share/postgresql/9.1/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
 * Starting PostgreSQL 9.1 database server                                                                                              * Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
Use of uninitialized value $logsize in numeric gt (>) at /usr/bin/pg_ctlcluster line 215.
The PostgreSQL server failed to start. Please check the log output.
                                                                                                                                [fail]
invoke-rc.d: initscript postgresql, action "start" failed.
dpkg: error processing postgresql-9.1 (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
 postgresql-9.1
E: Sub-process /usr/bin/dpkg returned an error code (1)

以下是 的输出uname -a

Linux $hostname 3.5.0-36-generic #57-Ubuntu SMP Wed Jun 19 15:10:49 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

它是一个 Amazon AWS EC2 服务器 - m1.small

从查看/usr/bin/pg_ctlcluster(perl 脚本)来看,它正在尝试读取/etc/postgresql/9.1/main/pg_ctl.conf以查找日志目录,但不知何故获取了一个无效值。我不明白为什么这会成为全新安装的问题。

任何指点都将不胜感激。

谢谢,

答案1

今天更新我们的开发服务器后,我遇到了完全相同的错误。我尝试了很多方法,包括向pg_ctlcluster脚本添加打印以跟踪正在发生的事情($logsize最终被设置为未初始化的值,并且在我的例子中套接字本身从未创建过)以及完全清除/重新安装,但什么也没起作用。

我与具有相同操作系统(我的情况是 12.04 LTS)的生产服务器比较了权限,并且/var/run/postgres其他lib目录都匹配,因此无法立即看到任何内容。同样,指定的日志文件pg_ctlcluster归 postgres 所有,并且看起来也不错。

我茫然地尝试将日志文件设置为我知道肯定可写且可访问的目录,即/tmp通过如下方式修改/etc/postgresql/9.1/main/pg_ctl.conf文件:

# Automatic pg_ctl configuration
# This configuration file contains cluster specific options to be passed to
# pg_ctl(1).

pg_ctl_options = '-l /tmp/pg.log'

然后 Postgres 就可以启动了,我就可以连接并创建角色,配置也可以通过。我还不确定是什么原因造成的——我猜是权限问题不知何故。很高兴终于可以继续了——我只需要做一些测试,预计只需要花一个小时!如果我找出原因,我会更新——我只看到了一些参考资料(谷歌搜索得到了大约 6 个结果全部的对于特定$logsize错误),Debian、Ubuntu 和 Linux Mint 之间有相似之处。但令我感到奇怪的是,没有更多人遇到过这种情况 - 这让我认为这是一种相当特殊和罕见的情况。

编辑可能相关 我之前也很难让 solr 工作。这也与日志文件未被写入有关。检查它是否使用符号链接指向日志目录 - 这很好解决,但由于某种原因service无法启动它。我删除了符号链接,log在其中创建了一个文件夹/var/lib/tomcat6,然后 tomcat 就可以启动了。我想知道这是否与日志文件由符号链接指定并且由于某种原因无法跟踪它有关。

答案2

最终的解决方案很简单:由于管理错误,postgresql 没有对其自身日志的读取权限。

这行代码pg_ctlcluster负责设置$logsize

$logsize = (stat $info{'logfile'})[7];

让我大吃一惊的是上面有一行字:

$logsize = 0;

因此,由于不理解 Perl 中变量的语义(现在我仍然不理解),我假设像这样的错误消息表明发生了一些更奇怪的事情Use of uninitialized value

使其成为postgres日志目录和文件的所有者就成功了。

相关内容