目次 |
---|
はじめに
この手順では CentOS 7 系に PostgreSQL をインストールする手順を説明します。
注意 |
---|
インストール対象の Alfresco Content Services あるいは Alfresco Process Services でサポートされているバージョンのものを選択してください。
本手順に記載のバージョンは、サポート対象バージョンにあわせて適宜読み替えてください。 |
1.リポジトリ情報の登録
リポジトリファイルの修正を行います
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# vi /etc/yum.repos.d/CentOS-Base.repo |
コード ブロック | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 exclude=postgresql* ←追加 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 exclude=postgresql* ←追加 (省略) |
情報 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
ここでは CentOS 7 系を例に説明していますが、Fedora 系の修正するファイルは以下の対象のセクションになります。(参考: Configure your YUM repository)
|
RPM パッケージをインストールします(Repository Package に記載があります)
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
Loaded plugins: fastestmirror pgdg-redhat-repo-latest.noarch.rpm | 5.6 kB 00:00 Examining /var/tmp/yum-root-2CGmmN/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch Marking /var/tmp/yum-root-2CGmmN/pgdg-redhat-repo-latest.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package pgdg-redhat-repo.noarch 0:42.0-4 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pgdg-redhat-repo noarch 42.0-4 /pgdg-redhat-repo-latest.noarch 6.8 k Transaction Summary ================================================================================ Install 1 Package Total size: 6.8 k Installed size: 6.8 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pgdg-redhat-repo-42.0-4.noarch 1/1 Verifying : pgdg-redhat-repo-42.0-4.noarch 1/1 Installed: pgdg-redhat-repo.noarch 0:42.0-4 Complete! |
インストール対象のパッケージのグループを確認します
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# yum grouplist |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
Loaded plugins: fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: ftp.riken.jp * epel: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp base | 3.6 kB 00:00 extras | 3.4 kB 00:00 pgdg10 | 3.6 kB 00:00 pgdg11 | 3.6 kB 00:00 pgdg94 | 3.6 kB 00:00 pgdg95 | 3.6 kB 00:00 pgdg96 | 3.6 kB 00:00 updates | 3.4 kB 00:00 (1/10): pgdg11/7/x86_64/group_gz | 245 B 00:01 (2/10): pgdg10/7/x86_64/group_gz | 245 B 00:01 (3/10): pgdg94/7/x86_64/group_gz | 247 B 00:01 (4/10): pgdg95/7/x86_64/group_gz | 249 B 00:01 (5/10): pgdg11/7/x86_64/primary_db | 182 kB 00:03 (6/10): pgdg10/7/x86_64/primary_db | 227 kB 00:03 (7/10): pgdg96/7/x86_64/group_gz | 249 B 00:00 (8/10): pgdg95/7/x86_64/primary_db | 242 kB 00:02 (9/10): pgdg94/7/x86_64/primary_db | 252 kB 00:02 (10/10): pgdg96/7/x86_64/primary_db | 246 kB 00:01 Available Environment Groups: Minimal Install Compute Node Infrastructure Server File and Print Server Cinnamon Desktop MATE Desktop Basic Web Server Virtualization Host Server with GUI GNOME Desktop KDE Plasma Workspaces Development and Creative Workstation Available Groups: Cinnamon Compatibility Libraries Console Internet Tools Development Tools Educational Software Electronic Lab Fedora Packager General Purpose Desktop Graphical Administration Tools Haskell Legacy UNIX Compatibility MATE Milkymist PostgreSQL Database Server 10 PGDG ←これらが PostgreSQL のパッケージグループ PostgreSQL Database Server 11 PGDG ←これらが PostgreSQL のパッケージグループ PostgreSQL Database Server 9.4 PGDG ←これらが PostgreSQL のパッケージグループ PostgreSQL Database Server 9.5 PGDG ←これらが PostgreSQL のパッケージグループ PostgreSQL Database Server 9.6 PGDG ←これらが PostgreSQL のパッケージグループ Scientific Support Security Tools Smart Card Support System Administration Tools System Management TurboGears application framework Xfce Done |
2.PostgreSQL のインストール
今回は "PostgreSQL Database Server 11 PGDG" を対象とします。
次のコマンドで PostgreSQL をインストールします。
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# yum groupinstall "PostgreSQL Database Server 11 PGDG" |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
読み込んだプラグイン:fastestmirror There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ postgresql11.x86_64 0:11.11-1PGDG.rhel7 を インストール ---> パッケージ postgresql11-contrib.x86_64 0:11.11-1PGDG.rhel7 を インストール ---> パッケージ postgresql11-libs.x86_64 0:11.11-1PGDG.rhel7 を インストール ---> パッケージ postgresql11-server.x86_64 0:11.11-1PGDG.rhel7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ================================================================================ Package アーキテクチャー バージョン リポジトリー 容量 ================================================================================ Installing for group install "PostgreSQL Database Server 11 PGDG": postgresql11 x86_64 11.11-1PGDG.rhel7 pgdg11 1.7 M postgresql11-contrib x86_64 11.11-1PGDG.rhel7 pgdg11 609 k postgresql11-libs x86_64 11.11-1PGDG.rhel7 pgdg11 363 k postgresql11-server x86_64 11.11-1PGDG.rhel7 pgdg11 4.7 M トランザクションの要約 ================================================================================ インストール 4 パッケージ 合計容量: 7.4 M インストール容量: 31 M Is this ok [y/d/N]: y Downloading packages: 警告: /var/cache/yum/x86_64/7/pgdg11/packages/postgresql11-libs-11.11-1PGDG.rhel7.x86_64.rpm: ヘッダー V4 DSA/SHA1 Signature、鍵 ID 442df0f8: NOKEY file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG から鍵を取得中です。 Importing GPG key 0x442DF0F8: Userid : "PostgreSQL RPM Building Project <pgsqlrpms-hackers@pgfoundry.org>" Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8 Package : pgdg-redhat-repo-42.0-14.noarch (@/pgdg-redhat-repo-latest.noarch) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG 上記の処理を行います。よろしいでしょうか? [y/N]y Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : postgresql11-libs-11.11-1PGDG.rhel7.x86_64 1/4 インストール中 : postgresql11-11.11-1PGDG.rhel7.x86_64 2/4 インストール中 : postgresql11-server-11.11-1PGDG.rhel7.x86_64 3/4 インストール中 : postgresql11-contrib-11.11-1PGDG.rhel7.x86_64 4/4 検証中 : postgresql11-libs-11.11-1PGDG.rhel7.x86_64 1/4 検証中 : postgresql11-11.11-1PGDG.rhel7.x86_64 2/4 検証中 : postgresql11-contrib-11.11-1PGDG.rhel7.x86_64 3/4 検証中 : postgresql11-server-11.11-1PGDG.rhel7.x86_64 4/4 インストール: postgresql11.x86_64 0:11.11-1PGDG.rhel7 postgresql11-contrib.x86_64 0:11.11-1PGDG.rhel7 postgresql11-libs.x86_64 0:11.11-1PGDG.rhel7 postgresql11-server.x86_64 0:11.11-1PGDG.rhel7 完了しました! |
3.PostgreSQL の設定
セットアップファイルを修正します
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# vi /usr/pgsql-11/bin/postgresql-11-setup |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# Initialize the database initdbcmd="$PGENGINE/initdb --pgdata='$PGDATA' --no-locale -E UTF-8 --auth='ident'" ←"--no-locale -E UTF-8" を追加 initdbcmd+=" $PGSETUP_INITDB_OPTIONS" $SU -l postgres -c "$initdbcmd" >> "$PGLOG" 2>&1 < /dev/null |
データベース領域を初期化します
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# /usr/pgsql-11/bin/postgresql-11-setup initdb |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
Initializing database ... OK |
postgresql.conf
ファイルを修正します。ここで設定する値は要件にあわせて適宜変更してください。(参考:PostgreSQL 公式ドキュメント - 第19章 サーバの設定)
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# vi /var/lib/pgsql/11/data/postgresql.conf |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# - Memory - (中略) max_connections = 275 # (change requires restart) (中略) shared_buffers = 512MB # min 128kB (中略) work_mem = 4MB # min 64kB (中略) wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers (中略) |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# - Connection Settings - listen_addresses = 'localhost' ←DBへの接続を許可するIPアドレスを設定 # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) |
pg_hba.conf
ファイルを修正します(参考:PostgreSQL 公式ドキュメント - 第20章 クライアント認証、PostgreSQL 公式ドキュメント - 20.1. pg_hba.confファイル)
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# vi /var/lib/pgsql/11/data/pg_hba.conf |
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# IPv4 local connections: host all all 127.0.0.1/32 md5 ←"md5"に変更 |
PostgreSQL を起動します
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# systemctl start postgresql-11.service \ && systemctl is-active postgresql-11.service && systemctl status postgresql-11.service |
PostgreSQL の自動起動設定をします
コード ブロック | ||||||
---|---|---|---|---|---|---|
| ||||||
# systemctl enable postgresql-11.service \ && systemctl is-enabled postgresql-11.service && systemctl status postgresql-11.service |