1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Proxmox8 を試してみる その21 PostgreSQLサーバ構築(Docker, LXC)

Last updated at Posted at 2025-06-19

PostgreSQL を手っ取り早く使いたい

SQLの勉強用として PostgreSQL を構築したいと思いつつ、Docker, LXC で簡単に構築できるか調べてみました。

Docker での構築

先に言うと慣れもありますが自分は、Docker での構築が楽でした。ベースの環境も最近は、Windowsであれば WSL2 使えますからね。

こちらの方の記事がとても分かりやすかったです。

Docker 構築後の作業

PostgreSQL の初期設定で外部からの接続とかありますが、Docker で構築した場合は最低限の設定がされているためすぐに使い始めることができます。とはいってもアカウントを作成したりDBを作る必要がありますけどね。

postgres=# create role testuser with login password 'testuser';

postgres=# create database testdb owner = testuser encoding='UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0;

外部公開も compose.yml で "5432:5432" と指定してあるので、A5:SQL Mk-2 使えば楽ですね。

LXC での構築

Docker が楽と言っておきながら、Proxmox を使用しているのであれば、LXC もよい。ただこちらは PostgreSQLをインストールしたあとに各種設定を行う必要があり若干ハードルが高い?ですが、要するに postgresql.confpg_hba.conf を設定すればいいんです。

psqlコマンドをインストール(Ubuntuの場合)

$ sudo apt-get install postgresql-client

でもって posgresアカウントのパスワードを変更しておきます。

$ sudo -u postgres psql
postgres=# alter role postgres with password 'postgres';

PGTune

PostgreSQLサーバをチューニングするのに最適解?を教えてくれるサイト。初めて知ったけどなかなかよさそう。

Postgres-WASM

PostgreSQLをWebブラウザ上で動かす方法もあるらしい。近いうちに調べてみます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?