Red Hat Enterprise Linux 8 に PostgreSQL 15 のクライアントをインストールしてみた
Red Hat Enterprise Linux 8にPostgreSQL 15のクライアントをインストールしたいな
こんにちは、のんピ(@non____97)です。
皆さんはRed Hat Enterprise Linux 8(以降RHEL 8)にPostgreSQL 15のクライアントをインストールしたいなと思ったことはありますか? 私はあります。
2023/4にAmazon Aurora PostgreSQL 15がGAされました。
これにより、PostgreSQL 15のクライアントの需要がより増えると予想します。
しかし、RHEL 8でデフォルトでインストール可能なPostgreSQLのクライアントのバージョンは10です。
せっかくRHELを使っているのに標準リポジトリ外からインストールするのも、なんだか勿体無い気がします。
ですが、安心してください。PostgreSQL 15のクライアントをRHEL 8にインストールすることは可能です。
以降、その方法を紹介します。
いきなりまとめ
- PostgreSQL 15のストリームを指定しよう
検証環境
検証環境は以下の通りです。
EC2インスタンスはRHEL 8.8です。
$ cat /etc/redhat-release Red Hat Enterprise Linux release 8.8 (Ootpa) $ rpm -qi kernel Name : kernel Version : 4.18.0 Release : 477.10.1.el8_8 Architecture: x86_64 Install Date: Wed 03 May 2023 03:42:27 PM UTC Group : System Environment/Kernel Size : 0 License : GPLv2 and Redistributable, no modification permitted Signature : RSA/SHA256, Mon 10 Apr 2023 01:53:24 PM UTC, Key ID 199e2f91fd431d51 Source RPM : kernel-4.18.0-477.10.1.el8_8.src.rpm Build Date : Wed 05 Apr 2023 06:05:30 PM UTC Build Host : x86-vm-07.build.eng.bos.redhat.com Relocations : (not relocatable) Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Vendor : Red Hat, Inc. URL : http://www.kernel.org/ Summary : The Linux kernel, based on version 4.18.0, heavily modified with backports Description : This is the package which provides the Linux kernel for Red Hat Enterprise Linux. It is based on upstream Linux at version 4.18.0 and maintains kABI compatibility of a set of approved symbols, however it is heavily modified with backports and fixes pulled from newer upstream Linux kernel releases. This means this is not a 4.18.0 kernel anymore: it includes several components which come from newer upstream linux versions, while maintaining a well tested and stable core. Some of the components/backports that may be pulled in are: changes like updates to the core kernel (eg.: scheduler, cgroups, memory management, security fixes and features), updates to block layer, supported filesystems, major driver updates for supported hardware in Red Hat Enterprise Linux, enhancements for enterprise customers, etc.
こちらの環境はAWS CDKでデプロイしました。
使用したコードは以下リポジトリに保存しています。
デフォルトのPostgreSQLクライアントのインストール
それでは、PostgreSQLクライアントのインストールをしてみます。
インストール可能なPostgreSQLクライアントの情報を確認します。
$ sudo dnf info postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:00:57 ago on Tue 30 May 2023 06:04:37 AM UTC. Available Packages Name : postgresql Version : 10.23 Release : 1.module+el8.7.0+17280+3a452e1f Architecture : x86_64 Size : 1.5 M Source : postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.src.rpm Repository : rhel-8-appstream-rhui-rpms Summary : PostgreSQL client programs URL : http://www.postgresql.org/ License : PostgreSQL Description : PostgreSQL is an advanced Object-Relational database management system (DBMS). : The base postgresql package contains the client programs that you'll need to : access a PostgreSQL DBMS server, as well as HTML documentation for the whole : system. These client programs can be located on the same machine as the : PostgreSQL server, or on a remote machine that accesses a PostgreSQL server : over a network connection. The PostgreSQL server can be found in the : postgresql-server sub-package.
10.23のようですね。
他にインストール可能なバージョンに何があるのか確認します。
$ sudo dnf list postgresql --showduplicates Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:02:21 ago on Tue 30 May 2023 06:04:37 AM UTC. Available Packages postgresql.x86_64 10.6-1.module+el8+2469+5ecd5aae rhel-8-appstream-rhui-rpms postgresql.x86_64 10.14-1.module+el8.2.0+7801+be0fed80 rhel-8-appstream-rhui-rpms postgresql.x86_64 10.15-1.module+el8.3.0+8944+1ca16b1f rhel-8-appstream-rhui-rpms postgresql.x86_64 10.17-1.module+el8.4.0+11249+895597ab rhel-8-appstream-rhui-rpms postgresql.x86_64 10.17-2.module+el8.5.0+11838+8dca950a rhel-8-appstream-rhui-rpms postgresql.x86_64 10.19-1.module+el8.6.0+13642+78853f5a rhel-8-appstream-rhui-rpms postgresql.x86_64 10.21-2.module+el8.6.0+15342+53518fac rhel-8-appstream-rhui-rpms postgresql.x86_64 10.23-1.module+el8.7.0+17280+3a452e1f rhel-8-appstream-rhui-rpms
10.6から10.23しかありませんね。
postgresql-15
のような類似のパッケージがないか検索します。
$ sudo dnf search postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:03:53 ago on Tue 30 May 2023 06:25:59 AM UTC. ======================================= Name & Summary Matched: postgresql ======================================== postgresql.x86_64 : PostgreSQL client programs freeradius-postgresql.x86_64 : Postgresql support for freeradius pcp-pmda-postgresql.x86_64 : Performance Co-Pilot (PCP) metrics for PostgreSQL postgresql-contrib.x86_64 : Extension modules distributed with PostgreSQL postgresql-docs.x86_64 : Extra documentation for PostgreSQL postgresql-jdbc.noarch : JDBC driver for PostgreSQL postgresql-jdbc-javadoc.noarch : API docs for postgresql-jdbc postgresql-odbc.x86_64 : PostgreSQL ODBC driver postgresql-plperl.x86_64 : The Perl procedural language for PostgreSQL postgresql-plpython3.x86_64 : The Python3 procedural language for PostgreSQL postgresql-pltcl.x86_64 : The Tcl procedural language for PostgreSQL postgresql-server.x86_64 : The programs needed to create and run a PostgreSQL server postgresql-server-devel.x86_64 : PostgreSQL development header files and libraries postgresql-static.x86_64 : Statically linked PostgreSQL libraries postgresql-test.x86_64 : The test suite distributed with PostgreSQL postgresql-test-rpm-macros.x86_64 : Convenience RPM macros for build-time testing against PostgreSQL server postgresql-upgrade.x86_64 : Support for upgrading from the previous major release of PostgreSQL qt5-qtbase-postgresql.i686 : PostgreSQL driver for Qt5's SQL classes qt5-qtbase-postgresql.x86_64 : PostgreSQL driver for Qt5's SQL classes tuned-profiles-postgresql.noarch : Additional tuned profile(s) targeted to PostgreSQL server loads ============================================ Name Matched: postgresql ============================================= postgresql-odbc-tests.x86_64 : Testsuite files for psqlodbc postgresql-upgrade-devel.x86_64 : Support for build of extensions required for upgrade process =========================================== Summary Matched: postgresql =========================================== apr-util-pgsql.x86_64 : APR utility library PostgreSQL DBD driver libpgtypes.x86_64 : Map PostgreSQL database types to C equivalents libpgtypes.i686 : Map PostgreSQL database types to C equivalents libpq.x86_64 : PostgreSQL client library libpq.i686 : PostgreSQL client library libpq-devel.x86_64 : Development files for building PostgreSQL client tools libpq-devel.i686 : Development files for building PostgreSQL client tools perl-DBD-Pg.x86_64 : A PostgreSQL interface for perl php-pgsql.x86_64 : A PostgreSQL database module for PHP postfix-pgsql.x86_64 : Postfix PostgreSQL map support python-psycopg2-doc.x86_64 : Documentation for psycopg python PostgreSQL database adapter python2-psycopg2.x86_64 : A PostgreSQL database adapter for Python 2 python2-psycopg2-debug.x86_64 : A PostgreSQL database adapter for Python 2 (debug build) python2-psycopg2-tests.x86_64 : A testsuite for A PostgreSQL database adapter for Python 2 python3-psycopg2.x86_64 : A PostgreSQL database adapter for Python 3 python3.11-psycopg2.x86_64 : A PostgreSQL database adapter for Python python38-psycopg2.x86_64 : A PostgreSQL database adapter for Python 3 python38-psycopg2-doc.x86_64 : Documentation for psycopg python PostgreSQL database adapter python38-psycopg2-tests.x86_64 : A testsuite for A PostgreSQL database adapter for Python 2 python39-psycopg2.x86_64 : A PostgreSQL database adapter for Python 3 python39-psycopg2-doc.x86_64 : Documentation for psycopg python PostgreSQL database adapter python39-psycopg2-tests.x86_64 : A testsuite for A PostgreSQL database adapter for Python 2 rubygem-pg.x86_64 : A Ruby interface to the PostgreSQL RDBMS
そのようなものはないようです。
なお、参照しているリポジトリは以下の通りです。デフォルトから変更していません。
$ dnf repolist Not root, Subscription Management repositories not updated repo id repo name ansible-2-for-rhel-8-rhui-rpms Red Hat Ansible Engine 2 for RHEL 8 (RPMs) from RHUI rhel-8-appstream-rhui-rpms Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) rhel-8-baseos-rhui-rpms Red Hat Enterprise Linux 8 for x86_64 - BaseOS from RHUI (RPMs) rhui-client-config-server-8 RHUI Client Configuration Server 8
しょうがないので、PostgreSQL 10.23のクライアントをインストールします。
$ sudo dnf install postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:03:57 ago on Tue 30 May 2023 06:04:37 AM UTC. Dependencies resolved. =================================================================================================================== Package Architecture Version Repository Size =================================================================================================================== Installing: postgresql x86_64 10.23-1.module+el8.7.0+17280+3a452e1f rhel-8-appstream-rhui-rpms 1.5 M Installing dependencies: libpq x86_64 13.5-1.el8 rhel-8-appstream-rhui-rpms 198 k Enabling module streams: postgresql 10 Transaction Summary =================================================================================================================== Install 2 Packages Total download size: 1.7 M Installed size: 6.2 M Is this ok [y/N]: y Downloading Packages: (1/2): libpq-13.5-1.el8.x86_64.rpm 4.3 MB/s | 198 kB 00:00 (2/2): postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64.rpm 21 MB/s | 1.5 MB 00:00 ------------------------------------------------------------------------------------------------------------------- Total 16 MB/s | 1.7 MB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : libpq-13.5-1.el8.x86_64 1/2 Installing : postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 2/2 Running scriptlet: postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 2/2 Verifying : libpq-13.5-1.el8.x86_64 1/2 Verifying : postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 2/2 Installed products updated. Installed: libpq-13.5-1.el8.x86_64 postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 Complete!
インストール後、クライアントのバージョンを確認します。
$ psql --version psql (PostgreSQL) 10.23
確かにバージョン10.23のクライアントですね。
それでは、10.23のクライアントを使ってAurora PostgreSQL 15.2に接続します。
# Secrets Managerから認証情報を取得 $ get_secrets_value=$(aws secretsmanager get-secret-value \ --secret-id db-cluster/postgresAdmin \ --region us-east-1 \ | jq -r .SecretString) $ export PGHOST=$(echo "${get_secrets_value}" | jq -r .host) $ export PGPORT=$(echo "${get_secrets_value}" | jq -r .port) $ export PGDATABASE=$(echo "${get_secrets_value}" | jq -r .dbname) $ export PGUSER=$(echo "${get_secrets_value}" | jq -r .username) $ export PGPASSWORD=$(echo "${get_secrets_value}" | jq -r .password) $ psql psql (10.23, server 15.2) WARNING: psql major version 10, server major version 15. Some psql features might not work. SSL connection (protocol: TLSv1.2, cipher: AES128-SHA256, bits: 128, compression: off) Type "help" for help.
「クライアントpsql
とサーバーのメジャーバージョンが違うため、psql
の機能が動作しないかもしれない」と警告されました。これはあまり気分が良いものではありません。
また、pg_dump
に至っては「バージョンが異なるため中止する」となってしまいました。
$ pg_dump pg_dump: server version: 15.2; pg_dump version: 10.23 pg_dump: aborting because of server version mismatch
これはクライアントとサーバーのバージョンを合わせたくなりますね。
PostgreSQL 15のクライアントのインストール
Application Streamsの確認
次にPostgreSQL 15のクライアントを指定してインストールします。
これは「Application StreamsでPostgreSQL 15のストリームを指定する」ことで行えます。
Application StreamsとはコアとなるOSパッケージと異なるライフサイクルで提供するパッケージ管理形式です。
以下記事でもApplication Streamsでストリームを指定してPythonをインストールしています。
Application Streamsを使う場合は、ライフサイクルに注意する必要があります。Application Streamsにおけるライフサイクルの考え方はRed HatのSAの方のスライドが参考になります。
RHEL 8におけるPostgreSQL 15の廃止日は2028/5です。なお、RHEL 8のEOLは2029/5です。
抜粋 : Red Hat Enterprise Linux Application Streams Life Cycle - Red Hat Customer Portal
実際にApplication Streamsを確認してみましょう。
RHEL 8で使用できるApplication Streamsのモジュール一覧を確認します。
$ sudo dnf module list Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) 92 kB/s | 4.5 kB 00:00 Red Hat Enterprise Linux 8 for x86_64 - BaseOS from RHUI (RPMs) 95 kB/s | 4.1 kB 00:00 Red Hat Ansible Engine 2 for RHEL 8 (RPMs) from RHUI 95 kB/s | 4.0 kB 00:00 RHUI Client Configuration Server 8 43 kB/s | 2.0 kB 00:00 Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary 389-ds 1.4 389 Directory Server (base) ant 1.10 [d] common [ Java build tool d] container-tools rhel8 [d] common [ Most recent (rolling) versions of podman, buildah, skopeo, runc, conm d] on, runc, conmon, CRIU, Udica, etc as well as dependencies such as co ntainer-selinux built and tested together, and updated as frequently as every 12 weeks. container-tools 1.0 common [ Stable versions of podman 1.0, buildah 1.5, skopeo 0.1, runc, conmon, d] CRIU, Udica, etc as well as dependencies such as container-selinux b uilt and tested together, and supported for 24 months. container-tools 2.0 common [ Stable versions of podman 1.6, buildah 1.11, skopeo 0.1, runc, conmon d] , etc as well as dependencies such as container-selinux built and tes ted together, and supported as documented on the Application Stream l ifecycle page. container-tools 3.0 common [ Stable versions of podman 3.0, buildah 1.19, skopeo 1.2, runc, conmon d] , CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and supported as documented on the Applica tion Stream lifecycle page. container-tools 4.0 common [ Stable versions of podman 4.0, buildah 1.24, skopeo 1.6, runc, conmon d] , CRIU, Udica, etc as well as dependencies such as container-selinux built and tested together, and supported as documented on the Applica tion Stream lifecycle page. eclipse rhel8 java [d] An open, extensible IDE and application platform freeradius 3.0 [d] server [ High-performance and highly configurable free RADIUS server d] gimp 2.8 [d] common [ gimp module d], deve l go-toolset rhel8 [d] common [ Go d] httpd 2.4 [d] common [ Apache HTTP Server d], deve l, minim al idm DL1 adtrust, The Red Hat Enterprise Linux Identity Management system module client, common [d], dns , server idm client [d] common [ RHEL IdM long term support client module d] inkscape 0.92.3 [d] common [ Unsupported. Obsoleted by the inkscape1 package d] javapackages-runtime 201801 [d] common [ Basic runtime utilities to support Java applications d] jaxb 4 [d] common [ Jakarta XML Binding API and Implementation d] jmc rhel8 [d] common [ Java Mission Control is a profiling and diagnostics tool for the Hots d], core pot JVM libselinux-python 2.8 common Python 2 bindings for libselinux llvm-toolset rhel8 [d] common [ LLVM d] log4j 2 [d] common [ Java logging library d] mailman 2.1 [d] common [ Electronic mail discussion and e-newsletter lists managing software d] mariadb 10.3 [d] client, MariaDB Module galera, server [ d] mariadb 10.5 client, MariaDB Module galera, server [ d] maven 3.5 [d] common [ Java project management and project comprehension tool d] maven 3.6 common [ Java project management and project comprehension tool d] maven 3.8 common [ Java project management and project comprehension tool d] mercurial 4.8 [d] common [ Mercurial -- a distributed SCM d] mercurial 6.2 common Mercurial -- a distributed SCM mod_auth_openidc 2.3 [d] default Apache module suporting OpenID Connect authentication [d] mysql 8.0 [d] client, MySQL Module server [ d] nginx 1.14 [d] common [ nginx webserver d] nginx 1.16 common [ nginx webserver d] nginx 1.18 common [ nginx webserver d] nginx 1.20 common [ nginx webserver d] nginx 1.22 common [ nginx webserver d] nodejs 10 [d] common [ Javascript runtime d], deve lopment, minimal , s2i nodejs 12 common [ Javascript runtime d], deve lopment, minimal , s2i nodejs 14 common [ Javascript runtime d], deve lopment, minimal , s2i nodejs 16 common [ Javascript runtime d], deve lopment, minimal , s2i nodejs 18 common [ Javascript runtime d], deve lopment, minimal , s2i parfait 0.5 common Parfait Module perl 5.24 common [ Practical Extraction and Report Language d], mini mal perl 5.26 [d] common [ Practical Extraction and Report Language d], mini mal perl 5.30 common [ Practical Extraction and Report Language d], mini mal perl 5.32 common [ Practical Extraction and Report Language d], mini mal perl-App-cpanminus 1.7044 [d] common [ Get, unpack, build and install CPAN modules d] perl-DBD-MySQL 4.046 [d] common [ A MySQL interface for Perl d] perl-DBD-Pg 3.7 [d] common [ A PostgreSQL interface for Perl d] perl-DBD-SQLite 1.58 [d] common [ SQLite DBI driver d] perl-DBI 1.641 [d] common [ A database access API for Perl d] perl-FCGI 0.78 [d] common [ FastCGI Perl bindings d] perl-IO-Socket-SSL 2.066 [d] common [ Perl library for transparent TLS d] perl-YAML 1.24 [d] common [ Perl parser for YAML d] perl-libwww-perl 6.34 [d] common [ A Perl interface to the World-Wide Web d] php 7.2 [d] common [ PHP scripting language d], deve l, minim al php 7.3 common [ PHP scripting language d], deve l, minim al php 7.4 common [ PHP scripting language d], deve l, minim al php 8.0 common [ PHP scripting language d], deve l, minim al pki-core 10.6 PKI Core module for PKI 10.6 or later pki-deps 10.6 PKI Dependencies module for PKI 10.6 or later pmdk 1_fileformat_v6 Persistent Memory Development Kit (former NVML) postgresql 9.6 client, PostgreSQL server and client module server [ d] postgresql 10 [d][e] client, PostgreSQL server and client module server [ d] postgresql 12 client, PostgreSQL server and client module server [ d] postgresql 13 client, PostgreSQL server and client module server [ d] postgresql 15 client, PostgreSQL server and client module server [ d] python27 2.7 [d] common [ Python programming language, version 2.7 d] python36 3.6 [d] build, c Python programming language, version 3.6 ommon [d ] python38 3.8 [d] build, c Python programming language, version 3.8 ommon [d ] python39 3.9 [d] build, c Python programming language, version 3.9 ommon [d ] redis 5 [d] common [ Redis persistent key-value database d] redis 6 common [ Redis persistent key-value database d] rhn-tools 1.0 [d] common [ Red Hat Satellite 5 tools for RHEL d] ruby 2.5 [d] common [ An interpreter of object-oriented scripting language d] ruby 2.6 common [ An interpreter of object-oriented scripting language d] ruby 2.7 common [ An interpreter of object-oriented scripting language d] ruby 3.0 common [ An interpreter of object-oriented scripting language d] ruby 3.1 common [ An interpreter of object-oriented scripting language d] rust-toolset rhel8 [d] common [ Rust d] satellite-5-client 1.0 [d] common [ Red Hat Satellite 5 client packages d], gui scala 2.10 [d] common [ A hybrid functional/object-oriented language for the JVM d] squid 4 [d] common [ Squid - Optimising Web Delivery d] subversion 1.10 [d] common [ Apache Subversion d], serv er subversion 1.14 common [ Apache Subversion d], serv er swig 3.0 [d] common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete swig 4.0 common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete swig 4.1 common [ Connects C/C++/Objective C to some high-level programming languages d], comp lete varnish 6 [d] common [ Varnish HTTP cache d] virt rhel [d] common [ Virtualization module d] Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
多すぎて見切れないので、PostgreSQLに絞って確認します。
$ sudo dnf module list postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:00:52 ago on Tue 30 May 2023 06:25:59 AM UTC. Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d][e] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module postgresql 15 client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
PostgreSQLのモジュールに5つのストリームがあることが分かります。
また、10 [d][e]
となっているため、PostgreSQL 10がデフォルトかつ使用可能なストリームになっているようですね。
使用したいPostgreSQL 15のストリームの詳細を確認します。
$ sudo dnf module info postgresql:15 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:02:31 ago on Tue 30 May 2023 06:25:59 AM UTC. Name : postgresql Stream : 15 Version : 8080020230212204728 Context : fd72936b Architecture : x86_64 Profiles : client, server [d] Default profiles : server Repo : rhel-8-appstream-rhui-rpms Summary : PostgreSQL server and client module Description : PostgreSQL is an advanced Object-Relational database management system (DBMS). The postgresql-server package contains the programs needed to create and run a PostgreSQL server, which will in turn allow you to create and maintain PostgreSQL databases. The base postgresql package contains the client programs that you'll need to access a PostgreSQL DBMS server. Requires : platform:[el8] Artifacts : pg_repack-0:1.4.8-1.module+el8.8.0+17071+aaaceaa4.src : pg_repack-0:1.4.8-1.module+el8.8.0+17071+aaaceaa4.x86_64 : pg_repack-debuginfo-0:1.4.8-1.module+el8.8.0+17071+aaaceaa4.x86_64 : pg_repack-debugsource-0:1.4.8-1.module+el8.8.0+17071+aaaceaa4.x86_64 : pgaudit-0:1.7.0-1.module+el8.8.0+17071+aaaceaa4.src : pgaudit-0:1.7.0-1.module+el8.8.0+17071+aaaceaa4.x86_64 : pgaudit-debuginfo-0:1.7.0-1.module+el8.8.0+17071+aaaceaa4.x86_64 : pgaudit-debugsource-0:1.7.0-1.module+el8.8.0+17071+aaaceaa4.x86_64 : postgres-decoderbufs-0:1.9.7-1.Final.module+el8.8.0+17071+aaaceaa4.src : postgres-decoderbufs-0:1.9.7-1.Final.module+el8.8.0+17071+aaaceaa4.x86_64 : postgres-decoderbufs-debuginfo-0:1.9.7-1.Final.module+el8.8.0+17071+aaaceaa4.x86_64 : postgres-decoderbufs-debugsource-0:1.9.7-1.Final.module+el8.8.0+17071+aaaceaa4.x86_64 : postgresql-0:15.2-1.module+el8.8.0+18155+992b6275.src : postgresql-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-contrib-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-contrib-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-debugsource-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-docs-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-docs-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-plperl-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-plperl-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-plpython3-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-plpython3-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-pltcl-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-pltcl-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-private-devel-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-private-libs-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-private-libs-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-server-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-server-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-server-devel-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-server-devel-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-static-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-test-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-test-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-test-rpm-macros-0:15.2-1.module+el8.8.0+18155+992b6275.noarch : postgresql-upgrade-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-upgrade-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-upgrade-devel-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 : postgresql-upgrade-devel-debuginfo-0:15.2-1.module+el8.8.0+18155+992b6275.x86_64 Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled, [a]ctive
アーキテクチャやプロファイルの情報を確認できますね。
デフォルトのプロファイルはserver
です。
$ sudo dnf module info postgresql:15 --profile Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:02:57 ago on Tue 30 May 2023 06:25:59 AM UTC. Name : postgresql:15:8080020230212204728:fd72936b:x86_64 client : postgresql server : postgresql-server
そのため、プロファイルを指定しない場合はPostgreSQLサーバーがインストールされます。
PostgreSQL 15のストリームの有効化
次にPostgreSQL 15のストリームの有効化を行います。
$ sudo dnf module enable postgresql:15 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:05:18 ago on Tue 30 May 2023 06:25:59 AM UTC. Dependencies resolved. The operation would result in switching of module 'postgresql' stream '10' to stream '15' Error: It is not possible to switch enabled streams of a module unless explicitly enabled via configuration optionmodule_stream_switch. It is recommended to rather remove all installed content from the module, and reset the module using 'dnf module reset <module_name>' command. After you reset the module, you can install the other stream.
すでにPostgreSQL 10のストリームを使っているため怒られました。
RHELのドキュメントにもモジュールに対して有効化できるストリームは1つのみと記載がありました。
あるモジュールの中で同時にアクティブにできるストリームは 1 つだけです。したがって、1 つのシステムにインストールできるコンポーネントは、1 つのバージョンだけです。
ユーザー空間コンポーネントのインストール、管理、および削除 Red Hat Enterprise Linux 8 | Red Hat Customer Portal
指示に従い、PostgreSQLモジュールのストリームをリセットします。
# PostgreSQLモジュールのストリームをリセット $ sudo dnf module reset postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:06:05 ago on Tue 30 May 2023 06:25:59 AM UTC. Dependencies resolved. =================================================================================================================== Package Architecture Version Repository Size =================================================================================================================== Resetting modules: postgresql Transaction Summary =================================================================================================================== Is this ok [y/N]: y Complete! # PostgreSQLのストリーム一覧を確認 $ sudo dnf module list postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:06:18 ago on Tue 30 May 2023 06:25:59 AM UTC. Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module postgresql 15 client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
リセットすると10 [d]
と、PostgreSQL 10のストリームが有効でなくなりました。
ちなみに、モジュールストリームをリセットしただけで、インストール済みのPostgreSQLのクライアントは削除されていません。
$ rpm -qa | grep postgresql postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 $ psql --version psql (PostgreSQL) 10.23
PostgreSQL 15のストリームを有効化します。
$ sudo dnf module enable postgresql:15 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:07:15 ago on Tue 30 May 2023 06:25:59 AM UTC. Dependencies resolved. =================================================================================================================== Package Architecture Version Repository Size =================================================================================================================== Enabling module streams: postgresql 15 Transaction Summary =================================================================================================================== Is this ok [y/N]: y Complete!
PostgreSQLのストリーム一覧を確認すると15 [e]
と、PostgreSQL 15のストリームが有効になっていますね。
$ sudo dnf module list postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:07:29 ago on Tue 30 May 2023 06:25:59 AM UTC. Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module postgresql 15 [e] client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
インストール可能なPostgreSQLのクライアント一覧を確認するPostgreSQL 10ではなく、15になっていますね。
$ sudo dnf list postgresql --showduplicates Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:01:48 ago on Tue 30 May 2023 09:06:18 AM UTC. Installed Packages postgresql.x86_64 10.23-1.module+el8.7.0+17280+3a452e1f @rhel-8-appstream-rhui-rpms Available Packages postgresql.x86_64 15.2-1.module+el8.8.0+18155+992b6275 rhel-8-appstream-rhui-rpms
PostgreSQLクライアントのインストール
それではPostgreSQLクライアントをインストールします。
$ sudo dnf install postgresql -v Loaded plugins: amazon-id, builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, product-id, repoclosure, repodiff, repograph, repomanage, reposync, subscription-manager, system-upgrade, uploadprofile Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. DNF version: 4.7.0 cachedir: /var/cache/dnf User-Agent: constructed: 'libdnf (Red Hat Enterprise Linux 8.8; generic; Linux.x86_64)' repo: using cache for: rhel-8-appstream-rhui-rpms rhel-8-appstream-rhui-rpms: using metadata from Thu 25 May 2023 08:23:08 AM UTC. repo: using cache for: rhel-8-baseos-rhui-rpms rhel-8-baseos-rhui-rpms: using metadata from Fri 19 May 2023 01:40:24 PM UTC. repo: using cache for: ansible-2-for-rhel-8-rhui-rpms ansible-2-for-rhel-8-rhui-rpms: using metadata from Thu 14 Oct 2021 07:37:02 PM UTC. repo: using cache for: rhui-client-config-server-8 rhui-client-config-server-8: using metadata from Fri 14 Apr 2023 09:48:30 AM UTC. Last metadata expiration check: 0:09:08 ago on Tue 30 May 2023 06:25:59 AM UTC. Package postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 is already installed. --> Starting dependency resolution ---> Package postgresql-private-libs.x86_64 15.2-1.module+el8.8.0+18155+992b6275 will be installed ---> Package postgresql.x86_64 10.23-1.module+el8.7.0+17280+3a452e1f will be upgraded ---> Package postgresql.x86_64 15.2-1.module+el8.8.0+18155+992b6275 will be an upgrade --> Finished dependency resolution Dependencies resolved. =================================================================================================================== Package Arch Version Repository Size =================================================================================================================== Upgrading: postgresql x86_64 15.2-1.module+el8.8.0+18155+992b6275 rhel-8-appstream-rhui-rpms 1.7 M Installing dependencies: postgresql-private-libs x86_64 15.2-1.module+el8.8.0+18155+992b6275 rhel-8-appstream-rhui-rpms 132 k Transaction Summary =================================================================================================================== Install 1 Package Upgrade 1 Package Total download size: 1.8 M Is this ok [y/N]: y Downloading Packages: (1/2): postgresql-private-libs-15.2-1.module+el8.8.0+18155+992b6275.x86_64.rpm 2.2 MB/s | 132 kB 00:00 (2/2): postgresql-15.2-1.module+el8.8.0+18155+992b6275.x86_64.rpm 15 MB/s | 1.7 MB 00:00 ------------------------------------------------------------------------------------------------------------------- Total 12 MB/s | 1.8 MB 00:00 Using rpmkeys executable at /bin/rpmkeys to verify signatures Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : postgresql-private-libs-15.2-1.module+el8.8.0+18155+992b6275.x86_64 1/3 Upgrading : postgresql-15.2-1.module+el8.8.0+18155+992b6275.x86_64 2/3 Cleanup : postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 3/3 Running scriptlet: postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 3/3 Verifying : postgresql-private-libs-15.2-1.module+el8.8.0+18155+992b6275.x86_64 1/3 Verifying : postgresql-15.2-1.module+el8.8.0+18155+992b6275.x86_64 2/3 Verifying : postgresql-10.23-1.module+el8.7.0+17280+3a452e1f.x86_64 3/3 Completion plugin: Generating completion cache... Installed products updated. Upgraded: postgresql-15.2-1.module+el8.8.0+18155+992b6275.x86_64 Installed: postgresql-private-libs-15.2-1.module+el8.8.0+18155+992b6275.x86_64 Upgraded: postgresql-15.2-1.module+el8.8.0+18155+992b6275.x86_64 Installed: postgresql-private-libs-15.2-1.module+el8.8.0+18155+992b6275.x86_64 Complete!
PostgreSQLのクライアントが10.23から15.2にアップデートされましたね。
rpm
やpsql
などからも確かにPostgreSQL 15.2のクライアントがインストールされたことが分かります。
$ rpm -qa | grep postgresql postgresql-15.2-1.module+el8.8.0+18155+992b6275.x86_64 postgresql-private-libs-15.2-1.module+el8.8.0+18155+992b6275.x86_64 $ psql --version psql (PostgreSQL) 15.2 $ sudo dnf info postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:00:11 ago on Tue 30 May 2023 06:38:47 AM UTC. Installed Packages Name : postgresql Version : 15.2 Release : 1.module+el8.8.0+18155+992b6275 Architecture : x86_64 Size : 6.8 M Source : postgresql-15.2-1.module+el8.8.0+18155+992b6275.src.rpm Repository : @System From repo : rhel-8-appstream-rhui-rpms Summary : PostgreSQL client programs URL : http://www.postgresql.org/ License : PostgreSQL Description : PostgreSQL is an advanced Object-Relational database management system (DBMS). : The base postgresql package contains the client programs that you'll need to : access a PostgreSQL DBMS server, as well as HTML documentation for the whole : system. These client programs can be located on the same machine as the : PostgreSQL server, or on a remote machine that accesses a PostgreSQL server : over a network connection. The PostgreSQL server can be found in the : postgresql-server sub-package.
なお、プロファイルを指定していないためかclient
のプロファイルに[i]
は付与されていません。
$ sudo dnf module list postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:09:43 ago on Tue 30 May 2023 06:25:59 AM UTC. Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module postgresql 15 [e] client, server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
psql
やpg_dump
で警告が出ないか確認します。
$ psql psql (15.2) SSL connection (protocol: TLSv1.2, cipher: AES128-SHA256, compression: off) Type "help" for help. testDB=> \q $ pg_dump -- -- PostgreSQL database dump -- -- Dumped from database version 15.2 -- Dumped by pg_dump version 15.2 SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; -- -- PostgreSQL database dump complete --
警告なく、正常に実行できましたね。
(おまけ) ストリームを指定してインストールする
先ほどはストリームを有効化してからパッケージをインストールしましたが、インストール時に直接ストリームを指定することも可能です。
その場合はdnf module install module-name:stream
かdnf install @module-name:stream
で行います。
試しにdnf module install postgresql:15
を叩いてみましょう。
$ sudo dnf module install postgresql:15 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:01:34 ago on Tue 30 May 2023 06:38:47 AM UTC. Dependencies resolved. =================================================================================================================== Package Arch Version Repository Size =================================================================================================================== Installing group/module packages: postgresql-server x86_64 15.2-1.module+el8.8.0+18155+992b6275 rhel-8-appstream-rhui-rpms 6.0 M Installing dependencies: libicu x86_64 60.3-2.el8_1 rhel-8-baseos-rhui-rpms 8.8 M Installing module profiles: postgresql/server Transaction Summary =================================================================================================================== Install 2 Packages Total download size: 15 M Installed size: 56 M Is this ok [y/N]: N Operation aborted.
プロファイルを指定していないため、PostgreSQLサーバーがインストールされそうになりましたね。
sudo dnf module install postgresql:15/client
でプロファイルを指定して、PostgreSQLのクライアントをインストールしてみます。
$ sudo dnf module install postgresql:15/client Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:01:46 ago on Tue 30 May 2023 06:38:47 AM UTC. Dependencies resolved. =================================================================================================================== Package Architecture Version Repository Size =================================================================================================================== Installing module profiles: postgresql/client Transaction Summary =================================================================================================================== Is this ok [y/N]: y Complete!
インストール後、PostgreSQLのストリーム一覧を確認します。
$ sudo dnf module list postgresql Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. Last metadata expiration check: 0:02:31 ago on Tue 30 May 2023 06:38:47 AM UTC. Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs) Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module postgresql 10 [d] client, server [d] PostgreSQL server and client module postgresql 12 client, server [d] PostgreSQL server and client module postgresql 13 client, server [d] PostgreSQL server and client module postgresql 15 [e] client [i], server [d] PostgreSQL server and client module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
client [i]
とクライアントのプロファイルがインストールされたことが分かります。
Application Streamsを使いこなそう
Red Hat Enterprise Linux 8 に PostgreSQL 15 のクライアントをインストールしてみました。
ライフサイクルに注意が必要ですが、Application Streamsを使いこなすことで新しいバージョンのパッケージをインストールすることができます。
新しいバージョンのソフトウェアをインストールしたいがために、ソースからインストールしたり、野性のリポジトリ経由でインストールするということが減りそうですね。
この記事が誰かの助けになれば幸いです。
以上、AWS事業本部 コンサルティング部の のんピ(@non____97)でした!