我正在尝试使用Chef solo在Vagrant盒子上设置
postgresql并遇到一些问题.我需要默认的postgres编码/语言环境为UTF8.默认情况下,exact64 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获得了这一切.
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。