↑↓ 选择 ↵ 打开 ⌫ 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

不受支持的版本: 7.4 / 7.3 / 7.2 / 7.1 / 7.0 / 6.5 / 6.4
历史版本PostgreSQL 6.4 已于 2003 年 10 月结束社区维护,本页译文保留供仍在使用旧版本的读者参考。新系统请看当前版本手册首页。

initlocation

initlocation — 创建一个辅助的 Postgres 数据库存储区

大纲

initlocation [ --location=altdir | -D altdir ]
    [ --username=name | -u name ]
    [ altdir ]

输入

--location=altdir
-D altdir
altdir

你想让备选数据库放在你的 Unix 文件系统的什么地方? 顶层目录称为 PGDATA 目录,所以 你可能想把你的第一个备选位置指向 PGDATA2。

--username=name
-u name
PGUSER

谁将成为这个数据库存储区的 Unix 文件系统拥有者? Postgres 超级用户是一个 Unix 用户, 他拥有存储数据库系统的所有文件,并且拥有访问它们的 postmaster 和后端进程。 通常,这就是应该运行 initlocation 的用户,他因此将拥有这些目录和文件。

注意

只有 Unix 超级用户才能创建一个由 不是 Postgres 超级用户的用户 拥有的数据库系统。指定一个不是 Postgres 超级用户的用户 可能导致数据库安全和数据完整性问题。更多信息请参阅 PostgreSQL 管理员指南 。

输出

initlocation 将在指定的 位置创建目录。

We are initializing the database area with username postgres (uid=500). This user will own all the files and must also own the server process. Creating Postgres database system directory altdir Creating Postgres database system directory altdir

成功完成。

We are initializing the database area with username postgres (uid=500). This user will own all the files and must also own the server process. Creating Postgres database system directory /usr/local/src/testlocation mkdir: cannot make directory `altdir': Permission denied

你没有写入指定目录区域的文件系统权限。

Valid username not given. You must specify the username for the Postgres superuser for the database system you are initializing, either with the --username option or by default to the USER environment variable.

你指定的用户名不是 Postgres 超级用户。

Can't tell what username to use. You don't have the USER environment variable set to your username and didn't specify the --username option

指定 --username 命令行选项。

描述

initlocation 创建一个新的 Postgres 辅助数据库存储区。 一个辅助存储区包含一棵必需的目录树,并且这些目录上有 正确的文件权限。

创建一个数据库存储区包括创建数据库数据可能 存放的目录。

initlocation 有两类参数。 首先,你可以指定一个环境变量(例如 PGDATA2)。 这个环境变量应当为后端所知,供以后在 CREATE DATABASE/WITH LOCATION 或 createdb -D altdir 中使用。 但是,后端守护进程的环境中必须有这个变量,这 才能成功。 其次,或许可以指定存储区顶层目录的一个显式 绝对路径。但是,第二个 选项只有在 Postgres 安装期间显式启用时 才可用。它通常被禁用, 以减轻安全和数据完整性方面的顾虑。

注意

Postgres 会把 /base/ 追加到指定的路径来创建存储区。

后端要求 WITH LOCATION 的任何全大写且 不含路径分隔符的参数都是环境变量。

用法

要在一个备选位置创建数据库,使用环境变量:

% setenv PGDATA2 /opt/postgres/data

% initlocation PGDATA2
% createdb -D PGDATA2

提交更正

译文有误、术语不当或页面显示问题,请到译文仓库 pgsty/pgdoc 报告译文问题。 英文原文本身的问题,请在当前版本的对应页面向上游反馈;上游不再修订已结束维护的版本。