Postgres file owner change causes Exception Handling

Source: Internet
Author: User
Postgres file owner changes cause exception handling on a local test machine. A colleague changed the owner of all files in the root directory to root (chown-Rroot: root, this is a pitfall and dangerous operation). The S database is installed by other users and there are other applications above. Here we will briefly describe the restoration process of the postgres database.

Postgres file owner change causes Exception Handling on a local test machine. A colleague changed the owner of all files in the root directory to root (chown-R root: root /, this is a pitfall and dangerous operation). The S database is installed by other users and there are other applications above. Here we will briefly describe the restoration process of the postgres database.

Postgres file owner change causes Exception Handling

On a local testing machine, my colleagues changed the owner of all the files in the root directory to root (chown-R root: root/, This is a pitfall and dangerous operation ), the S database is installed by other users. There are other applications above. Here we will briefly describe the restoration process of the postgres database.

1. Environment

OS: CentOS 6.2

DB: ipvs 9.2.4

2. Exceptions

A. The database process is gone.

B. Logs

[Postgresql @ localhost pg_log] $ tail-f postgresql-2013-05-06_000000.csv

17:11:21. 923 CST, "test", "testdb", 664, "172.25.10.1: 13906", 51876c10. 298, 3, "idle", 16:38:40 CST, 37/0, 0, WARNING, 57P02, "terminating connection because of crash of another server process ", "The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly implements upted shared memory. "," In a moment you shoshould be able to reconnect to the database and repeat your command. ",,,,,,,""

17:11:21. 921 CST, "test", "testdb", 2633, "172.25.10.88: 45681", 5187730e. a49, 3, "idle", 17:08:30 CST, 14/0, 0, WARNING, 57P02, "terminating connection because of crash of another server process ", "The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly implements upted shared memory. "," In a moment you shoshould be able to reconnect to the database and repeat your command. ",,,,,,,""

.....

17:11:21. 926 CST, 24842, 5162b7b7. 610a, 8, 20:27:35 CST, 0, LOG, 00000, "all server processes terminated; reinitializing ",,,,,,,,,""

17:11:21. 955 CST, 24842, 5162b7b7. 610a, 9, 20:27:35 CST, 0, LOG, 42501, "cocould not open file" "postmaster. pid "": Permission denied ",,,,,,,,,""

17:11:22. 011 CST, 24842, 5162b7b7. 610a, 10, 20:27:35 CST, 0, PANIC, 42501, "cocould not open control file" "global/pg_control "": permission denied ",,,,,,,,,""

3. Recovery Process

A. First Change the user permission

[Root @ localhost ~] # Chown-R postgresql: postgresql/var/postgres

[Root @ localhost ~] # Chown-R postgresql: postgresql/data/pgdata

B. Restart

[Postgresql @ localhost pg_log] $ pg_start

Server starting

[Postgresql @ localhost pg_log] $ FATAL: cocould not open lock file "/tmp/. s. PGSQL. lock": Permission denied

Cocould not open control file "" global/pg_control "": Permission denied

The database still cannot be restarted, but the following information is provided. The socket File Permission under tmp is insufficient.

Return to the root user for authorization, and then start

[Root @ localhost home] # cd/tmp

[Root @ localhost tmp] # ls-a. s. PGSQL *

. S. PGSQL.5432. s. PGSQL.5432.lock

[Root @ localhost tmp] # chown postgresql: postgresql./. s. PGSQL *

[Root @ localhost tmp] # su-postgresql

[Postgresql @ localhost ~] $ Pg_start

-- The above error is still reported. Because the socket file is a local communication file, it should be deleted first and then start the database. Normally, It's okay not to delete it.

[Root @ localhost tmp] # rm-f./. s. PGSQL *

[Postgresql @ localhost ~] $ Pg_start

Server starting

[Postgresql @ localhost ~] $ LOG: cocould not bind Unix socket: Address already in use

HINT: Is another postmaster already running on port 5432? If not, remove socket file "/tmp/. s. PGSQL.5432" and retry.

WARNING: cocould not create Unix-domain socket

C. login check

[Postgresql @ localhost ~] $ Psql

Psql: cocould not connect to server: No such file or directory

Is the server running locally and accepting

Connections on Unix domain socket "/tmp/. s. PGSQL.5432 "?

[Postgresql @ localhost ~] $ Psql-h 192.168.10.38

Password:

Psql (9.2.4)

Type "help" for help.

Postgres = # \ q

After checking that the socket file under tmp was not generated during startup, psql directly reports an error. If you want psql to log on directly and restart the database, the socket file will be generated as the server starts.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.