PostgreSQLのalternativeの向き先を変更

現状:postgresql11.9
変更後:postgresql13.9

↓参考にした記事
https://lets.postgresql.jp/documents/tutorial/new_rpm


1.シンボリックリンク一覧を確認
# ll -h /etc/alternatives/ | grep pgsql
lrwxrwxrwx 1 root root 27 Jun 30  2022 pgsql-clusterdb -> /usr/pgsql-11/bin/clusterdb
lrwxrwxrwx 1 root root 40 Jun 30  2022 pgsql-clusterdbman -> /usr/pgsql-11/share/man/man1/clusterdb.1
lrwxrwxrwx 1 root root 26 Jun 30  2022 pgsql-createdb -> /usr/pgsql-11/bin/createdb
lrwxrwxrwx 1 root root 39 Jun 30  2022 pgsql-createdbman -> /usr/pgsql-11/share/man/man1/createdb.1
lrwxrwxrwx 1 root root 28 Jun 30  2022 pgsql-createuser -> /usr/pgsql-11/bin/createuser
lrwxrwxrwx 1 root root 41 Jun 30  2022 pgsql-createuserman -> /usr/pgsql-11/share/man/man1/createuser.1
lrwxrwxrwx 1 root root 24 Jun 30  2022 pgsql-dropdb -> /usr/pgsql-11/bin/dropdb
lrwxrwxrwx 1 root root 37 Jun 30  2022 pgsql-dropdbman -> /usr/pgsql-11/share/man/man1/dropdb.1
lrwxrwxrwx 1 root root 26 Jun 30  2022 pgsql-dropuser -> /usr/pgsql-11/bin/dropuser
lrwxrwxrwx 1 root root 39 Jun 30  2022 pgsql-dropuserman -> /usr/pgsql-11/share/man/man1/dropuser.1
lrwxrwxrwx 1 root root 43 Jun 30  2022 pgsql-ld-conf -> /usr/pgsql-11/share/postgresql-11-libs.conf
lrwxrwxrwx 1 root root 31 Jun 30  2022 pgsql-pg_basebackup -> /usr/pgsql-11/bin/pg_basebackup
lrwxrwxrwx 1 root root 44 Jun 30  2022 pgsql-pg_basebackupman -> /usr/pgsql-11/share/man/man1/pg_basebackup.1
lrwxrwxrwx 1 root root 25 Jun 30  2022 pgsql-pg_dump -> /usr/pgsql-11/bin/pg_dump
lrwxrwxrwx 1 root root 28 Jun 30  2022 pgsql-pg_dumpall -> /usr/pgsql-11/bin/pg_dumpall
lrwxrwxrwx 1 root root 41 Jun 30  2022 pgsql-pg_dumpallman -> /usr/pgsql-11/share/man/man1/pg_dumpall.1
lrwxrwxrwx 1 root root 38 Jun 30  2022 pgsql-pg_dumpman -> /usr/pgsql-11/share/man/man1/pg_dump.1
lrwxrwxrwx 1 root root 28 Jun 30  2022 pgsql-pg_restore -> /usr/pgsql-11/bin/pg_restore
lrwxrwxrwx 1 root root 41 Jun 30  2022 pgsql-pg_restoreman -> /usr/pgsql-11/share/man/man1/pg_restore.1
lrwxrwxrwx 1 root root 22 Jun 30  2022 pgsql-psql -> /usr/pgsql-11/bin/psql
lrwxrwxrwx 1 root root 35 Jun 30  2022 pgsql-psqlman -> /usr/pgsql-11/share/man/man1/psql.1
lrwxrwxrwx 1 root root 27 Jun 30  2022 pgsql-reindexdb -> /usr/pgsql-11/bin/reindexdb
lrwxrwxrwx 1 root root 40 Jun 30  2022 pgsql-reindexdbman -> /usr/pgsql-11/share/man/man1/reindexdb.1
lrwxrwxrwx 1 root root 26 Jun 30  2022 pgsql-vacuumdb -> /usr/pgsql-11/bin/vacuumdb
lrwxrwxrwx 1 root root 39 Jun 30  2022 pgsql-vacuumdbman -> /usr/pgsql-11/share/man/man1/vacuumdb.1



2.作業前のalternativesの優先度を確認
#  /sbin/alternatives --display pgsql-createdb
pgsql-createdb - status is auto.
 link currently points to /usr/pgsql-11/bin/createdb
/usr/pgsql-11/bin/createdb - priority 1100
Current `best' version is /usr/pgsql-11/bin/createdb.

#  /sbin/alternatives --display pgsql-createdbman
pgsql-createdbman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/createdb.1
/usr/pgsql-11/share/man/man1/createdb.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/createdb.1.

#  /sbin/alternatives --display pgsql-createuser
pgsql-createuser - status is auto.
 link currently points to /usr/pgsql-11/bin/createuser
/usr/pgsql-11/bin/createuser - priority 1100
Current `best' version is /usr/pgsql-11/bin/createuser.

#  /sbin/alternatives --display pgsql-createuserman 
pgsql-createuserman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/createuser.1
/usr/pgsql-11/share/man/man1/createuser.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/createuser.1.

#  /sbin/alternatives --display pgsql-dropdb
pgsql-dropdb - status is auto.
 link currently points to /usr/pgsql-11/bin/dropdb
/usr/pgsql-11/bin/dropdb - priority 1100
Current `best' version is /usr/pgsql-11/bin/dropdb.

#  /sbin/alternatives --display pgsql-dropdbman 
pgsql-dropdbman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/dropdb.1
/usr/pgsql-11/share/man/man1/dropdb.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/dropdb.1.

#  /sbin/alternatives --display pgsql-dropuser 
pgsql-dropuser - status is auto.
 link currently points to /usr/pgsql-11/bin/dropuser
/usr/pgsql-11/bin/dropuser - priority 1100
Current `best' version is /usr/pgsql-11/bin/dropuser.

#  /sbin/alternatives --display pgsql-dropuserman 
pgsql-dropuserman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/dropuser.1
/usr/pgsql-11/share/man/man1/dropuser.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/dropuser.1.

#  /sbin/alternatives --display pgsql-ld-conf
pgsql-ld-conf - status is auto.
 link currently points to /usr/pgsql-11/share/postgresql-11-libs.conf
/usr/pgsql-11/share/postgresql-11-libs.conf - priority 1100
Current `best' version is /usr/pgsql-11/share/postgresql-11-libs.conf.

#  /sbin/alternatives --display pgsql-pg_basebackup
pgsql-pg_basebackup - status is auto.
 link currently points to /usr/pgsql-11/bin/pg_basebackup
/usr/pgsql-11/bin/pg_basebackup - priority 1100
Current `best' version is /usr/pgsql-11/bin/pg_basebackup.

#  /sbin/alternatives --display pgsql-pg_basebackupman
pgsql-pg_basebackupman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/pg_basebackup.1
/usr/pgsql-11/share/man/man1/pg_basebackup.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/pg_basebackup.1.

#  /sbin/alternatives --display pgsql-pg_dump
pgsql-pg_dump - status is auto.
 link currently points to /usr/pgsql-11/bin/pg_dump
/usr/pgsql-11/bin/pg_dump - priority 1100
Current `best' version is /usr/pgsql-11/bin/pg_dump.

#  /sbin/alternatives --display pgsql-pg_dumpall
pgsql-pg_dumpall - status is auto.
 link currently points to /usr/pgsql-11/bin/pg_dumpall
/usr/pgsql-11/bin/pg_dumpall - priority 1100
Current `best' version is /usr/pgsql-11/bin/pg_dumpall.

#  /sbin/alternatives --display pgsql-pg_dumpallman
pgsql-pg_dumpallman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/pg_dumpall.1
/usr/pgsql-11/share/man/man1/pg_dumpall.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/pg_dumpall.1.

#  /sbin/alternatives --display pgsql-pg_dumpman
pgsql-pg_dumpman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/pg_dump.1
/usr/pgsql-11/share/man/man1/pg_dump.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/pg_dump.1.

#  /sbin/alternatives --display pgsql-pg_restore
 /sbin/alternatives --display pgsql-pg_restoreman
pgsql-pg_restore - status is auto.
 link currently points to /usr/pgsql-11/bin/pg_restore
/usr/pgsql-11/bin/pg_restore - priority 1100
Current `best' version is /usr/pgsql-11/bin/pg_restore.

#  /sbin/alternatives --display pgsql-pg_restoreman
pgsql-pg_restoreman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/pg_restore.1
/usr/pgsql-11/share/man/man1/pg_restore.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/pg_restore.1.

#  /sbin/alternatives --display pgsql-psql
pgsql-psql - status is auto.
 link currently points to /usr/pgsql-11/bin/psql
/usr/pgsql-11/bin/psql - priority 1100
Current `best' version is /usr/pgsql-11/bin/psql.

#  /sbin/alternatives --display pgsql-psqlman
pgsql-psqlman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/psql.1
/usr/pgsql-11/share/man/man1/psql.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/psql.1.

#  /sbin/alternatives --display pgsql-reindexdb
pgsql-reindexdb - status is auto.
 link currently points to /usr/pgsql-11/bin/reindexdb
/usr/pgsql-11/bin/reindexdb - priority 1100
Current `best' version is /usr/pgsql-11/bin/reindexdb.

#  /sbin/alternatives --display pgsql-reindexdbman
pgsql-reindexdbman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/reindexdb.1
/usr/pgsql-11/share/man/man1/reindexdb.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/reindexdb.1.

#  /sbin/alternatives --display pgsql-vacuumdb
pgsql-vacuumdb - status is auto.
 link currently points to /usr/pgsql-11/bin/vacuumdb
/usr/pgsql-11/bin/vacuumdb - priority 1100
Current `best' version is /usr/pgsql-11/bin/vacuumdb.

#  /sbin/alternatives --display pgsql-vacuumdbman
pgsql-vacuumdbman - status is auto.
 link currently points to /usr/pgsql-11/share/man/man1/vacuumdb.1
/usr/pgsql-11/share/man/man1/vacuumdb.1 - priority 1100
Current `best' version is /usr/pgsql-11/share/man/man1/vacuumdb.1.




3.alternativesにPostgresql13.9を追加
cd /etc/alternatives/
ln -nfs /usr/pgsql-13.9/share/postgresql-13.9-libs.conf  pgsql-ld-conf

 /sbin/alternatives --install /usr/bin/clusterdb pgsql-clusterdb /usr/pgsql-13.9/bin/clusterdb 1300
 /sbin/alternatives --install  /usr/share/man/man1/clusterdb.1 pgsql-clusterdbman /usr/pgsql-13.9/share/man/man1/clusterdb.1 1300
 /sbin/alternatives --install  /usr/bin/createdb pgsql-createdb /usr/pgsql-13.9/bin/createdb 1300
 /sbin/alternatives --install  /usr/share/man/man1/createdb.1 pgsql-createdbman /usr/pgsql-13.9/share/man/man1/createdb.1 1300
 /sbin/alternatives --install  /usr/bin/createuser pgsql-createuser /usr/pgsql-13.9/bin/createuser
 /sbin/alternatives --install  /usr/share/man/man1/createuser.1  pgsql-createuserman  /usr/pgsql-13.9/share/man/man1/createuser.1 1300
 /sbin/alternatives --install  /usr/bin/dropdb pgsql-dropdb /usr/pgsql-13.9/bin/dropdb 1300
 /sbin/alternatives --install  /usr/share/man/man1/dropdb.1  pgsql-dropdbman  /usr/pgsql-13.9/share/man/man1/dropdb.1 1300
 /sbin/alternatives --install  /usr/bin/dropuser  pgsql-dropuser  /usr/pgsql-13.9/bin/dropuser 1300
 /sbin/alternatives --install  /usr/share/man/man1/dropuser.1  pgsql-dropuserman  /usr/pgsql-13.9/share/man/man1/dropuser.1 1300
 /sbin/alternatives --install  /usr/bin/ld-conf pgsql-ld-conf /usr/pgsql-11/share/postgresql-11-libs.conf 1300
 /sbin/alternatives --install  /usr/bin/pg_basebackup pgsql-pg_basebackup /usr/pgsql-13.9/bin/pg_basebackup 1300
 /sbin/alternatives --install  /usr/share/man/man1/pg_basebackup.1 pgsql-pg_basebackupman /usr/pgsql-13.9/share/man/man1/pg_basebackup.1 1300
 /sbin/alternatives --install  /usr/bin/pg_dump pgsql-pg_dump /usr/pgsql-13.9/bin/pg_dump 1300
 /sbin/alternatives --install  /usr/bin/pg_dumpall pgsql-pg_dumpall /usr/pgsql-13.9/bin/pg_dumpall 1300
 /sbin/alternatives --install  /usr/share/man/man1/pg_dumpall.1 pgsql-pg_dumpallman /usr/pgsql-13.9/share/man/man1//pg_dumpall.1 1300
 /sbin/alternatives --install  /usr/share/man/man1/pg_dump.1 pgsql-pg_dumpman /usr/pgsql-13.9/share/man/man1//pg_dump.1 1300
 /sbin/alternatives --install  /usr/bin/pg_restore pgsql-pg_restore /usr/pgsql-13.9/bin/pg_restore 1300
 /sbin/alternatives --install  /usr/share/man/man1/pg_restore.1 pgsql-pg_restoreman /usr/pgsql-13.9/share/man/man1/pg_restore.1 1300
 /sbin/alternatives --install  /usr/bin/psql pgsql-psql /usr/pgsql-13.9/bin/psql 1300
 /sbin/alternatives --install  /usr/share/man/man1/psql.1 pgsql-psqlman /usr/pgsql-13.9/share/man/man1/psql.1 1300
 /sbin/alternatives --install  /usr/bin/reindexdb pgsql-reindexdb /usr/pgsql-13.9/bin/reindexdb 1300
 /sbin/alternatives --install  /usr/share/man/man1/reindexdb.1 pgsql-reindexdbman /usr/pgsql-13.9/share/man/man1/reindexdb.1 1300
 /sbin/alternatives --install  /usr/bin/vacuumdb pgsql-vacuumdb /usr/pgsql-13.9/bin/vacuumdb 1300
 /sbin/alternatives --install  /usr/share/man/man1/vacuumdb.1 pgsql-vacuumdbman /usr/pgsql-13.9/share/man/man1/vacuumdb.1 1300


4.作業後alternativesの向き先を確認
#ll -h /etc/alternatives/
lrwxrwxrwx 1 root root 29 Feb  7 07:36 pgsql-clusterdb -> /usr/pgsql-13.9/bin/clusterdb
lrwxrwxrwx 1 root root 42 Feb  7 07:47 pgsql-clusterdbman -> /usr/pgsql-13.9/share/man/man1/clusterdb.1
lrwxrwxrwx 1 root root 28 Feb  7 07:56 pgsql-createdb -> /usr/pgsql-13.9/bin/createdb
lrwxrwxrwx 1 root root 41 Feb  7 07:56 pgsql-createdbman -> /usr/pgsql-13.9/share/man/man1/createdb.1
lrwxrwxrwx 1 root root 30 Feb  7 07:56 pgsql-createuser -> /usr/pgsql-13.9/bin/createuser
lrwxrwxrwx 1 root root 43 Feb  7 07:57 pgsql-createuserman -> /usr/pgsql-13.9/share/man/man1/createuser.1
lrwxrwxrwx 1 root root 26 Feb  7 07:57 pgsql-dropdb -> /usr/pgsql-13.9/bin/dropdb
lrwxrwxrwx 1 root root 39 Feb  7 07:57 pgsql-dropdbman -> /usr/pgsql-13.9/share/man/man1/dropdb.1
lrwxrwxrwx 1 root root 28 Feb  7 07:57 pgsql-dropuser -> /usr/pgsql-13.9/bin/dropuser
lrwxrwxrwx 1 root root 41 Feb  7 07:58 pgsql-dropuserman -> /usr/pgsql-13.9/share/man/man1/dropuser.1
lrwxrwxrwx 1 root root 43 Jun 30  2022 pgsql-ld-conf -> /usr/pgsql-11/share/postgresql-11-libs.conf
lrwxrwxrwx 1 root root 33 Feb  7 07:58 pgsql-pg_basebackup -> /usr/pgsql-13.9/bin/pg_basebackup
lrwxrwxrwx 1 root root 46 Feb  7 07:58 pgsql-pg_basebackupman -> /usr/pgsql-13.9/share/man/man1/pg_basebackup.1
lrwxrwxrwx 1 root root 27 Feb  7 07:58 pgsql-pg_dump -> /usr/pgsql-13.9/bin/pg_dump
lrwxrwxrwx 1 root root 30 Feb  7 07:58 pgsql-pg_dumpall -> /usr/pgsql-13.9/bin/pg_dumpall
lrwxrwxrwx 1 root root 44 Feb  7 07:58 pgsql-pg_dumpallman -> /usr/pgsql-13.9/share/man/man1//pg_dumpall.1
lrwxrwxrwx 1 root root 41 Feb  7 07:58 pgsql-pg_dumpman -> /usr/pgsql-13.9/share/man/man1//pg_dump.1
lrwxrwxrwx 1 root root 30 Feb  7 07:59 pgsql-pg_restore -> /usr/pgsql-13.9/bin/pg_restore
lrwxrwxrwx 1 root root 43 Feb  7 07:59 pgsql-pg_restoreman -> /usr/pgsql-13.9/share/man/man1/pg_restore.1
lrwxrwxrwx 1 root root 24 Feb  7 07:59 pgsql-psql -> /usr/pgsql-13.9/bin/psql
lrwxrwxrwx 1 root root 37 Feb  7 07:59 pgsql-psqlman -> /usr/pgsql-13.9/share/man/man1/psql.1
lrwxrwxrwx 1 root root 29 Feb  7 07:59 pgsql-reindexdb -> /usr/pgsql-13.9/bin/reindexdb
lrwxrwxrwx 1 root root 42 Feb  7 07:59 pgsql-reindexdbman -> /usr/pgsql-13.9/share/man/man1/reindexdb.1
lrwxrwxrwx 1 root root 28 Feb  7 07:59 pgsql-vacuumdb -> /usr/pgsql-13.9/bin/vacuumdb
lrwxrwxrwx 1 root root 41 Feb  7 07:59 pgsql-vacuumdbman -> /usr/pgsql-13.9/share/man/man1/vacuumdb.1
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次