我很惊讶在 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) ...
我以前见过类似的行为,安装程序无法创建默认集群(我认为),因为缺少某些区域设置,但我认为我已经正确设置了这些设置。
在 Ubuntu 14.04 上需要额外的步骤,这是新的(因此是正确的)吗?还是有什么(悄无声息地)坏了?
所有这一切都发生在全新的 DigitalOcean 14.04 VPS 上。
答案1
发生的问题出现在系统区域设置上
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.
第一步使用以下命令配置重置区域设置:
$ sudo dpkg-reconfigure locales
但是 postgresql 无法执行,因为当前 Postgres 安装集群尚未建立。
然后运行命令:
$ sudo pg_createcluster 9.3 main --start
- 注意:我使用版本 postgresql-9.3
接下来使用以下命令运行 postgresql:
$ sudo service postgresql start
## Or
$ sudo /etc/init.d/postgresql start
结果如下
$ sudo service postgresql start
* Starting PostgreSQL 9.3 database server
检查 postgresql 状态是否正在运行
$ sudo service postgresql status
9.3/main (port 5432): online
答案2
今天我在玩 Ubuntu 14.04 时遇到了同样的问题 - 但在我的例子中,我采用了我的 puppet 清单。无论如何,问题是一样的:当我期望找到配置文件时,它却/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
安装结束时:
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) ...
在安装 postgresql 之前用这样的命令修复语言环境后sudo locale-gen ru_RU ru_RU.UTF-8 ru_RU ru_RU.UTF-8
问题就解决了。希望它能在未来帮助别人或帮助我自己。
答案3
用于pg_createcluster version clustername
创建新集群。这将在其中包含名为的文件夹下创建一个名为 version 的文件夹,该/etc/postgresql
文件夹clustername
将包含新集群的数据库配置文件: environment、、、、、。pg_ctl.conf
请将其替换为您喜欢的集群名称。pg_hba.conf
pg_ident.conf
postgresql.conf
start.conf
clustername