AWS(Amazon Linux2)にPostgreSQLをインストールする
yumを使ってインストール
yum install postgresql-server postgresql-devel postgresql-contrib
以下が表示されたらOK!
Installed:
postgresql-contrib.x86_64 0:9.2.24-1.amzn2.0.1 postgresql-devel.x86_64 0:9.2.24-1.amzn2.0.1 postgresql-server.x86_64 0:9.2.24-1.amzn2.0.1
Dependency Installed:
libxslt.x86_64 0:1.1.28-5.amzn2.0.2 postgresql.x86_64 0:9.2.24-1.amzn2.0.1 postgresql-libs.x86_64 0:9.2.24-1.amzn2.0.1 uuid.x86_64 0:1.6.2-26.amzn2.0.1
Complete!
初期設定とサービス起動
initdbコマンドで初期処理を行います
postgresql-setup initdb
以下が表示されます
Initializing database ... OK
systemctlを使ってサービスを起動します
systemctl start postgresql.service
psコマンドでpostgresが起動していることを確認してください。
ps -ef | grep postgres
postgres 1907 1 0 04:12 ? 00:00:00 /usr/bin/postgres -D /var/lib/pgsql/data -p 5432
postgres 1908 1907 0 04:12 ? 00:00:00 postgres: logger process
postgres 1910 1907 0 04:12 ? 00:00:00 postgres: checkpointer process
postgres 1911 1907 0 04:12 ? 00:00:00 postgres: writer process
postgres 1912 1907 0 04:12 ? 00:00:00 postgres: wal writer process
postgres 1913 1907 0 04:12 ? 00:00:00 postgres: autovacuum launcher process
postgres 1914 1907 0 04:12 ? 00:00:00 postgres: stats collector process
ec2-user 1979 1622 0 04:16 pts/2 00:00:00 grep --color=auto postgres
ユーザの初期設定
最初からpostgresというユーザ存在していますが、パスワードが設定されていないのでパスワードを設定します。
sudo passwd postgres
Changing password for user postgres.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
接続確認
postgresユーザにスイッチして、接続確認を行います
su - postgres
psql
以下のように表示されれば成功です。
psql (9.2.24)
Type "help" for help.

ディスカッション
コメント一覧
まだ、コメントがありません