PgAdmin III,打开服务器状态提供“编码UTF8的无效字节序列”

时间:2022-06-26 12:42:05

I have two Postgres 9.3 servers in synchronous replication.

在同步复制中,我有两个Postgres 9.3服务器。

I had needed to restart the slave in order to load a new archive_cleanup_command in the recovery.conf.

为了在恢复过程中加载一个新的archive_cleanup_command,我需要重新启动这个奴隶。

The server restarted correctly and it's now perfectly in sync with the master server.

服务器重新启动,现在与主服务器完全同步。

But when I open "Server status" panel for the slave server in PgAdmin III (which executable is located on the master server), I get some errors like this:

但是当我在PgAdmin III中为从服务器打开“服务器状态”面板(可执行文件位于主服务器上)时,我得到如下错误:

invalid byte sequence for encoding “UTF8” plus some hex codes

编码“UTF8”和一些十六进制代码的无效字节序列。

PgAdmin III,打开服务器状态提供“编码UTF8的无效字节序列”

It might be because I put a tilde ~ in the archive_cleanup_command, but it didn't worked, then I removed it and the command worked correctly.

这可能是因为我在archive_cleanup_command中放置了一个tilde ~,但是它没有工作,然后我删除了它,命令工作正常。

Maybe that ~ has been written somewhere and it's not a valid char... but I also deleted logs...

也许那个~已经写在某个地方了,它不是一个有效的字符…但我也删除了日志…

Log of the slave server has a lot of lines like the followings:

从服务器的日志中有很多类似如下的行:

2015-02-13 11:11:32 CET ERROR:  invalid byte sequence for encoding “UTF8”: 0xe8 0x20 0x73
2015-02-13 11:11:32 CET STATEMENT:  SELECT pg_file_read('pg_log/postgresql-2015-02-13_111038.log', 0, 50000)

Note that postgresql-2015-02-13_111038.log is the last log, the one from which I got these lines.

注意,postgresql - 2015 - 02年- 13 - _111038。log是最后一个log,我从这里得到这些线。

2 个解决方案

#1


4  

The problem you have is that the locale setting lc_messages is set to an encoding that is different to the encoding of the database(s). As a result, some messages are being written into the log using Windows-1252 encoding, while when you try to use PgAdmin to view the log, it tries to interpret the file using UTF-8. Some of the byte sequences written in the log are not valid UTF-8, leading to the error.

您的问题是设置lc_messages的语言环境设置为与数据库的编码不同的编码。因此,一些消息使用Windows-1252编码被写入到日志中,而当您尝试使用PgAdmin查看日志时,它试图使用UTF-8来解释文件。在日志中写入的一些字节序列不是有效的UTF-8,导致错误。

In fact, the way in which different locales interact in postgresql can result in mixed encodings in the log file. There is a Bug Report on this, but it does not look like it has been resolved.

实际上,在postgresql中不同的地区交互的方式可能导致日志文件中的混合编码。关于这个问题有一个Bug报告,但是它看起来并没有得到解决。

Probably the easiest way to resolve this is to set lc_messages to English_United States.UTF-8.

解决这个问题的最简单方法可能是将lc_messages设置为English_United States.UTF-8。

It would also be preferable to have lc_messages aligned across all of the databases on the server (or at least all using the same encoding).

最好将lc_messages对齐到服务器上的所有数据库(或者至少使用相同的编码)。

Be sure to remove any existing log files as they will already contain the incorrect encoding.

一定要删除任何现有的日志文件,因为它们已经包含了不正确的编码。

#2


0  

It is due to your postgresql.log corrupted as stated in the statement 'select pf_file_read ....'.

这是由于您的postgresql。日志损坏在声明中说“选择pf_file_read ....”。

If you do a "touch" (after a backup of your log perhaps) on you server log, and reconnect, you'll not see this unicode error anymore and thus, you'll be able to use pgadmin III furthermore.

如果您在服务器日志上执行“触摸”(可能是在您的日志备份之后),并且重新连接,您将不再看到这个unicode错误,因此,您将能够使用pgadmin III。

#1


4  

The problem you have is that the locale setting lc_messages is set to an encoding that is different to the encoding of the database(s). As a result, some messages are being written into the log using Windows-1252 encoding, while when you try to use PgAdmin to view the log, it tries to interpret the file using UTF-8. Some of the byte sequences written in the log are not valid UTF-8, leading to the error.

您的问题是设置lc_messages的语言环境设置为与数据库的编码不同的编码。因此,一些消息使用Windows-1252编码被写入到日志中,而当您尝试使用PgAdmin查看日志时,它试图使用UTF-8来解释文件。在日志中写入的一些字节序列不是有效的UTF-8,导致错误。

In fact, the way in which different locales interact in postgresql can result in mixed encodings in the log file. There is a Bug Report on this, but it does not look like it has been resolved.

实际上,在postgresql中不同的地区交互的方式可能导致日志文件中的混合编码。关于这个问题有一个Bug报告,但是它看起来并没有得到解决。

Probably the easiest way to resolve this is to set lc_messages to English_United States.UTF-8.

解决这个问题的最简单方法可能是将lc_messages设置为English_United States.UTF-8。

It would also be preferable to have lc_messages aligned across all of the databases on the server (or at least all using the same encoding).

最好将lc_messages对齐到服务器上的所有数据库(或者至少使用相同的编码)。

Be sure to remove any existing log files as they will already contain the incorrect encoding.

一定要删除任何现有的日志文件,因为它们已经包含了不正确的编码。

#2


0  

It is due to your postgresql.log corrupted as stated in the statement 'select pf_file_read ....'.

这是由于您的postgresql。日志损坏在声明中说“选择pf_file_read ....”。

If you do a "touch" (after a backup of your log perhaps) on you server log, and reconnect, you'll not see this unicode error anymore and thus, you'll be able to use pgadmin III furthermore.

如果您在服务器日志上执行“触摸”(可能是在您的日志备份之后),并且重新连接,您将不再看到这个unicode错误,因此,您将能够使用pgadmin III。