Postgresql - 无法识别的配置参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41528168/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgresql - unrecognized configuration parameter
提问by Horse O'Houlihan
I exported a postgresql database from an external server, and attempted to import it into my local server but got this error:
我从外部服务器导出了一个 postgresql 数据库,并尝试将其导入到我的本地服务器中,但出现此错误:
unrecognized configuration parameter "idle_in_transaction_session_timeout"
Does this kind of error mean that the two servers are using different versions of postgresql? I looked into that, and the external server is running:
这种错误是否意味着两台服务器使用的是不同版本的postgresql?我调查了一下,外部服务器正在运行:
version
PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
and my server is running:
我的服务器正在运行:
version
PostgreSQL 9.5.5 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609, 64-bit
Pretty much the same thing. Is there a site where you can see all of the valid config parameters for each version? And is there a way to sync up two databases like this, so incompatibilities like this get patched up automatically?
几乎相同的事情。是否有一个站点可以查看每个版本的所有有效配置参数?有没有办法像这样同步两个数据库,以便自动修补这样的不兼容性?
回答by cjungel
According to Postgresql 9.6 Release Notesthe idle_in_transaction_session_timeout
parameter was introduced in version 9.6.
根据Postgresql 9.6 发行说明,该idle_in_transaction_session_timeout
参数是在 9.6 版中引入的。
E.2.3.1.10. Server Configuration
Allow sessions to be terminated automatically if they are in idle-in-transaction state for too long (Vik Fearing)
This behavior is controlled by the new configuration parameter idle_in_transaction_session_timeout. It can be useful to prevent forgotten transactions from holding locks or preventing vacuum cleanup for too long.
E.2.3.1.10。服务器配置
如果会话处于空闲事务状态太长时间,则允许会话自动终止(Vik Fearing)
此行为由新配置参数 idle_in_transaction_session_timeout 控制。防止被遗忘的事务持有锁或防止真空清理太久是很有用的。
Since you are using version 9.5 on the server, the parameter is not recognized.
由于您在服务器上使用的是 9.5 版,因此无法识别该参数。
It's possible that you used version 9.6 of the Postgresql client to export data from the the source 9.5 server and the parameter was introduced in the dump file. If this was the case I would recommend using a 9.5 client version to export and import the data.
您可能使用 9.6 版的 Postgresql 客户端从源 9.5 服务器导出数据,并且在转储文件中引入了该参数。如果是这种情况,我建议使用 9.5 客户端版本来导出和导入数据。
回答by Travis Stevens
The accepted answer is the way to go, but if for some reason you can not upgrade version, here is a workaround.
接受的答案是要走的路,但如果由于某种原因您无法升级版本,这里有一个解决方法。
- Export using plain text. You probably want to use compression too.
pg_dump -F c -Z 9 dbname > file.zip
- Before import, we need to remove the offending parameter. To do that we can use zcat and grep.
zcat file.zip | grep -vw "idle_in_transaction_session_timeout" | psql -d newdb
- 使用纯文本导出。您可能也想使用压缩。
pg_dump -F c -Z 9 dbname > file.zip
- 在导入之前,我们需要删除有问题的参数。为此,我们可以使用 zcat 和 grep。
zcat file.zip | grep -vw "idle_in_transaction_session_timeout" | psql -d newdb
Note that there are drawbacks using psql instead of pg_import. For instance, one can not use the -j to import concurrently.
请注意,使用 psql 而不是 pg_import 有一些缺点。例如,不能同时使用-j 导入。