编码UTF8不匹配地区en_US; 所选择的LC_CTYPE设置需要编码LATIN1(encod

2019-07-03 10:36发布

尝试安装OpenNMS的:

/usr/share/opennms/bin/install -l /usr/local/lib -dis

我得到的错误:

错误:编码UTF8不匹配地区en_US详情:所选择的LC_CTYPE设置需要编码LATIN1。

而我不知道如何着手,因为我已经尝试创建数据库几种不同的方式(见下文)。

完整的日志:

==============================================================================
OpenNMS Installer
==============================================================================

Configures PostgreSQL tables, users, and other miscellaneous settings.

- searching for jicmp:
  - trying to load /usr/local/lib/libjicmp.so: NO
  - trying to load /usr/lib/jni/libjicmp.so: OK
- searching for jicmp6:
  - trying to load /usr/local/lib/libjicmp6.so: NO
  - trying to load /usr/lib/jni/libjicmp6.so: OK
- searching for jrrd:
  - trying to load /usr/local/lib/libjrrd.so: NO
  - trying to load /usr/lib/jni/libjrrd.so: NO
  - trying to load /usr/lib/jni/libjrrd.so: NO
  - trying to load /usr/lib/jvm/jdk1.6.0_34/jre/lib/amd64/server/libjrrd.so: NO
  - trying to load /usr/lib/jvm/jdk1.6.0_34/jre/lib/amd64/libjrrd.so: NO
  - trying to load /usr/lib/jvm/jdk1.6.0_34/jre/../lib/amd64/libjrrd.so: NO
  - trying to load /libjrrd.so: NO
  - trying to load /usr/share/opennms/lib/libjrrd.so: NO
  - trying to load /usr/share/opennms/lib/linux64/libjrrd.so: NO
  - trying to load /usr/java/packages/lib/amd64/libjrrd.so: NO
  - trying to load /usr/lib64/libjrrd.so: NO
  - trying to load /lib64/libjrrd.so: NO
  - trying to load /lib/libjrrd.so: NO
  - trying to load /usr/lib/libjrrd.so: NO
  - trying to load /usr/lib/jni/libjrrd.so: NO
  - trying to load /usr/lib/libjrrd.so: NO
  - trying to load /usr/local/lib/libjrrd.so: NO
  - trying to load /opt/NMSjicmp/lib/32/libjrrd.so: NO
  - trying to load /opt/NMSjicmp/lib/64/libjrrd.so: NO
  - trying to load /opt/NMSjicmp6/lib/32/libjrrd.so: NO
  - trying to load /opt/NMSjicmp6/lib/64/libjrrd.so: NO
- Failed to load the optional jrrd library.
  - This error is not fatal, since jrrd is only required for optional features.
  - For more information, see http://www.opennms.org/index.php/jrrd
- using SQL directory... /usr/share/opennms/etc
- using create.sql... /usr/share/opennms/etc/create.sql
* using 'postgres' as the PostgreSQL user for OpenNMS
* using 'opennms' as the PostgreSQL database name for OpenNMS
Exception in thread "main" org.opennms.core.schema.MigrationException: an error occurred creating the OpenNMS database
    at org.opennms.core.schema.Migrator.createDatabase(Migrator.java:428)
    at org.opennms.core.schema.Migrator.prepareDatabase(Migrator.java:444)
    at org.opennms.install.Installer.install(Installer.java:236)
    at org.opennms.install.Installer.main(Installer.java:949)
Caused by: org.postgresql.util.PSQLException: ERROR: encoding UTF8 does not match locale en_US
  Detail: The chosen LC_CTYPE setting requires encoding LATIN1.
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:366)
    at org.opennms.core.schema.Migrator.createDatabase(Migrator.java:425)
    ... 3 more

数据库列表:

   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | LATIN1   | en_US   | en_US | 
 rhq       | rhqadmin | 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
(4 rows)

我已经使用了以下3个initdb的选项,但他们没有工作

/usr/local/pgsql/bin/initdb -E UTF-8 --pgdata=/usr/local/pgsql/data

/usr/local/pgsql/bin/initdb -E LATIN1 --pgdata=/usr/local/pgsql/data

/usr/local/pgsql/bin/initdb -E en_US.UTF8  --pgdata=/usr/local/pgsql/data

另外,我是否需要删除所有数据/usr/local/pgsql/data之前,我使用initdb

附加区域设置命令标准输出:

$区域

LANG=en_US
LANGUAGE=en_US:
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME="en_US"
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=

Answer 1:

感谢您的locale的输出。 OpenNMS的好像是用您的EN_US(非UTF-8)语言环境,以创造的Postgres数据库,这是不对的。 这应该工作:

export LANG=en_US.UTF-8
locale   # confirm that it shows only en_US.UTF-8 for all settings
# finally, run your opennms installer
/usr/share/opennms/bin/install -l /usr/local/lib -dis


Answer 2:

我回答这个问题,因为从计算器没有为我工作。

结合我从做了工作的其他网站两种解决方案(这个答案适用于Ubuntu的服务器12.04和PGSQL 9.1):

创建一个文件:

纳米/etc/profile.d/lang.sh

添加以下

export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

保存

重新启动壳或运行所有出口手动命令在当前shell实例

重新配置这样的编码可以是UTF8([从这里得到它] [1])

sudo su postgres

psql

update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'

  lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;

update pg_database set datistemplate=true where datname='template1';

使用模板1为DB制作。

我希望这有帮助 ;)



Answer 3:

这是发生,因为你的系统设置为使用latin1编码,而不是UTF-8。 您的语言正确设置为en_US,但是编码未设置为UTF-8。 尝试运行以下命令:$

localedef -v -c -i en_US -f UTF-8 en_US.UTF-8

这将设置告诉所有的应用程序被改变(我认为)后,安装使用与Unicode编码的英语。 更多信息可以在这里找到: https://www.linux.com/learn/docs/ldp/790-Unicode-HOWTO#s3

我也有类似的问题,所以我:

  1. 资质净化postresql ...
  2. localedef -v -c -i EN_US -f UTF-8的en_US.UTF-8
  3. 安装资质的postresql ....

然后postregsql知道该为自己使用带有unicode编码英语。

当然,你可以这里描述在每个数据库的基础上做到这一点: http://www.postgresql.org/docs/9.1/static/multibyte.html



Answer 4:

这个工作对我来说:

CREATE DATABASE mydb WITH ENCODING='UTF8' LC_CTYPE='en_US.UTF-8' LC_COLLATE='en_US.UTF-8' OWNER=postgres TEMPLATE=template0 CONNECTION LIMIT=-1;


Answer 5:

变化如此的语言环境和语言与BD了兼容性。

的dpkg-重新配置语言环境

请享用!



Answer 6:

我见到了类似的错误。 旧的数据库LC_CTYPE是UTF-8,但新的一个是面对en_US.UTF-8,我解决问题重新发起数据库之后。

initdb --pgdata=/path/to/postgresql -E utf8

你应该选择正确的-E参数



Answer 7:

我有“同样的问题”,而安装odoo。 原来,在安装之前odoo您必须配置的语言环境

export LC_CTYPE="en_US.UTF-8"
sudo dpkg-reconfigure locales

并用UTF-8则configuler语言环境,但你必须posgres安装之前配置的语言环境。



文章来源: encoding UTF8 does not match locale en_US; the chosen LC_CTYPE setting requires encoding LATIN1