--- title: VMware Tanzu for Postgres 18.2をRocky Linuxにインストールするメモ summary: この記事では、VMware Tanzu for Postgres 18.2をRocky Linux 9にインストールし、設定・拡張機能追加までの手順を紹介します。 tags: ["Tanzu", "PostgreSQL", "Rocky"] categories: ["Middleware", "RDBMS", "PostgreSQL"] date: 2026-01-05T11:15:31Z updated: 2026-02-25T06:28:57.800Z --- [VMware Tanzu for Postgres 18.2](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-for-postgres/18-2/tnz-postgres/index.html)をRocky Linux 9にインストールする手順をメモします。 **目次** ### VMware Tanzu for Postgresのダウンロード [Broadcom Support](https://support.broadcom.com)にログインして、[VMware Tanzu for Postgresのダウンロードページ](https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware%20Tanzu%20for%20Postgres)にアクセスします。 最新バージョンを選択します。 ![image](https://s3.ik.am/ikam/_/1771999989178_pasted-image.png) "I agree to the Terms and Conditions"にチェックを入れて、 ![image](https://s3.ik.am/ikam/_/1769080281957_pasted-image.png) EL9用のインストーラーを`~/Downloads`にダウンロードします。 ![image](https://s3.ik.am/ikam/_/1772000093245_pasted-image.png) ```bash cd ~/Downloads mkdir -p vmware-postgres-18.2.0 unzip -d vmware-postgres-18.2.0 vmware-postgres-18.2.0.el9.x86_64.zip ``` ### Rocky Linux 9へのインストール Rocky Linux 9環境は[OrbStack](https://orbstack.dev/)の[Linux Machine](https://docs.orbstack.dev/machines/)を使って構築します。 VMware Tanzu for Postgresはx86_64にしか対応していないので、x86_64エミュレーションを使ってRocky Linux 9マシンを作成します。 ```bash orb create -a amd64 rocky:9 tanzu-postgres orb shell -m tanzu-postgres ``` ドキュメントには書いてありませんでしたが、VMware Tanzu for Postgresのインストールには`libssh2`パッケージが必要でした。 `libssh2`パッケージをインストールするにはEPEL(Extra Packages for Enterprise Linux)リポジトリを有効化する必要があります。 ```bash sudo dnf install epel-release -y ``` メタデータを更新します。 ```bash sudo dnf clean all sudo dnf makecache ``` `libssh2`(その他、あると便利な)パッケージをインストールします。 ```bash sudo dnf install libssh2 which lsof vim -y ``` ### VMware Tanzu for Postgresのインストール VMware Tanzu for Postgresのrpmパッケージをインストールします。 ```bash cd /Users/$USER/Downloads/vmware-postgres-18.2.0 sudo dnf install ./vmware-postgres18-18.2-1.el9.x86_64.rpm ./vmware-postgres18-libs-18.2-1.el9.x86_64.rpm -y ``` `postgres`ユーザーができるので、ユーザーを切り替えてデータベースを初期化します。 ```bash sudo su - postgres ``` データベースを初期化します。 ```bash initdb -D /var/lib/pgsql/data ``` 一旦、元のユーザーに戻ります。 ```bash exit ``` ### systemdサービスファイルの作成 VMware Tanzu for Postgresにはサービス化のためのsystemdユニットファイルが含まれていないので、自分で作成します。 ```bash cat <<'EOF' | sudo tee /etc/systemd/system/postgresql.service > /dev/null [Unit] Description=VMware Tanzu for Postgres After=network.target [Service] Type=forking User=postgres Group=postgres ExecStart=/opt/vmware/postgres/18/bin/pg_ctl start -D /var/lib/pgsql/data -l /var/lib/pgsql/data/logfile ExecStop=/opt/vmware/postgres/18/bin/pg_ctl stop -D /var/lib/pgsql/data ExecReload=/opt/vmware/postgres/18/bin/pg_ctl reload -D /var/lib/pgsql/data TimeoutSec=300 [Install] WantedBy=multi-user.target EOF ``` systemdデーモンをリロードして、PostgreSQLサービスを有効化・起動します。 ```bash sudo systemctl daemon-reload sudo systemctl enable postgresql sudo systemctl start postgresql sudo systemctl status postgresql ``` PostgreSQLが起動していることを確認します。 ```bash $ sudo lsof -i -n -P | grep -i listen postgres 1700 postgres 9u IPv6 49812992 0t0 TCP [::1]:5432 (LISTEN) postgres 1700 postgres 10u IPv4 49812993 0t0 TCP 127.0.0.1:5432 (LISTEN) ``` `postgres`ユーザーに切り替えて、PostgreSQLに接続します。 ```bash sudo su - postgres ``` ```bash $ psql psql (18.2 (VMware Postgres 18.2.0)) Type "help" for help. postgres=# ``` 初期状態を確認します。 ```bash postgres=# SELECT version(); version ---------------------------------------------------------------------------------------------------------------------------------------- PostgreSQL 18.2 (VMware Postgres 18.2.0) on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-11), 64-bit (1 row) postgres=# \l List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges -----------+----------+----------+-----------------+------------+------------+--------+-----------+----------------------- postgres | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | template0 | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/postgres + | | | | | | | | postgres=CTc/postgres (3 rows) postgres=# \d Did not find any relations. ``` 利用可能な拡張機能を確認します。 ```bash postgres=# SELECT * FROM pg_available_extensions ORDER BY name; name | default_version | installed_version | comment --------------------+-----------------+-------------------+------------------------------------------------------------------------ amcheck | 1.5 | | functions for verifying relation integrity autoinc | 1.0 | | functions for autoincrementing fields bloom | 1.0 | | bloom access method - signature file based index bool_plperl | 1.0 | | transform between bool and plperl bool_plperlu | 1.0 | | transform between bool and plperlu btree_gin | 1.3 | | support for indexing common datatypes in GIN btree_gist | 1.8 | | support for indexing common datatypes in GiST citext | 1.8 | | data type for case-insensitive character strings cube | 1.5 | | data type for multidimensional cubes dblink | 1.2 | | connect to other PostgreSQL databases from within a database dict_int | 1.0 | | text search dictionary template for integers dict_xsyn | 1.0 | | text search dictionary template for extended synonym processing earthdistance | 1.2 | | calculate great-circle distances on the surface of the Earth file_fdw | 1.0 | | foreign-data wrapper for flat file access fuzzystrmatch | 1.2 | | determine similarities and distance between strings hstore | 1.8 | | data type for storing sets of (key, value) pairs hstore_plperl | 1.0 | | transform between hstore and plperl hstore_plperlu | 1.0 | | transform between hstore and plperlu hstore_plpython3u | 1.0 | | transform between hstore and plpython3u insert_username | 1.0 | | functions for tracking who changed a table intagg | 1.1 | | integer aggregator and enumerator (obsolete) intarray | 1.5 | | functions, operators, and index support for 1-D arrays of integers isn | 1.3 | | data types for international product numbering standards jsonb_plperl | 1.0 | | transform between jsonb and plperl jsonb_plperlu | 1.0 | | transform between jsonb and plperlu jsonb_plpython3u | 1.0 | | transform between jsonb and plpython3u lo | 1.2 | | Large Object maintenance ltree | 1.3 | | data type for hierarchical tree-like structures ltree_plpython3u | 1.0 | | transform between ltree and plpython3u moddatetime | 1.0 | | functions for tracking last modification time pageinspect | 1.13 | | inspect the contents of database pages at a low level pg_buffercache | 1.6 | | examine the shared buffer cache pg_freespacemap | 1.3 | | examine the free space map (FSM) pg_logicalinspect | 1.0 | | functions to inspect logical decoding components pg_prewarm | 1.2 | | prewarm relation data pg_stat_statements | 1.12 | | track planning and execution statistics of all SQL statements executed pg_surgery | 1.0 | | extension to perform surgery on a damaged relation pg_trgm | 1.6 | | text similarity measurement and index searching based on trigrams pg_visibility | 1.2 | | examine the visibility map (VM) and page-level visibility info pg_walinspect | 1.1 | | functions to inspect contents of PostgreSQL Write-Ahead Log pgcrypto | 1.4 | | cryptographic functions pgrowlocks | 1.2 | | show row-level locking information pgstattuple | 1.5 | | show tuple-level statistics plperl | 1.0 | | PL/Perl procedural language plperlu | 1.0 | | PL/PerlU untrusted procedural language plpgsql | 1.0 | 1.0 | PL/pgSQL procedural language plpython3u | 1.0 | | PL/Python3U untrusted procedural language postgres_fdw | 1.2 | | foreign-data wrapper for remote PostgreSQL servers refint | 1.0 | | functions for implementing referential integrity (obsolete) seg | 1.4 | | data type for representing line segments or floating-point intervals sslinfo | 1.2 | | information about SSL certificates tablefunc | 1.0 | | functions that manipulate whole tables, including crosstab tcn | 1.0 | | Triggered change notifications tsm_system_rows | 1.0 | | TABLESAMPLE method which accepts number of rows as a limit tsm_system_time | 1.0 | | TABLESAMPLE method which accepts time in milliseconds as a limit unaccent | 1.1 | | text search dictionary that removes accents uuid-ossp | 1.1 | | generate universally unique identifiers (UUIDs) vector | 0.8.1 | | vector data type and ivfflat and hnsw access methods xml2 | 1.2 | | XPath querying and XSLT (59 rows) ``` サポートされている拡張一覧は[こちら](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-for-postgres/18-2/tnz-postgres/software-components.html)です。18.1には含まれていなかったpgvectorが復活しました。 PostgreSQL 18から導入された`uuidv7`関数を試してみます。 ```bash postgres=# SELECT uuidv7(); uuidv7 -------------------------------------- 019b8e14-dd7e-79dd-a6d8-65a20839934e (1 row) ``` ### データベースとユーザーの作成 [Vultrのガイド](https://docs.vultr.com/how-to-install-postgresql-database-server-on-ubuntu-22-04)を参考に、`hospital`データベースと`db_manager`ユーザーを作成し、適切な権限を付与します。 ```bash psql -c "CREATE DATABASE hospital;" psql -c "CREATE ROLE db_manager WITH LOGIN PASSWORD 'strong-password';" psql -d hospital -c " GRANT ALL PRIVILEGES ON DATABASE hospital TO db_manager; GRANT USAGE, CREATE ON SCHEMA public TO db_manager; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON TABLES TO db_manager; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL PRIVILEGES ON SEQUENCES TO db_manager; " ``` テーブルを作成し、データを挿入して、クエリを実行してみます。 ```bash psql -d hospital -c "CREATE TABLE doctors( doctor_id SERIAL PRIMARY KEY, first_name VARCHAR(50), last_name VARCHAR(50), appointment_date DATE );" psql -d hospital -c "INSERT INTO doctors (first_name, last_name, appointment_date) VALUES ('John', 'Doe', '2024-10-01'), ('Jane', 'Smith', '2024-10-02'), ('Emily', 'Johnson', '2024-10-03'), ('Michael', 'Brown', '2024-10-04'), ('Sarah', 'Davis', '2024-10-05');" psql -d hospital -c "SELECT * FROM doctors WHERE appointment_date >= '2024-10-03';" ``` ``` doctor_id | first_name | last_name | appointment_date -----------+------------+-----------+------------------ 3 | Emily | Johnson | 2024-10-03 4 | Michael | Brown | 2024-10-04 5 | Sarah | Davis | 2024-10-05 (3 rows) ``` リモート接続を有効化します。 ```bash echo "host hospital db_manager 0.0.0.0/0 scram-sha-256" >> /var/lib/pgsql/data/pg_hba.conf sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /var/lib/pgsql/data/postgresql.conf ``` PostgreSQLサービスを再起動します。 ```bash exit sudo systemctl restart postgresql ``` `pg_hba.conf`の設定を確認します。 ```bash $ sudo -u postgres /opt/vmware/postgres/18/bin/psql -c "SELECT * FROM pg_hba_file_rules;" rule_number | file_name | line_number | type | database | user_name | address | netmask | auth_method | options | error -------------+---------------------------------+-------------+-------+---------------+--------------+-----------+-----------------------------------------+---------------+---------+------- 1 | /var/lib/pgsql/data/pg_hba.conf | 117 | local | {all} | {all} | | | trust | | 2 | /var/lib/pgsql/data/pg_hba.conf | 119 | host | {all} | {all} | 127.0.0.1 | 255.255.255.255 | trust | | 3 | /var/lib/pgsql/data/pg_hba.conf | 121 | host | {all} | {all} | ::1 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | trust | | 4 | /var/lib/pgsql/data/pg_hba.conf | 124 | local | {replication} | {all} | | | trust | | 5 | /var/lib/pgsql/data/pg_hba.conf | 125 | host | {replication} | {all} | 127.0.0.1 | 255.255.255.255 | trust | | 6 | /var/lib/pgsql/data/pg_hba.conf | 126 | host | {replication} | {all} | ::1 | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | trust | | 7 | /var/lib/pgsql/data/pg_hba.conf | 127 | host | {hospital} | {db_manager} | 0.0.0.0 | 0.0.0.0 | scram-sha-256 | | (7 rows) ``` リモート接続を確認します。まずはローカルホストで。 ```bash $ /opt/vmware/postgres/18/bin/psql "postgresql://db_manager:strong-password@localhost:5432/hospital" psql (18.2 (VMware Postgres 18.2.0)) Type "help" for help. hospital=> ``` 次に、Rocky LinuxマシンのIPアドレスを調べて、そのIPアドレスを使ってリモート接続を試みます。 ```bash $ ip addr | grep eth0 | tail -1 | awk '{print $2}' | awk -F '/' '{print $1}' 192.168.139.15 ``` ```bash $ /opt/vmware/postgres/18/bin/psql "postgresql://db_manager:strong-password@192.168.139.15:5432/hospital" psql (18.2 (VMware Postgres 18.2.0)) Type "help" for help. hospital=> ``` データを確認します。 ```bash hospital=> select * from doctors; doctor_id | first_name | last_name | appointment_date -----------+------------+-----------+------------------ 1 | John | Doe | 2024-10-01 2 | Jane | Smith | 2024-10-02 3 | Emily | Johnson | 2024-10-03 4 | Michael | Brown | 2024-10-04 5 | Sarah | Davis | 2024-10-05 (5 rows) ``` ### pg_hint_plan拡張機能のインストール VMware Tanzu for Postgresで`pg_hint_plan`拡張機能を使用するには、次の手順に従います。`pg_hint_plan`はクエリプランナーにヒントを与えるための拡張機能です。 https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-for-postgres/18-2/tnz-postgres/installing.html#pghintplan ```bash cd /Users/$USER/Downloads/vmware-postgres-18.2.0 sudo dnf install ./vmware-postgres18-pg_hint_plan-extension-1.8.0-5.el9.x86_64.rpm -y sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'pg_hint_plan'/" /var/lib/pgsql/data/postgresql.conf sudo systemctl restart postgresql ``` `pg_hint_plan`拡張機能が利用可能であることを確認します。 ```bash $ sudo -u postgres /opt/vmware/postgres/18/bin/psql -c "SELECT * FROM pg_available_extensions WHERE name LIKE '%hint%';" name | default_version | installed_version | comment --------------+-----------------+-------------------+-------------------------------- pg_hint_plan | 1.8.0 | | optimizer hints for PostgreSQL (1 row) ``` ### Linux Machineの削除 ```bash orb delete tanzu-postgres -f ``` --- 以上で、VMware Tanzu for Postgres 18.2をRocky Linux 9にインストールし、基本的な設定と操作を行う手順のメモを終わります。 [Patroniを使ったHA構成](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-for-postgres/18-2/tnz-postgres/high-availability.html)も試してみたいところですが、今回はここまでとします。→ [こちらの記事](/entries/901)に書きました