このページの翻訳:
- 日本語 (ja)
- English (en)
最近の更新
- 24 Bitwarden/Vaultwarden created
最近の更新
文書の過去の版を表示しています。
WALをスタンバイサーバへ転送する事で高可用性と読取に対するスケールアウトを実現するストリーミングレプリケーションを作成
yum -y install epel-release centos-release-scl
yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install postgresql13-contrib postgresql13-devel
systemctl enable postgresql-13.service systemctl disable postgresql-13.service
mkdir /data/ chown postgres:postgres /data/ chmod 750 /data/ # grep Environment=PGDATA /usr/lib/systemd/system/postgresql-13.service Environment=PGDATA=/var/lib/pgsql/13/data/ ↓ Environment=PGDATA=/data/
systemctl daemon-reload
PGSETUP_INITDB_OPTIONS="-E UTF8 --no-locale" /usr/pgsql-13/bin/postgresql-13-setup initdb
cat << __EOM__ | tee /var/lib/pgsql/.pgsql_profile PATH=/usr/pgsql-13/bin:$PATH export PATH __EOM__ source /var/lib/pgsql/.pgsql_profile
# vi /var/lib/pgsql/.bash_profile #PGDATA=/var/lib/pgsql/12/data PGDATA=/data source /var/lib/pgsql/.bash_profile
# su - postgres $ psql alter role postgres with password 'new_password';
systemctl status postgresql-13.service
-bash-4.2$ psql -V psql (PostgreSQL) 13.7 -bash-4.2$ psql -l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- postgres | postgres | UTF8 | C | C | template0 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres (3 rows)
-bash-4.2$ createuser --login --pwprompt testuser Enter password for new role: Enter it again: -bash-4.2$ createdb --owner=testuser testdb
https://www.postgresqltutorial.com/postgresql-getting-started/postgresql-sample-database/
curl -L -O https://www.postgresqltutorial.com/wp-content/uploads/2019/05/dvdrental.zip unzip dvdrental.zip cd sample_data tar zxvf ../dvdrental.zip
vi /data/postgresql.conf #listen_addresses = 'localhost' ↓ listen_addresses = '*'
vi /data/pg_hba.conf ↓追加 ### ローカルホストから、testdb testuser でアクセス local testdb testuser scram-sha-256 ### 他のホストからネットワーク経由でアクセス host all all 172.16.0.0/24 scram-sha-256 ### 他のホストからreplicationを許可 host replication all 172.16.0.0/24 scram-sha-256
# systemctl reload postgresql-13.service
他のノードから、node1へ接続してバックアップを取得
# pg_basebackup -R -D /data/ -h 172.16.0.51 -U postgres
Secondaryは下記を追加 /data/postgresql.auto.conf primary_conninfo = へ追加 application_name=postgresql ## Secondaryは下記をコメントアウト # grep synchronous_standby_names /data/postgresql.conf synchronous_standby_names = 'postgresql' # standby servers that provide sync rep
インストール
https://qiita.com/mkyz08/items/e9316fecd57bff6679cd
pgpool-IIについて
https://qiita.com/tom-sato/items/c01d4df39a6bb19e2b17
動作モード master_slave_mode master_slave_sub_mode stream
https://www.pgpool.net/docs/pgpool-II-4.0.4/ja/html/runtime-config-running-mode.html
ロジカルレプリケーション ストリーミングレプリケーション違い
https://www.sraoss.co.jp/tech-blog/pgsql/logical-replication-1/