Postgresql 中文操作指南
17.5. Post-Installation Setup #
17.5.1. Shared Libraries #
在某些使用共享库的系统上,您需要告诉系统如何查找新安装的共享库。需要 not 执行此操作的系统包括 FreeBSD、Linux、NetBSD、OpenBSD 和 Solaris。
On some systems with shared libraries you need to tell the system how to find the newly installed shared libraries. The systems on which this is not necessary include FreeBSD, Linux, NetBSD, OpenBSD, and Solaris.
设置共享库搜索路径的方法因平台而异,但使用最广泛的方法是设置环境变量 LD_LIBRARY_PATH,如下所示:对于 Bourne Shell (sh、ksh、bash、zsh):
The method to set the shared library search path varies between platforms, but the most widely-used method is to set the environment variable LD_LIBRARY_PATH like so: In Bourne shells (sh, ksh, bash, zsh):
LD_LIBRARY_PATH=/usr/local/pgsql/lib
export LD_LIBRARY_PATH
或在 csh 或 tcsh 中:
or in csh or tcsh:
setenv LD_LIBRARY_PATH /usr/local/pgsql/lib
将 /usr/local/pgsql/lib 替换为在 Step 1 中将 —libdir 设置为的任意内容。您应该将这些命令放入贝壳启动文件中,例如 /etc/profile 或 ~/.bash_profile。可以通过链接:http://xahlee.info/UnixResource_dir//ldpath.html[http://xahlee.info/UnixResource_dir//ldpath.html] 找到与该方法相关的注意事项的一些有用信息。
Replace /usr/local/pgsql/lib with whatever you set —libdir to in Step 1. You should put these commands into a shell start-up file such as /etc/profile or ~/.bash_profile. Some good information about the caveats associated with this method can be found at http://xahlee.info/UnixResource_dir//ldpath.html.
在某些系统上,最好设置环境变量 LD_RUN_PATH before 构建。
On some systems it might be preferable to set the environment variable LD_RUN_PATH before building.
在 Cygwin 上,将库目录放在 PATH 中或将 .dll 文件移动到 bin 目录中。
On Cygwin, put the library directory in the PATH or move the .dll files into the bin directory.
如有疑问,请参阅您系统的自述文件(可能为 ld.so 或 rld)。如果稍后收到类似这样的消息:
If in doubt, refer to the manual pages of your system (perhaps ld.so or rld). If you later get a message like:
psql: error in loading shared libraries
libpq.so.2.1: cannot open shared object file: No such file or directory
那么此步骤是必需的。只需当时处理即可。
then this step was necessary. Simply take care of it then.
如果你处于 Linux 中并且拥有 root 访问权限,则可以运行:
If you are on Linux and you have root access, you can run:
/sbin/ldconfig /usr/local/pgsql/lib
(或同等目录)以加速运行时链接器查找共享库。有关更多信息,请参阅 ldconfig 的自述文件。在 FreeBSD、NetBSD 和 OpenBSD 上,命令为:
(or equivalent directory) after installation to enable the run-time linker to find the shared libraries faster. Refer to the manual page of ldconfig for more information. On FreeBSD, NetBSD, and OpenBSD the command is:
/sbin/ldconfig -m /usr/local/pgsql/lib
而其他系统没有已知的等效命令。
instead. Other systems are not known to have an equivalent command.
17.5.2. Environment Variables #
如果您安装到 /usr/local/pgsql 中或默认情况下不针对程序搜索的某些其他位置,则应该将 /usr/local/pgsql/bin (或在 Step 1 中将 —bindir 设置为的任意内容)添加到您的 PATH 中。严格地说,这不是必需的,但这将让使用 PostgreSQL 更加方便。
If you installed into /usr/local/pgsql or some other location that is not searched for programs by default, you should add /usr/local/pgsql/bin (or whatever you set —bindir to in Step 1) into your PATH. Strictly speaking, this is not necessary, but it will make the use of PostgreSQL much more convenient.
要做到这一点,将以下内容添加到 shell 启动文件,例如 ~/.bash_profile(或 /etc/profile,如果你想让它影响所有用户):
To do this, add the following to your shell start-up file, such as ~/.bash_profile (or /etc/profile, if you want it to affect all users):
PATH=/usr/local/pgsql/bin:$PATH
export PATH
如果你使用的是 csh 或 tcsh,那么使用此命令:
If you are using csh or tcsh, then use this command:
set path = ( /usr/local/pgsql/bin $path )
要让你的系统找到 man 文档,你需要在 Shell 启动文件中添加如下行,除非你安装在默认情况下搜索的位置:
To enable your system to find the man documentation, you need to add lines like the following to a shell start-up file unless you installed into a location that is searched by default:
MANPATH=/usr/local/pgsql/share/man:$MANPATH
export MANPATH
环境变量 PGHOST 和 PGPORT 向客户端应用程序指定数据库服务器的主机和端口,覆盖已编译的默认值。如果你准备远程运行客户端应用程序,那么计划使用数据库的每个用户都设置 PGHOST 将很方便。然而这不是必须的;设置可以通过命令行选项告知大多数客户端程序。
The environment variables PGHOST and PGPORT specify to client applications the host and port of the database server, overriding the compiled-in defaults. If you are going to run client applications remotely then it is convenient if every user that plans to use the database sets PGHOST. This is not required, however; the settings can be communicated via command line options to most client programs.