Upgrade to Pro — share decks privately, control downloads, hide ads and more …

こわくないPostgreSQLのアップグレード

ester41
March 17, 2019
3.1k

 こわくないPostgreSQLのアップグレード

ester41

March 17, 2019
Tweet

Transcript

  1. ΞοϓάϨʔυํ๏ 2. ৽͍͠PostgreSQLͷಋೖ ݹ͍PostgreSQLΛఀࢭޙɺ৽͍͠PostgreSQLΛಋೖ͠·͢ɻ $ su - # systemctl stop

    postgresql-9.6 # systemctl disable postgresql-9.6 # yum install -y https://download.postgresql.org/pub/repos/yum/11/ redhat/rhel-7-x86_64/pgdg-redhat11-11-2.noarch.rpm # yum install -y postgresql11-server postgresql11-contrib postgresql11-devel postgresql11-libs # cd /usr/pgsql-11/bin/ # export PGSETUP_INITDB_OPTIONS="-E UTF-8 --locale=C" # ./postgresql-11-setup initdb
  2. ΞοϓάϨʔυํ๏ 3. σʔλͷΞοϓάϨʔυɺىಈ ݹ͍PostgreSQLͷσʔλΛɺ৽͍͠PostgreSQLʹҠߦ͠·͢ɻ # su - postgres $ /usr/pgsql-11/bin/pg_upgrade

    -b /usr/pgsql-9.6/bin/ -B /usr/ pgsql-11/bin/ -d /var/lib/pgsql/9.6/data/ -D /var/lib/pgsql/11/data/ $ vim /var/lib/pgsql/11/data/postgresql.conf pg_hba.conf $ exit # systemctl start postgresql-11 # systemctl enable postgresql-11 # su - postgres $ ./analyze_new_cluster.sh $ exit # exit
  3. ΞοϓάϨʔυํ๏ 4. Ruby༻PostgreSQL઀ଓϥΠϒϥϦͷߋ৽(1/2) MastodonͷPostgreSQL઀ଓ༻ϥΠϒϥϦpg͸ɺlibpqͱݺ͹ΕΔϥΠϒ ϥϦΛϦϯΫ͍ͯ͠·͢ɻ libpqͱ͸ɺCݴޠͰॻ͔ΕͨPostgreSQLͷΠϯλʔϑΣʔεϥΠϒϥϦ ͱͳΓ·͢ɻ( https://www.postgresql.jp/document/10/html/ ) ͜ͷ··چPostgreSQLΛ࡟আͯ͠͠·͏ͱɺMastodon͔ΒPostgreSQL

    ʹ઀ଓͰ͖ͳ͘ͳͬͯ͠·͍·͢ɻ ͦͷͨΊɺϥΠϒϥϦͷ࠶ϦϯΫ(࠶ίϯύΠϧ)͕ඞཁͱͳΓ·͢ɻ $ ldd vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0- static/pg-1.1.4/pg_ext.so | grep libpq libpq.so.5 => /usr/pgsql-9.6/lib/libpq.so.5 (0x00007fc0598e4000)
  4. ΞοϓάϨʔυํ๏ 4. Ruby༻PostgreSQL઀ଓϥΠϒϥϦͷߋ৽(2/2) Gemͷ࠶ίϯύΠϧΛߦ͍·͢ɻ (RubyͷίϚϯυʹ͍ͭͯ଄ܮ͕ਂ͋͘Γ·ͤΜͷͰɺશϥΠϒϥϦͷ ࠶ίϯύΠϧ͕૸Γ·͢ɻ΋ͬͱ͍͍ํ๏͕͋Ε͹ڭ͑ͯͩ͘͞ ͍ɻɻɻ) $ bundle config

    build.pg --with-pg-config=/usr/pgsql-11/bin/ pg_config $ bundle install --force $ ldd vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0- static/pg-1.1.4/pg_ext.so | grep libpq libpq.so.5 => /usr/pgsql-11/lib/libpq.so.5 (0x00007f0fea6b5000)
  5. ΞοϓάϨʔυํ๏ 5. Mastodonͷىಈɺಈ࡞֬ೝɺچσʔλ࡟আ MastodonΛىಈ͠ɺਖ਼ৗʹಈ࡞͢Δ͔֬ೝ͠·͢ɻ ໰୊ͳ͚Ε͹ɺچPostgreSQLΛ࡟আ͠·͢ɻ $ su - # systemctl

    start mastodon-web mastodon-sidekiq mastodon-streaming # su - postgresql $ ./delete_old_cluster.sh $ rm -f analyze_new_cluster.sh delete_old_cluster.sh $ exit # yum remove postgresql96-contrib postgresql96-libs postgresql96- devel postgresql96-server postgresql96 # exit