【发布时间】:2013-10-10 07:21:09
【问题描述】:
我正在尝试使用 Chef solo 在 Vagrant 盒子上设置 postgresql,但遇到了一些问题。我需要默认的 postgres 编码/语言环境为 UTF8。默认情况下,精确 64 位 Ubuntu 框的语言环境设置为“C”,因此 postgres 使用 LATIN1 进行编码。这是我到目前为止所做的:
我有一个厨师食谱,通过执行以下操作设置区域设置:
template "/etc/profile.d/lang.sh" do
source "lang.sh.erb"
mode "0644"
end
execute "locale-gen" do
command "locale-gen en_US.UTF-8"
end
execute "dpkg-reconfigure-locales" do
command "dpkg-reconfigure locales"
end
lang.sh.erb 的样子:
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
这会正确设置语言环境,但不幸的是它不会修改当前环境。所以我有另一个配方,只是在包含 postgresql 之前设置 ENV
ENV["LANGUAGE"] = ENV["LANG"] = ENV["LC_ALL"] = "en_US.UTF-8"
include_recipe "postgresql::server"
这没有效果。语言环境设置正确:
postgres@precise64:~$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
但是 postgres 在安装时使用了“C”语言环境。
postgres@precise64:~$ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
postgres | postgres | LATIN1 | en_US | en_US |
template0 | postgres | LATIN1 | en_US | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | LATIN1 | en_US | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
为了署名,我从http://www.softr.li/blog/2012/05/22/chef-recipe-to-install-a-postgresql-server-on-a-machine-configured-with-en_us-locales得到了这一切。
【问题讨论】:
-
我发现stackoverflow.com/questions/20815440/… 有点老套,但很有帮助
标签: postgresql ubuntu chef-infra vagrant