皆様、こんにちは
CentOS8のサポート期限が迫るなか、
AlmaLinux と Rocky Linuxのどちら移行するか未だに決めかねておりますが、
先ずはAlmaLinuxに、PostgreSQLとPgadmin4を導入します。
当初は、OSのVersionを8.4で止めようと思いましが、
依存関係で引っ掛かりましたので今回は、8.5まで上げております。
※8.5は、RHELの発表よりライフサイクルが短いため注意が必要です。
Red Hat Enterprise Linux 8 Life Cycle
https://access.redhat.com/support/policy/updates/errata#RHEL8_Life_Cycle
今回は、最新の安定版Version14を導入します。
(#、$はプロンプトです)
1、PostgreSQLのレポジトリをインストールします。
# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2、元々のPostgreSQLを無効にします。
# dnf -qy module disable postgresql
3、PostgreSQL14をインストールします。
# dnf install -y postgresql14-server
4、DBを初期化します。
# /usr/pgsql-14/bin/postgresql-14-setup initdb
5、サービスを有効化します。
# systemctl enable postgresql-14
6、初期設定をします。
・DB管理ユーザへスイッチします。
# su - postgres
$ cd /var/lib/pgsql/14/data/
・ローカルネットワークを許可します。
(192.168.aaa.0は自身のネットワークに合わせてください)
$ cp -p pg_hba.conf pg_hba.conf.orig
$ vi pg_hba.conf
-------------------------------------------------------------------
host all all 192.168.aaa.0/24 md5
-------------------------------------------------------------------
チューニングは、以下のサイトで
「https://pgtune.leopard.in.ua」より
Version:14
OS:Linux
DB Type:Web application
Total Memmory(RAM):8GB
SSD Storage
で選択すると以下の値となります。
これをpostgresql.confへ反映します。
-------------------------------------------------------------------
max_connections = 200
shared_buffers = 2GB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 5242kB
min_wal_size = 1GB
max_wal_size = 4GB
-------------------------------------------------------------------
7、PostgreSQLを起動します。
# systemctl restart postgresql-14
# su - postgres
$ psql -c "alter user postgres with password 'password'"
ALTER ROLE
$ sudo systemctl restart postgresql-14.service
8、pgadminを初期化します。
[root@ta69 site-packages]# /usr/pgadmin4/bin/setup-web.sh
Setting up pgAdmin 4 in web mode on a Redhat based platform...
Creating configuration database...
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user account:
Email address: hogehoge@expample.com
Password:ログインパスワード
Retype password:ログインパスワード
pgAdmin 4 - Application Initialisation
======================================
Creating storage and log directories...
Configuring SELinux...
The Apache web server is running and must be restarted for the pgAdmin 4 installation to complete. Continue (y/n)? y
Apache successfully restarted. You can now start using pgAdmin 4 in web mode at http://127.0.0.1/pgadmin4
※新しいPgadmin4では以下のディレクトリの作成は不要でした。
# mkdir -p /var/lib/pgadmin4/
# mkdir -p /var/log/pgadmin4/
それぞれ
/var/log/pgadmin
/var/lib/pgadmin
でディレクトリが自動で作成されます。
9、ブラウザーにて
http://AlmaLinuxサーバのIP/pgadmin4
で先程メールアドレスとパスワードを入力します。
(言語は日本語も選択できます。
では