OpenBSD / PostgreSQL / Authentication

November 29, 2017
openbsd postgresql pgen

PostgreSQL and the BSD authentication

If you are an OpenBSD user and you are using PostgreSQL, you can use the BSD authentication to login into PostgreSQL. We will see how to do this.

The setup is quite easy:

$ doas pkg_add postgresql-server
quirks-2.395 signed on 2017-11-27T16:02:16Z
postgresql-server-9.6.6:postgresql-client-9.6.6: ok
postgresql-server-9.6.6: ok
The following new rcscripts were installed: /etc/rc.d/postgresql
See rcctl(8) for details.
Look in /usr/local/share/doc/pkg-readmes for extra documentation.

If you re not an OpenBSD user, you should read the file /usr/local/share/doc/pkg-readmes/postgresql-server-9.6.6 to see all the options available.

Create the cluster:

$ doas su _postgresql
$ mkdir /var/postgresql/data
$ initdb -D /var/postgresql/data/ -U postgres -E UTF-8 -A md5 -W
The files belonging to this database system will be owned by user "_postgresql".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".

Data page checksums are disabled.

Enter new superuser password:
Enter it again:

fixing permissions on existing directory /var/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 30
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

Success. You can now start the database server using:

pg_ctl -D /var/postgresql/data/ -l logfile start

Trick: this method is not mentionned in the file pg_hba.conf

Warning: the user pea must exist in PostgreSQL too !

(1 row)

pea=> select version();

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ version │ ├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │ PostgreSQL 9.6.6 on x86_64-unknown-openbsd6.2, compiled by OpenBSD clang version 5.0.0 (tags/RELEASE_500/final) (based on LLVM 5.0.0), 64-bit │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ (1 row) ```

Et voila 😃 !!

Setup a PostgreSQL cluster with repmgr and pgbouncer

December 22, 2018
PostgreSQL replication pgen repmgr pgbouncer

Mettre en place une streaming replication avec PostgreSQL 10

March 13, 2018
postgresql pgfr

Setup a streaming replication with PostgreSQL 10

March 11, 2018
postgresql pgen