postgresql – 主厨ENV设置不起作用
发布时间:2020-12-13 15:56:50 所属栏目:百科 来源:网络整理
导读:我正在尝试使用Chef solo在Vagrant盒子上设置 postgresql并遇到一些问题.我需要默认的postgres编码/语言环境为UTF8.默认情况下,exact64 Ubuntu框的语言环境设置为“C”,因此postgres使用LATIN1进行编码.这是我到目前为止所做的: 我有一个厨师食谱,通过执行
我正在尝试使用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获得了这一切. 解决方法
我发现对我有用的解决方案是在bootstrap shell脚本中,或者作为内联shell,在运行任何配方之前将/etc/default/lang.sh复制到该框. (所以应该在框定义后在Vagrant文??件中完成第一件事)
郎文件: export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 从这里开始,数据库应该使用UTF-8编码进行设置.希望这有帮助,因为我花了几天时间寻找解决方案,并提出各种讨论中的点点滴滴,但意识到问题是设置值的时机… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |