Discussion:
New DB cluster.
Ron Watkins
2018-02-22 18:21:15 UTC
Permalink
I finally got postgresql working on the host.

Next, I read a web-site which said to use a different directory for your
postgres database, you would first remove the old directory then run the
init commands to create a new cluster. However, when I tried that I ran into
a problem.

Now im out of action again with no database and no server running.



***@localhost ~$ pg_ctl initdb -D /pgsql/data

The files belonging to this database system will be owned by user
"postgres".

This user must also own the server process.



The database cluster will be initialized with locale "en_US.UTF-8".

The default database encoding has accordingly been set to "UTF8".

The default text search configuration will be set to "english".



Data page checksums are disabled.



creating directory /pgsql/data ... ok

creating subdirectories ... ok

selecting default max_connections ... 100

selecting default shared_buffers ... 128MB

selecting dynamic shared memory implementation ... posix

creating configuration files ... ok

running bootstrap script ... ok

performing post-bootstrap initialization ... ok

syncing data to disk ... ok



WARNING: enabling "trust" authentication for local connections

You can change this by editing pg_hba.conf or using the option -A, or

--auth-local and --auth-host, the next time you run initdb.



Success. You can now start the database server using:



/usr/pgsql-10/bin/pg_ctl -D /pgsql/data -l logfile start



***@localhost ~$ pg_ctl -D /pgsql/data -l logfile start

waiting for server to start.... stopped waiting

pg_ctl: could not start server

Examine the log output.

***@localhost ~$ cat logfile

2018-02-22 11:18:51.702 MST [3113] LOG: listening on IPv6 address "::1",
port 5432

2018-02-22 11:18:51.702 MST [3113] LOG: listening on IPv4 address
"127.0.0.1", port 5432

2018-02-22 11:18:51.703 MST [3113] FATAL: could not create lock file
"/var/run/postgresql/.s.PGSQL.5432.lock": No such file or dire
ctory

2018-02-22 11:18:51.703 MST [3113] LOG: database system is shut down
Laurenz Albe
2018-02-23 07:18:52 UTC
Permalink
2018-02-22 11:18:51.703 MST [3113] FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": No such file or directory
Either the directory does not exist, or the operating system user as which
you started PostgreSQL does not have permissions on the file.

You can either:

# mkdir -m 0755 /var/run/postgresql
# chown postgres:postgres /var/run/postgresql

or edit postgresql.conf and change the parameter unix_socket_directories.

Yours,
Laurenz Albe

Loading...