安装后postgresql(服务器)是否设置主集群?(14.04)

Ivo*_*ijk 7 postgresql cluster 14.04

我很惊讶在 ubuntu 上安装 postgresql 并没有立即给我一个有效的 postgres 服务器设置:它需要额外的步骤:

Setting up postgresql-common (154) ...
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-9.3 (9.3.4-1) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql (9.3+154) ...
Run Code Online (Sandbox Code Playgroud)

我过去见过类似的行为,安装程序无法创建默认集群(我认为),因为缺少某些语言环境设置,但我认为我正确设置了这些设置。

在 Ubuntu 14.04 上需要额外的步骤是新的(因此是正确的)吗?或者有什么东西(悄悄地)坏了?

所有这一切都发生在全新的 DigitalOcean 14.04 VPS 上。

Yud*_*nto 5

出现的问题出现在系统区域

 warning: Please check that your locale settings:
  LANGUAGE = (unset),
  LC_ALL = (unset),
  LC_TIME = "en_US.UTF-8",
  LC_MONETARY = "en_US.UTF-8",
  LC_ADDRESS = "en_US.UTF-8",
  LC_TELEPHONE = "en_US.UTF-8",
  LC_NAME = "en_US.UTF-8",
  LC_MEASUREMENT = "en_US.UTF-8",
  LC_IDENTIFICATION = "en_US.UTF-8",
  LC_NUMERIC = "en_US.UTF-8",
  LC_PAPER = "en_US.UTF-8",
  LANG = "en_US.UTF-8"
     are supported and installed on your system.
Run Code Online (Sandbox Code Playgroud)

使用以下命令配置重置区域设置的第一步:

  $ sudo dpkg-reconfigure locales
Run Code Online (Sandbox Code Playgroud)

但是 postgresql 无法执行,因为当前的 Postgres 安装集群没有制作。

然后运行命令:

  $ sudo pg_createcluster 9.3 main --start
Run Code Online (Sandbox Code Playgroud)
  • 注意:我使用的是 postgresql-9.3 版本

接下来使用以下命令运行 postgresql:

  $ sudo service postgresql start
   ## Or
  $ sudo /etc/init.d/postgresql start
Run Code Online (Sandbox Code Playgroud)

结果如下

  $ sudo service postgresql start
    * Starting PostgreSQL 9.3 database server
Run Code Online (Sandbox Code Playgroud)

检查状态 postgresql 正在运行与否

  $ sudo service postgresql status
    9.3/main (port 5432): online
Run Code Online (Sandbox Code Playgroud)


小智 1

今天我正在使用 Ubuntu 14.04 并面临同样的问题 - 但就我而言,我正在采用我的木偶清单。无论如何,问题是相同的:当我期望在/etc/postgresql/9.3/main/postgresql.conf它下面找到配置文件时丢失了。一段时间后,我发现了问题的根源:由于某种原因,我使用的 Vagrant box 的语言环境(实际上是 ubuntu/trusty64)配置错误,在安装过程中我看到了这样的消息:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_TIME = "ru_RU.UTF-8",
        LC_MONETARY = "ru_RU.UTF-8",
        LC_ADDRESS = "ru_RU.UTF-8",
        LC_TELEPHONE = "ru_RU.UTF-8",
        LC_NAME = "ru_RU.UTF-8",
        LC_MEASUREMENT = "ru_RU.UTF-8",
        LC_IDENTIFICATION = "ru_RU.UTF-8",
        LC_NUMERIC = "ru_RU.UTF-8",
        LC_PAPER = "ru_RU.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Run Code Online (Sandbox Code Playgroud)

并在安装结束时:

Unpacking postgresql (9.3+154) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Setting up libpq5 (9.3.5-0ubuntu0.14.04.1) ...
Setting up postgresql-client-common (154) ...
Setting up postgresql-client-9.3 (9.3.5-0ubuntu0.14.04.1) ...
update-alternatives: using /usr/share/postgresql/9.3/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up ssl-cert (1.0.33) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up postgresql-common (154) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Adding user postgres to group ssl-cert

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Processing triggers for ureadahead (0.100.0-16) ...
Setting up postgresql-9.3 (9.3.5-0ubuntu0.14.04.1) ...
Error: The locale requested by the environment is invalid.
Error: could not create default cluster. Please create it manually with

  pg_createcluster 9.3 main --start

or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
 * No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql (9.3+154) ...
Processing triggers for libc-bin (2.19-0ubuntu6.5) ...
Run Code Online (Sandbox Code Playgroud)

在安装 postgresql 之前使用这样的命令修复区域设置后,sudo locale-gen ru_RU ru_RU.UTF-8 ru_RU ru_RU.UTF-8问题就消失了。希望它能对未来的人或未来的我有所帮助。


小智 0

用于pg_createcluster version clustername创建新集群。这将创建一个名为 version 的文件夹,其中包含一个/etc/postgresql名为的文件夹clustername,该文件夹将包含新集群的数据库配置文件:environment pg_ctl.conf、、、、、、。替换为您首选的集群名称。pg_hba.confpg_ident.confpostgresql.confstart.confclustername