AmazonEC2へPostgresをソースからインストールする手順(ver9.2.2)
AmazonEC2へPostgresをソースからインストールする手順(ver9.2.2)
前回構築したAWSのEC2環境へ、Postgresをソースからインストールする手順をまとめます。
手順1.ログイン
まずはSSHでEC2環境へログインしましょう。秘密鍵の設定を忘れずに。
ログイン時点でユーザはec2-userなので、rootに変わっておきます。
1 | $ sudo su |
手順2.postgresユーザ作成
postgres用のユーザを作成しておきます。
1 2 3 | # useradd postgers # id postgres uid=500(postgres) gid=501(postgres) groups =501(postgres) |
↑こんな感じで表示されればOK
1 | # passwd postgres |
↑postgresユーザのパスワードも設定しておきましょう。
手順3.インストール用ディレクトリの作成
1 2 3 4 5 | # mkdir /usr/local/pgsql9.2.2/ # mkdir /var/lib/pgsql9.2.2/ # mkdir /var/lib/pgsql9.2.2/data/ # chown postgres:postgres /usr/local/pgsql9.2.2/ # chown -Rf postgres:postgres /var/lib/pgsql9.2.2/ |
手順4.ソースダウンロード&解凍
ここはrootユーザで。
1 2 3 4 | # cd /usr/local/src # tar xvfz postgresql-9.2.2.tar.gz # cd postgresql-9.2.2 |
↑解凍したディレクトリに移動しておきます。
手順5.configure
postgresユーザに切り替わりましょう。
1 2 | # su postgres $ . /configure --prefix= /usr/local/pgsql9 .2.2/ |
※ここで、「configure: error: readline library not found」のようなエラーが出る場合、
下記のように一旦rootユーザに戻り、yumでreadlineライブラリをインストールしましょう。
1 2 | $ exit (←rootに戻る) # yum install readline readline-devel |
手順6.コンパイル&インストール
1 2 | $ make $ make install |
↑makeは結構時間がかかるので、気長に待ちましょう。
初級インフラエンジニアにオススメ連載リンク
ネットワーク学習の登竜門・・
ゼロからのCCNA独学講座
Linuxの取り扱いを基礎から学ぶ
Linux資格 「LPIC-Lv1」徹底解説