thalesrodolfo
Posts: 12
Joined: Sat Jun 20, 2015 9:05 pm

Postgres is not working

Thu Apr 14, 2016 1:19 am

Hi all,

I installed postgresql from repository with eopkg. However, I am not being able to start it
Image

How should I proceed to get this working?

Thank you.

User avatar
Justin
Development Team
Posts: 3617
Joined: Mon Jul 28, 2014 10:42 am
Location: Adelaide, Australia
Contact: Website Google+ Twitter

Re: Postgres is not working

Thu Apr 14, 2016 8:49 am

You need to specify a configuration file as it appears there's no default one. Have a look in /usr/share/postgresql to see if there's a default or sample config file.

thalesrodolfo
Posts: 12
Joined: Sat Jun 20, 2015 9:05 pm

Re: Postgres is not working

Thu Apr 14, 2016 12:05 pm

Hi, Justin

So the directory have these files. It seems like there are a few sample conf files

Image

I tried to use

Code: Select all

postgres --config-file /usr/share/postgresql/postgresql.conf.sample 
But it returns

Code: Select all

FATAL:  --config-file requires a value

User avatar
ikey
Project Founder
Posts: 1581
Joined: Sun Jul 27, 2014 10:42 pm
Location: Ireland
Contact: Website

Re: Postgres is not working

Thu Apr 14, 2016 12:15 pm

Howdy. PostgreSQL will need modifying for the daemon side of things it seems.

I'm not sure this is something typically done by anyone though.
Image

thalesrodolfo
Posts: 12
Joined: Sat Jun 20, 2015 9:05 pm

Re: Postgres is not working

Thu Apr 14, 2016 8:51 pm

:(

Thank you for the reply!

I'll try to use mysql instead then.

thalesrodolfo
Posts: 12
Joined: Sat Jun 20, 2015 9:05 pm

Re: Postgres is not working

Sun Apr 24, 2016 4:02 pm

I managed to make postgres to work :D

If anyone is interested here are the steps:

1 - I uninstalled the eopkg postgres;
2 - Downloaded and installed the graphical installer from postgres site;
3 - I have put it in /opt/Postgres/9.5 and added to path;
4 - Followed the steps described here: http://www.sfentona.net/?p=2756 to set up the pgdata directory;

Now run

Code: Select all

psql -U postgres -h localhost
And it should work now.

sargunster
Posts: 1
Joined: Sat Jun 04, 2016 2:06 am

Re: Postgres is not working

Sat Jun 04, 2016 2:07 am

You can pass the config file like

Code: Select all

postgres --config-file=/path/to/file
not

Code: Select all

postgres --config-file /path/to/file
I haven't been able to get a working config yet though.

User avatar
r4lly99
Posts: 8
Joined: Thu Jul 21, 2016 5:36 am

Re: Postgres is not working

Thu Jul 21, 2016 8:36 am

thalesrodolfo wrote:I managed to make postgres to work :D

If anyone is interested here are the steps:

1 - I uninstalled the eopkg postgres;
2 - Downloaded and installed the graphical installer from postgres site;
3 - I have put it in /opt/Postgres/9.5 and added to path;
4 - Followed the steps described here: http://www.sfentona.net/?p=2756 to set up the pgdata directory;

Now run

Code: Select all

psql -U postgres -h localhost
And it should work now.
Thank mate , step 1-3 , 4. initdb --path data postgres user, 5. running service at step 4 described , 6. install pgadmin3 , complete setup .

Image

gerardo
Posts: 1
Joined: Sat Oct 22, 2016 11:39 pm
Location: Medellín

Re: Postgres is not working

Sat Oct 22, 2016 11:57 pm

So after reading this post I found a solution that works for me:

1. Install PostgreSQL and pgAdmin from repositories
sudo eopkg install postgresql pgadmin3

2. Make a directory for user postgres
sudo mkdir /home/postgres

3. Create the user postgres
sudo useradd postgres

4. Assign password to user postgres
sudo passwd postgres

5. Make the user postgres own the /home/postgres directory (it didn't work for me if I omitted this step)
sudo chown -R postgres:postgres /home/postgres

6. Login to postgres user
sudo su - postgres

7. Create the PostgreSQL database cluster with locale ("es_CO" Spanish for my use)
initdb -D /home /postgres --locale=es_CO

8. Start the PostgreSQL server
pg_ctl -D /home/postgres/ -l logfile start

Now you can login using psql o pgAdmin

PD: Step 6 and 8 must be done every time you boot the machine, I suppose you can write a script for it.

Hope it helps!

jamespotz
Posts: 1
Joined: Fri Nov 25, 2016 4:05 am

Re: Postgres is not working

Thu Dec 08, 2016 5:49 pm

Hi i manage to create a systemd for postgres to run on boot.

Code: Select all

	sudo nano /usr/lib/systemd/system/postgresql.service 

Code: Select all

[Service]
Type=forking

User=postgres
Group=postgres

# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog

# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000
# ... but allow it still to be effective for child processes
# (note that these settings are ignored by Postgres releases before 9.5)
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0

# Maximum number of seconds pg_ctl will wait for postgres to start.  Note that
# PGSTARTTIMEOUT should be less than TimeoutSec value.
Environment=PGSTARTTIMEOUT=270

Environment=PGDATA=/home/postgres/


ExecStart=/usr/bin/pg_ctl start -D ${PGDATA} -s -w -t ${PGSTARTTIMEOUT}
ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -s

# Give a reasonable amount of time for the server to start up/shut down.
# Ideally, the timeout for starting PostgreSQL server should be handled more
# nicely by pg_ctl in ExecStart, so keep its timeout smaller than this value.
TimeoutSec=300

[Install]
WantedBy=multi-user.target
then just run the code below to enable it.

Code: Select all

$ sudo systemctl daemon-reload # load the updated service file from disk
$ sudo systemctl enable postgresql
$ sudo systemctl start postgresql

Return to “Tutorials”