patternsqlMinor
Starting postgresql service and specifying data directory
Viewed 0 times
postgresqlstartingspecifyingdirectoryserviceanddata
Problem
I have recently installed pg 8.4 on Ubuntu 10.0.4 using apt-get install.
It installed pg as a service which starts ehenever the machine starts. However I have created a db cluster in a specific location that I want postgres to use.
This is the command line output of how I created the cluster:
Now, I try to start the postgresql service:
Here is the command line outpu
It installed pg as a service which starts ehenever the machine starts. However I have created a db cluster in a specific location that I want postgres to use.
This is the command line output of how I created the cluster:
username@jupiter:~$ sudo /usr/lib/postgresql/8.4/bin/initdb --encoding=UTF8 --pgdata=/mydata/pgdbdata/
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.
username@jupiter:~$ /usr/lib/postgresql/8.4/bin/initdb --encoding=UTF8 --pgdata=/mydata/pgdbdata/
The files belonging to this database system will be owned by user "username".
This user must also own the server process.
The database cluster will be initialized with locale en_US.utf8.
The default text search configuration will be set to "english".
fixing permissions on existing directory /mydata/pgdbdata ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 24MB
creating configuration files ... ok
creating template1 database in /mydata/pgdbdata/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
/usr/lib/postgresql/8.4/bin/postgres -D /mydata/pgdbdata
or
/usr/lib/postgresql/8.4/bin/pg_ctl -D /mydata/pgdbdata -l logfile start
username@jupiter:~$Now, I try to start the postgresql service:
Here is the command line outpu
Solution
There error is telling ... The problem is that you ran initdb as your local login, but I'm pretty that your login (
Then you can
Also, as Catcall mentioned, make sure you're using the correct location for your data.
username) doesn't have access to /var/run/postgresql. If you have a clean install, may I recommend that you remove the data directory and start all over, this time by su-ing into the postgres account:username@jupiter:~$ sudo su - postgresThen you can
initdbpostgres@jupiter:~$ /usr/lib/postgresql/8.4/bin/initdb --encoding=UTF8 --pgdata=/mydata/pgdbdata/Also, as Catcall mentioned, make sure you're using the correct location for your data.
Code Snippets
username@jupiter:~$ sudo su - postgrespostgres@jupiter:~$ /usr/lib/postgresql/8.4/bin/initdb --encoding=UTF8 --pgdata=/mydata/pgdbdata/Context
StackExchange Database Administrators Q#19557, answer score: 7
Revisions (0)
No revisions yet.