IT井戸端会議

IT井戸端会議

インフラ、ネットワーク、アプリケーション開発、IT界隈の話等々を東京都千代田区界隈から発信します。

confluence(こんふるえんす)を使ってみる(posgreSQLのインストール)

confluenceを使うためにDBサーバであるpostgreSQLをインストールする

インストールするバージョンについてはシステム用件を確認

# yum install postgresql
読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package postgresql.x86_64 0:8.4.20-3.el6_6 will be インストール
--> 依存性の処理をしています: postgresql-libs(x86-64) = 8.4.20-3.el6_6 のパッケージ: postgresql-8.4.20-3.el6_6.x86_64
--> 依存性の処理をしています: libpq.so.5()(64bit) のパッケージ: postgresql-8.4.20-3.el6_6.x86_64
--> トランザクションの確認を実行しています。
---> Package postgresql-libs.x86_64 0:8.4.20-3.el6_6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

===============================================================================================
 パッケージ                     アーキテクチャ  バージョン        リポジトリー            容量
===============================================================================================
インストールしています:
 postgresql                     x86_64          8.4.20-3.el6_6    updates                2.6 M
依存性関連でのインストールをします。:
 postgresql-libs                x86_64          8.4.20-3.el6_6    updates                202 k

トランザクションの要約
===============================================================================================
インストール         2 パッケージ

総ダウンロード容量: 2.8 M
インストール済み容量: 14 M
これでいいですか? [y/N]n
ユーザーコマンドを終了しています
#

インストールしようとしたらシステム用件であるバージョンでは無いためキャンセルしてバージョン9.3用のリポジトリを追加

# wget http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
--2015-07-30 23:56:59--  http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
yum.postgresql.org をDNSに問いあわせています... 174.143.35.196
yum.postgresql.org|174.143.35.196|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 5240 (5.1K) [application/x-redhat-package-manager]
`pgdg-centos93-9.3-1.noarch.rpm' に保存中

100%[=======================>] 5,240       --.-K/s 時間 0s

2015-07-30 23:56:59 (125 MB/s) - `pgdg-centos93-9.3-1.noarch.rpm' へ保存完了 [5240/5240]
# rpm -ivh pgdg-centos93-9.3-1.noarch.rpm
警告: pgdg-centos93-9.3-1.noarch.rpm: ヘッダ V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
準備中...                   ########################################### [100%]
   1:pgdg-centos93          ########################################### [100%]
#
# yum repolist
読み込んだプラグイン:fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.tsukuba.wide.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
pgdg93                 | 3.6 kB     00:00
pgdg93/primary_db      | 122 kB     00:00
リポジトリー ID    リポジトリー名                                   状態
base               CentOS-6 - Base                                   6,518
epel               Extra Packages for Enterprise Linux 6 - x86_64   11,742
extras             CentOS-6 - Extras                                    38
pgdg93             PostgreSQL 9.3 6 - x86_64                           259
updates            CentOS-6 - Updates                                1,370
repolist: 19,927
#

バージョン9.3を確認しインストール

# yum list | grep ^postgresql93
postgresql93.x86_64                  9.3.9-1PGDG.rhel6      pgdg93
postgresql93-contrib.x86_64          9.3.9-1PGDG.rhel6      pgdg93
postgresql93-debuginfo.x86_64        9.3.9-1PGDG.rhel6      pgdg93
postgresql93-devel.x86_64            9.3.9-1PGDG.rhel6      pgdg93
postgresql93-docs.x86_64             9.3.9-1PGDG.rhel6      pgdg93
postgresql93-jdbc.x86_64             9.3.1101-1PGDG.rhel6   pgdg93
postgresql93-jdbc-debuginfo.x86_64   9.3.1101-1PGDG.rhel6   pgdg93
postgresql93-libs.x86_64             9.3.9-1PGDG.rhel6      pgdg93
postgresql93-odbc.x86_64             09.03.0400-1PGDG.rhel6 pgdg93
postgresql93-odbc-debuginfo.x86_64   09.03.0400-1PGDG.rhel6 pgdg93
postgresql93-plperl.x86_64           9.3.9-1PGDG.rhel6      pgdg93
postgresql93-plpython.x86_64         9.3.9-1PGDG.rhel6      pgdg93
postgresql93-pltcl.x86_64            9.3.9-1PGDG.rhel6      pgdg93
postgresql93-python.x86_64           4.1.1-1PGDG.rhel6      pgdg93
postgresql93-python-debuginfo.x86_64 4.1.1-1PGDG.rhel6      pgdg93
postgresql93-server.x86_64           9.3.9-1PGDG.rhel6      pgdg93
postgresql93-test.x86_64             9.3.9-1PGDG.rhel6      pgdg93
#
# yum install postgresql93-server.x86_64
読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * epel: ftp.kddilabs.jp
 * extras: www.ftp.ne.jp
 * updates: ftp.riken.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package postgresql93-server.x86_64 0:9.3.9-1PGDG.rhel6 will be インストール
--> 依存性の処理をしています: postgresql93 = 9.3.9-1PGDG.rhel6 のパッケージ: postgresql93-server-9.3.9-1PGDG.rhel6.x86_64
--> 依存性の処理をしています: libpq.so.5()(64bit) のパッケージ: postgresql93-server-9.3.9-1PGDG.rhel6.x86_64
--> トランザクションの確認を実行しています。
---> Package postgresql93.x86_64 0:9.3.9-1PGDG.rhel6 will be インストール
---> Package postgresql93-libs.x86_64 0:9.3.9-1PGDG.rhel6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

=========================================================================================
 パッケージ                        アーキテクチャ バージョン          リポジトリー  容量
=========================================================================================
インストールしています:
 postgresql93-server               x86_64         9.3.9-1PGDG.rhel6   pgdg93       4.1 M
依存性関連でのインストールをします。:
 postgresql93                      x86_64         9.3.9-1PGDG.rhel6   pgdg93       1.0 M
 postgresql93-libs                 x86_64         9.3.9-1PGDG.rhel6   pgdg93       192 k

トランザクションの要約
=========================================================================================
インストール         3 パッケージ

総ダウンロード容量: 5.3 M
インストール済み容量: 21 M
これでいいですか? [y/N]y
パッケージをダウンロードしています:
(1/3): postgresql93-9.3.9-1PGDG.rhel6.x86_64.rpm                     | 1.0 MB     00:01
(2/3): postgresql93-libs-9.3.9-1PGDG.rhel6.x86_64.rpm                | 192 kB     00:01
(3/3): postgresql93-server-9.3.9-1PGDG.rhel6.x86_64.rpm              | 4.1 MB     00:03
--------------------------------------------------------------------------------------------
合計                                                        733 kB/s | 5.3 MB     00:07
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
警告: RPMDB は yum 以外で変更されました。
  インストールしています  : postgresql93-libs-9.3.9-1PGDG.rhel6.x86_64      1/3
  インストールしています  : postgresql93-9.3.9-1PGDG.rhel6.x86_64           2/3
  インストールしています  : postgresql93-server-9.3.9-1PGDG.rhel6.x86_64    3/3
  Verifying               : postgresql93-libs-9.3.9-1PGDG.rhel6.x86_64      1/3
  Verifying               : postgresql93-9.3.9-1PGDG.rhel6.x86_64           2/3
  Verifying               : postgresql93-server-9.3.9-1PGDG.rhel6.x86_64    3/3

インストール:
  postgresql93-server.x86_64 0:9.3.9-1PGDG.rhel6

依存性関連をインストールしました:
  postgresql93.x86_64 0:9.3.9-1PGDG.rhel6               
  postgresql93-libs.x86_64 0:9.3.9-1PGDG.rhel6

完了しました!
#
# yum list installed | grep ^postgresql
postgresql93.x86_64  9.3.9-1PGDG.rhel6  @pgdg93
postgresql93-libs.x86_64
postgresql93-server.x86_64
#

postgreSQLの起動 ※初回起動前に初期化が必要

# /etc/init.d/postgresql-9.3 status
postgresql-9.3 は停止しています
#
# /etc/init.d/postgresql-9.3 start

/var/lib/pgsql/9.3/data is missing. Use "service postgresql-9.3 initdb" to initialize the cluster first.
                                                           [失敗]
#
# service postgresql-9.3 initdb
データベースを初期化中:                                    [  OK  ]
#
# /etc/init.d/postgresql-9.3 start
postgresql-9.3 サービスを開始中:                           [  OK  ]
#

postgresユーザが作成されたことを確認

# id postgres
uid=26(postgres) gid=26(postgres) 所属グループ=26(postgres)
#

postgresユーザにスイッチ

# su - postgres
-bash-4.1$ id -un
postgres
-bash-4.1$

ユーザ作成

-bash-4.1$ psql
postgres=# create role confluencedb_user PASSWORD 'xxxxxxxx'  CREATEDB LOGIN;
CREATE ROLE
postgres=#
postgres=# du
                                             ロール一覧
     ロール名      |                                 属性                                 | メンバー
-------------------+----------------------------------------------------------------------+----------
 confluencedb_user | DBを作成できる                                                       | {}
 postgres          | スーパーユーザ, ロールを作成できる, DBを作成できる, レプリケーション | {}

postgres=#

template0(まっさら)を指定しconfluencedbを作成

postgres=# create database confluencedb owner confluenceDB_user template=template0 encoding='utf-8';
CREATE DATABASE
postgres=#
postgres=# l
                                               データベース一覧
     名前     |      所有者       | エンコーディング |  照合順序   | Ctype(変換演算子) |      アクセス権
--------------+-------------------+------------------+-------------+-------------------+-----------------------
 confluencedb | confluencedb_user | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       |
 postgres     | postgres          | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       |
 template0    | postgres          | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       | =c/postgres          +
              |                   |                  |             |                   | postgres=CTc/postgres
 template1    | postgres          | UTF8             | ja_JP.UTF-8 | ja_JP.UTF-8       | =c/postgres          +
              |                   |                  |             |                   | postgres=CTc/postgres
(4 行)
postgres-# q
-bash-4.1$