Postgresql - 无法识别的配置参数
Postgresql - unrecognized configuration parameter
我从外部服务器导出了一个 postgresql 数据库,并试图将其导入我的本地服务器,但出现了这个错误:
unrecognized configuration parameter "idle_in_transaction_session_timeout"
出现这种错误是不是说明两台服务器使用了不同版本的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
我的服务器是 运行:
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
差不多。是否有一个站点可以让您查看每个版本的所有有效配置参数?有没有办法像这样同步两个数据库,这样不兼容的地方就会自动得到修补?
根据 Postgresql 9.6 Release Notes,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.
由于您在服务器上使用的是9.5版本,因此无法识别该参数。
可能您使用了 9.6 版本的 Postgresql 客户端从源 9.5 服务器导出数据,并且在转储文件中引入了参数。如果是这种情况,我建议使用 9.5 客户端版本来导出和导入数据。
接受的答案是可行的方法,但如果由于某种原因您无法升级版本,这里有一个解决方法。
- 使用纯文本导出。您可能也想使用压缩。
pg_dump -F c -Z 9 dbname > file.zip
- 导入之前,我们需要删除有问题的参数。为此,我们可以使用 zcat 和 grep。
zcat file.zip | grep -vw "idle_in_transaction_session_timeout" | psql -d newdb
请注意,使用 psql 而不是 pg_import 存在一些缺点。例如,不能使用 -j 并发导入。
我从外部服务器导出了一个 postgresql 数据库,并试图将其导入我的本地服务器,但出现了这个错误:
unrecognized configuration parameter "idle_in_transaction_session_timeout"
出现这种错误是不是说明两台服务器使用了不同版本的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
我的服务器是 运行:
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
差不多。是否有一个站点可以让您查看每个版本的所有有效配置参数?有没有办法像这样同步两个数据库,这样不兼容的地方就会自动得到修补?
根据 Postgresql 9.6 Release Notes,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.
由于您在服务器上使用的是9.5版本,因此无法识别该参数。
可能您使用了 9.6 版本的 Postgresql 客户端从源 9.5 服务器导出数据,并且在转储文件中引入了参数。如果是这种情况,我建议使用 9.5 客户端版本来导出和导入数据。
接受的答案是可行的方法,但如果由于某种原因您无法升级版本,这里有一个解决方法。
- 使用纯文本导出。您可能也想使用压缩。
pg_dump -F c -Z 9 dbname > file.zip
- 导入之前,我们需要删除有问题的参数。为此,我们可以使用 zcat 和 grep。
zcat file.zip | grep -vw "idle_in_transaction_session_timeout" | psql -d newdb
请注意,使用 psql 而不是 pg_import 存在一些缺点。例如,不能使用 -j 并发导入。