⚠️ このエントリーは1年以上前に作成されたものです。情報の賞味期限切れにご注意ください。
タイトルどおり。
docker swarmでreplicaから復帰するときにsyncがクソ長くて、マネージドDBに移行したすぎたから移行した。
AWS処女だから db.t2.micro
が :gohan_omori_muryo: 。
やったねたえちゃん!
手順メモ
- 旧DB dump
拡張はRDSの制限であれこれできないらしいので、コメントアウトしておく。
pg_dump --format=plain --no-owner --no-acl mastodon | sed -E 's/(DROP|CREATE|COMMENT ON) EXTENSION/-- \1 EXTENSION/g' > mastodon.sql
Bash
How to solve privileges issues when restore PostgreSQL Database
I have dumped a clean, no owner backup for Postgres Database with the commandpg_dump sample_database -O -c -ULater, when...
- RDSに接続
psql -h XXXXXXXXXXXX.YYYYYYYYYYYYY.ap-northeast-1.rds.amazonaws.com -U postgres -W
Bash- ロール作成
create role mastodon with login password 'ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ';
SQL- DB作成
create database mastodon;
SQL- DBを指定してRDSに接続
psql mastodon -h XXXXXXXXXXXX.YYYYYYYYYYYYY.ap-northeast-1.rds.amazonaws.com -U postgres -W
Bash- DBオーナーと権限設定
grant all privileges on database mastodon to mastodon;
alter database mastodon owner to mastodon;
SQL- RDSにrestore
psql mastodon -h XXXXXXXXXXXX.YYYYYYYYYYYYY.ap-northeast-1.rds.amazonaws.com -U postgres -W < mastodon.sql
Bash.env.production
のDBの向き先を変える
DB_SSLMODE
はコメントアウトのままでよかった。
DB_HOST=XXXXXXXXXXXX.YYYYYYYYYYYYY.ap-northeast-1.rds.amazonaws.com
DB_USER=mastodon
DB_NAME=mastodon
DB_PASS=ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
DB_PORT=5432
DB_POOL=15
Bashdocker stack deploy --compose-file docker-compose.yml mastodon
感想
丸1日使ってみたけど、稀にAPIの反応が悪くなる。
CloudWatchで見る限りでは超余裕っぽさそうだから原因が分からん。
もしかするとLinodeとRDSの間が詰まってるのかもしれない。
