Longer answer (as promised)

On Saturday, May 21, 2016 04:56:18 PM waltd...@waltdnes.org wrote:
> On Sat, May 21, 2016 at 08:55:39AM +0200, J. Roeleveld wrote

> > Did you run
> > emerge --config dev-db/postgresql:9.5
> 
>   Yes.
> 
> > succesfully?
> 
>   Obviously not.

:)

>   I think I've finally figured it out.  I edited
> /etc/conf.d/postgresql-9.5 to PG_INITDB_OPTS="--encoding=UTF8" and ran
> "emerge --config dev-db/postgresql:9.5".  I got an error message about
> the data directory not be empty (probably from my first attempt).  I ran
> 
> rm /var/lib/postgresql/9.5/data/*
> emerge --config dev-db/postgresql:9.5
> 
> and got a bit further.  I did get error messages as follows
> 
> 
> #######################################################################
> The database cluster will be initialized with locale "en_US.iso88591".
> initdb: encoding mismatch
> The encoding you selected (UTF8) and the encoding that the
> selected locale uses (LATIN1) do not match.  This would lead to
> misbehavior in various character string processing functions.
> Rerun initdb and either do not specify an encoding explicitly,
> or choose a matching combination.
> mv: cannot stat '/var/lib/postgresql/9.5/data/pg_hba.conf': No such file or
> directory mv: cannot stat '/var/lib/postgresql/9.5/data/pg_ident.conf': No
> such file or directory mv: cannot stat
> '/var/lib/postgresql/9.5/data/postgresql.conf': No such file or directory
> #######################################################################

If there is a mismatch, the config-script refuses to work correctly.

>   I fixed that.  In /etc/conf.d/postgresql-9.5 I set
> PG_INITDB_OPTS="--encoding=iso88591"  and ran
> 
> rm /var/lib/postgresql/9.5/data/*
> emerge --config dev-db/postgresql:9.5
> 
> and got the following.  Does it look OK?  Do I understand correctly...
> 
> config files are located in /etc/postgresql-9.5/
> the actual databases are located in /var/lib/postgresql/9.5/data
> 
> #######################################################################

<snipped output - which looks 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.

This is nothing to worry about, as long as the database is not accessible from 
outside.
The "trust" part means it ignores passwords. By default, this is only for 
"localhost"

> Success. You can now start the database server using:
> 
>     /usr/lib64/postgresql-9.5/bin/pg_ctl -D /var/lib/postgresql/9.5/data -l
> logfile start

Ignore this line.

>  * The autovacuum function, which was in contrib, has been moved to the main
> * PostgreSQL functions starting with 8.1, and starting with 8.4 is now
> enabled * by default. You can disable it in the cluster's:
>  *     /etc/postgresql-9.5/postgresql.conf
>  *
>  * The PostgreSQL server, by default, will log events to:
>  *     /var/lib/postgresql/9.5/data/postmaster.log
>  *
>  * You should use the '/etc/init.d/postgresql-9.5' script to run PostgreSQL
>  * instead of 'pg_ctl'.

Listen to this line :)
The init-script uses "pg_ctl" to start/stop postgresql.

> #######################################################################
> 
>   There's still one apparent internal contradiction in the output...
> 
> #######################################################################
> Success. You can now start the database server using:
> 
>     /usr/lib64/postgresql-9.5/bin/pg_ctl -D /var/lib/postgresql/9.5/data -l
> logfile start
> #######################################################################
> 
> ...but it also says...
> 
> #######################################################################
>  * You should use the '/etc/init.d/postgresql-9.5' script to run PostgreSQL
>  * instead of 'pg_ctl'.
> #######################################################################

See above, use the init-script and you're fine.

If you change the configuration, you can tell Postgresql to reload the new 
config by issuing " /etc/init.d/postgresql-9.5 reload "

Most common config-changes to a running system: adding/removing users/access to 
/etc/postgresql-9.5/pg_hba.conf.

One additional piece of info, by default, it logs to
/var/lib/postgresql/9.5/data/postmaster.log

If you want it to log to a different location or to syslog, you can edit this 
in the file:
/etc/postgresql-9.5/postgresql.conf

Look for the section:
#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

The comments in the file tell you which settings require a restart (of 
postgresql). The ones that don't should come into effect with just the 
"reload" command I mentioned above.

--
Joost

Reply via email to