1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 >Creating a Database Cluster</TITLE
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
15 TITLE="Server Run-time Environment"
16 HREF="runtime.html"><LINK
18 TITLE="Server Run-time Environment"
19 HREF="runtime.html"><LINK
21 TITLE="Starting the Database Server"
22 HREF="postmaster-start.html"><LINK
25 HREF="stylesheet.css"><META
27 CONTENT="2003-12-22T03:48:47"></HEAD
33 SUMMARY="Header navigation table"
43 >PostgreSQL 7.4.1 Documentation</TH
67 >Chapter 16. Server Run-time Environment</TD
81 HREF="postmaster-start.html"
95 NAME="CREATING-CLUSTER"
96 >16.2. Creating a Database Cluster</A
105 > Before you can do anything, you must initialize a database storage
106 area on disk. We call this a <I
113 > uses the term catalog cluster instead.) A
114 database cluster is a collection of databases is accessible by a
115 single instance of a running database server. After initialization, a
116 database cluster will contain a database named
120 >. As the name suggests, this will be used
121 as a template for subsequently created databases; it should not be
122 used for actual work. (See <A
123 HREF="managing-databases.html"
126 about creating databases.)
129 > In file system terms, a database cluster will be a single directory
130 under which all data will be stored. We call this the <I
138 completely up to you where you choose to store your data. There is no
139 default, although locations such as
142 >/usr/local/pgsql/data</TT
146 >/var/lib/pgsql/data</TT
147 > are popular. To initialize a
148 database cluster, use the command <TT
159 file system location of your database system is indicated by the
163 > option, for example
171 >initdb -D /usr/local/pgsql/data</KBD
174 Note that you must execute this command while logged into the
178 > user account, which is
179 described in the previous section.
188 > As an alternative to the <VAR
191 > option, you can set
192 the environment variable <TT
207 > will attempt to create the directory you
208 specify if it does not already exist. It is likely that it will not
209 have the permission to do so (if you followed our advice and created
210 an unprivileged account). In that case you should create the
211 directory yourself (as root) and change the owner to be the
215 > user. Here is how this might
221 >mkdir /usr/local/pgsql/data</KBD
225 >chown postgres /usr/local/pgsql/data</KBD
233 >initdb -D /usr/local/pgsql/data</KBD
241 > will refuse to run if the data directory
242 looks like it it has already been initialized.</P
244 > Because the data directory contains all the data stored in the
245 database, it is essential that it be secured from unauthorized
249 > therefore revokes access
250 permissions from everyone but the
257 > However, while the directory contents are secure, the default
258 client authentication setup allows any local user to connect to the
259 database and even become the database superuser. If you do not
260 trust other local users, we recommend you use
271 > option to assign a password to the
272 database superuser.<A
299 > you start the server for the first time. (Other
300 approaches include using <TT
304 file system permissions to restrict connections. See <A
305 HREF="client-authentication.html"
307 > for more information.)
313 > also initializes the default
317 > for the database cluster.
318 Normally, it will just take the locale settings in the environment
319 and apply them to the initialized database. It is possible to
320 specify a different locale for the database; more information about
321 that can be found in <A
322 HREF="charset.html#LOCALE"
324 >. The sort order used
325 within a particular database cluster is set by
329 > and cannot be changed later, short of
330 dumping all data, rerunning <TT
334 reloading the data. So it's important to make this choice correctly
343 SUMMARY="Footer navigation table"
372 HREF="postmaster-start.html"
382 >Server Run-time Environment</TD
396 >Starting the Database Server</TD