Rob*_*ark 11 postgresql ubuntu
我安装了 Postgresql 8.4 和 9.1 版。对于任何给定的 Postgresql 命令,如何指定要运行的命令的特定版本?(例如, psql, pg_dump, pg_ctlcluster, pg_restore, ...)
我的问题是想要做一个 pg_dump 以准备从 8.4 升级到 9.1,我想知道我正在运行哪个 pg_dump 版本。
我在 Ubuntu 10.04 Natty 上运行。
Erw*_*ter 18
您使用的是 Ubuntu,并且显然已经pg_wrapper安装了Martin Pitt 的(从 判断pg_ctlcluster),它由软件包提供postgresql-common并随标准 Debian 软件包一起提供。我在 Debian 上使用相同的。
在 Linux 系统上,which在 shell 中运行以查看实际选择了哪个可执行文件:
postgres@db:~$ which pg_dump
/usr/bin/pg_dump
postgres@db:~$ ls -l /usr/bin/pg_dump
lrwxrwxrwx 1 root root 37 4. Jun 18:57 /usr/bin/pg_dump -> ../share/postgresql-common/pg_wrapper
Run Code Online (Sandbox Code Playgroud)
pg_dump实际上是到 的符号链接pg_wrapper,它为您运行的数据库集群动态选择适当版本的客户端程序pg_dump。我引用的手册页pg_wrapper:
该程序仅作为指向与 /usr/lib/postgresql/version/bin 中的 PostgreSQL 程序相对应的名称的链接运行。它为用户确定配置的集群和数据库,并调用所需程序的适当版本来连接到该集群和数据库,为该命令提供任何指定的选项。
Run Code Online (Sandbox Code Playgroud)The target cluster is selected by the following means, in descending order of precedence: 1. explicit specification with the --cluster option 2. explicit specification with the PGCLUSTER environment variable 3. matching entry in ~/.postgresqlrc (see postgresqlrc(5)), if that file exists 4. matching entry in /etc/postgresql-common/user_clusters (see user_clusters(5)), if that file exists 5. If only one local cluster exists, that one will be selected. 6. If several local clusters exist, the one listening on the default port 5432 will be selected. If none of these rules match, pg_wrapper aborts with an error.
IOW,应该自动选择正确的版本 - 除非您以某种方式搞砸了安装。您始终可以添加--cluster特定的选项。
小智 5
我用
PGCLUSTER=8.4/main pg_dump ...
PGCLUSTER=9.1/main pg_dump ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11628 次 |
| 最近记录: |