Troubleshooting basic PostgreSQL Problems In Linux (RHEL)

Encountered 2 PostgreSQL problems today. One was about the wrong permission to opt/PostgreSQL/9.3/data directory.

[root@server pg_log]# /etc/rc.d/init.d/postgresql-9.3 restart
Restarting PostgreSQL 9.3:
waiting for server to shut down.... done
server stopped
waiting for server to start........ stopped waiting
pg_ctl: could not start server
Examine the log output.
PostgreSQL 9.3 did not start in a timely fashion, please see /opt/PostgreSQL/9.3/data/pg_log/startup.log for details

Examining the log file pointed to below.

FATAL:  data directory "/opt/PostgreSQL/9.3/data" has group or world access

DETAIL:  Permissions should be u=rwx (0700)

So, the trick was to chmod 0700 to opt/PostgreSQL/9.3/data directory 😉 And it solved it 🙂

[root@server pg_log]# /etc/rc.d/init.d/postgresql-9.3 restart
Restarting PostgreSQL 9.3:
pg_ctl: PID file "/opt/PostgreSQL/9.3/data/" does not exist
Is server running?
starting server anyway
waiting for server to start.... done
server started
PostgreSQL 9.3 restarted successfully

Other problem was with a normal user trying to restart PostgreSQL server. So I made below changes to the /etc/sudoers file. 

shashank ALL=(ALL) NOPASSWD: /etc/rc.d/init.d/postgresql-9.3 restart
 shashank ALL=(ALL) NOPASSWD: /etc/rc.d/init.d/postgresql-9.3 start
 shashank ALL=(ALL) NOPASSWD: /etc/rc.d/init.d/postgresql-9.3 stop

prefixing sudo to /etc/rc.d/init.d/postgresql-9.3 restart did the trick 😉

2 thoughts on “Troubleshooting basic PostgreSQL Problems In Linux (RHEL)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s