Presented by Keith Fiske / @keithf4
Senior Database Engineer @ Crunchy Data Solutions, Inc.
(pg_partman, pg_extractor, mimeo)
Follow along at
http://slides.keithf4.com/managing_pg_packages
http://www.postgresql.org/download/
Debian 9.5.0 64-bit
$ cat /etc/apt/preferences.d/postgresql
Package: postgresql-* libpq5 libpq-dev
Pin: version 9.4.6-1.*
Pin-Priority: 501
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
#listen_addresses = 'localhost'
keith@debian:~$ sudo update-alternatives --get-selections | grep postgres
postmaster.1.gz auto /usr/share/postgresql/10/man/man1/postmaster.1.gz
psql.1.gz auto /usr/share/postgresql/10/man/man1/psql.1.gz
keith@debian:~$ sudo update-alternatives --list psql.1.gz
/usr/share/postgresql/10/man/man1/psql.1.gz
/usr/share/postgresql/9.6/man/man1/psql.1.gz
keith@debian:~$ sudo update-alternatives --config psql.1.gz
There are 2 choices for the alternative psql.1.gz (providing /usr/share/man/man1/psql.1.gz).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/share/postgresql/10/man/man1/psql.1.gz 100 auto mode
1 /usr/share/postgresql/10/man/man1/psql.1.gz 100 manual mode
2 /usr/share/postgresql/9.6/man/man1/psql.1.gz 96 manual mode
Press enter to keep the current choice[*], or type selection number:
systemctl list-units | grep postgres
sudo systemctl start postgresql@10-main
sudo systemctl stop postgresql@10-main
pg_ctlcluster 9.4 main stop -m fast
CentOS 7.5 64-bit
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
/usr/pgsql-10/bin/postgresql-10-setup initdb
sudo systemctl enable postgresql-10
sudo systemctl start postgresql-10
sudo systemctl stop postgresql-10
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
#listen_addresses = 'localhost'
[keith@centos alternatives]$ pwd
/var/lib/alternatives
[training@localhost alternatives]$ ls -l
total 196
-rw-r--r--. 1 root root 400 Jan 24 2018 cdrecord
-rw-r--r--. 1 root root 114 Aug 29 16:26 cifs-idmap-plugin
-rw-r--r--. 1 root root 63 Aug 29 16:28 cups_backend_smb
-rw-r--r--. 1 root root 63 Aug 29 16:28 google-chrome
-rw-r--r--. 1 root root 4411 Aug 29 16:29 java
-rw-r--r--. 1 root root 253 Aug 29 16:29 jre_1.7.0
-rw-r--r--. 1 root root 264 Aug 29 16:29 jre_1.7.0_openjdk
-rw-r--r--. 1 root root 243 Aug 29 16:29 jre_1.8.0
-rw-r--r--. 1 root root 258 Aug 29 16:29 jre_1.8.0_openjdk
-rw-r--r--. 1 root root 424 Aug 29 16:29 jre_openjdk
-rw-r--r--. 1 root root 57 Aug 29 16:27 ld
-rw-r--r--. 1 root root 531 Aug 20 14:18 libjavaplugin.so.x86_64
-rw-r--r--. 1 root root 101 Aug 29 16:26 libnssckbi.so.x86_64
-rw-r--r--. 1 root root 86 Aug 29 16:30 libwbclient.so.0.14-64
-rw-r--r--. 1 root root 283 Jan 24 2018 mkisofs
-rw-r--r--. 1 root root 689 Jan 24 2018 mta
-rw-r--r--. 1 root root 103 Feb 12 2018 pax
-rw-r--r--. 1 root root 91 Oct 17 19:12 pgsql-clusterdb
-rw-r--r--. 1 root root 130 Oct 17 19:12 pgsql-clusterdbman
-rw-r--r--. 1 root root 88 Oct 17 19:12 pgsql-createdb
-rw-r--r--. 1 root root 127 Oct 17 19:12 pgsql-createdbman
-rw-r--r--. 1 root root 60 Oct 17 19:12 pgsql-createlang
-rw-r--r--. 1 root root 86 Oct 17 19:12 pgsql-createlangman
-rw-r--r--. 1 root root 94 Oct 17 19:12 pgsql-createuser
-rw-r--r--. 1 root root 133 Oct 17 19:12 pgsql-createuserman
-rw-r--r--. 1 root root 82 Oct 17 19:12 pgsql-dropdb
-rw-r--r--. 1 root root 121 Oct 17 19:12 pgsql-dropdbman
-rw-r--r--. 1 root root 56 Oct 17 19:12 pgsql-droplang
-rw-r--r--. 1 root root 82 Oct 17 19:12 pgsql-droplangman
-rw-r--r--. 1 root root 88 Oct 17 19:12 pgsql-dropuser
-rw-r--r--. 1 root root 127 Oct 17 19:12 pgsql-dropuserman
-rw-r--r--. 1 root root 149 Oct 17 19:12 pgsql-ld-conf
-rw-r--r--. 1 root root 103 Oct 17 19:12 pgsql-pg_basebackup
-rw-r--r--. 1 root root 142 Oct 17 19:12 pgsql-pg_basebackupman
-rw-r--r--. 1 root root 85 Oct 17 19:12 pgsql-pg_dump
-rw-r--r--. 1 root root 94 Oct 17 19:12 pgsql-pg_dumpall
-rw-r--r--. 1 root root 133 Oct 17 19:12 pgsql-pg_dumpallman
-rw-r--r--. 1 root root 124 Oct 17 19:12 pgsql-pg_dumpman
-rw-r--r--. 1 root root 94 Oct 17 19:12 pgsql-pg_restore
-rw-r--r--. 1 root root 133 Oct 17 19:12 pgsql-pg_restoreman
-rw-r--r--. 1 root root 76 Oct 17 19:12 pgsql-psql
-rw-r--r--. 1 root root 115 Oct 17 19:12 pgsql-psqlman
-rw-r--r--. 1 root root 91 Oct 17 19:12 pgsql-reindexdb
-rw-r--r--. 1 root root 130 Oct 17 19:12 pgsql-reindexdbman
-rw-r--r--. 1 root root 88 Oct 17 19:12 pgsql-vacuumdb
-rw-r--r--. 1 root root 127 Oct 17 19:12 pgsql-vacuumdbman
-rw-r--r--. 1 root root 856 Aug 20 14:11 print
-rw-r--r--. 1 root root 181 Aug 20 14:14 xinputrc
$ sudo update-alternatives --display pgsql-psql
pgsql-psql - status is auto.
link currently points to /usr/pgsql-10/bin/psql
/usr/pgsql-10/bin/psql - priority 1000
/usr/pgsql-9.6/bin/psql - priority 960
Current `best' version is /usr/pgsql-10/bin/psql.
$ sudo update-alternatives --config pgsql-psql
There are 2 programs which provide 'pgsql-psql'.
Selection Command
-----------------------------------------------
*+ 1 /usr/pgsql-10/bin/psql
2 /usr/pgsql-9.6/bin/psql
Enter to keep the current selection[+], or type selection number:
--auto option sets alternatives to automatically choose the one with highest priority
$ pwd
/usr/lib/systemd/system
$ ls -l | grep postgres
-rw-r--r--. 1 root root 1728 Aug 9 05:35 postgresql-10.service
-rw-r--r--. 1 root root 1730 Aug 9 05:27 postgresql-9.6.service
Environment=PGDATA=/var/lib/pgsql/10/my_other_db/
FreeBSD 11.2 64-bit
postgresql_enable="YES"
sudo /usr/local/etc/rc.d/postgresql initdb
sudo service postgresql start
sudo service postgresql stop -m fast
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
#listen_addresses = 'localhost'
/usr/local/etc/rc.d/postgresql
postgresql_data="/usr/local/pgsql/data/10
postgresql_flags="-w -s -m fast"
postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"
REPLACE:
# set defaults
eval postgresql_data=${postgresql_data:-"~${postgresql_user}/data"}
WITH:
postgresql_data="/usr/local/pgsql/10/newdb"
pkg install readline
./configure --with-includes=/usr/local/include
make world
make install-world
ln -s /opt/pgsql95 pgsql
keith@server:~ % zfs list
NAME USED AVAIL REFER MOUNTPOINT
tank 2.60T 937G 144K /tank
tank/pgdata 396M 937G 280M /tank/pgdata
keith@server:/tank/pgdata % ls -l
total 9
drwx------ 19 pgsql pgsql 26 Apr 14 14:33 96
drwx------ 2 pgsql pgsql 2 May 16 20:34 10