-
Notifications
You must be signed in to change notification settings - Fork 210
Postgres Upgrade 13.3
jashaik edited this page Jul 29, 2021
·
33 revisions
Upgrades page: https://docs.chef.io/server/upgrades/
- Vacuum full (recommendation)
- Stop the chef-server
- Take a copy of the
/opt/opscode/embedded/postgresql/*
(need to remove this step) - Download the upgrade build (14.6.33+20210719175317 used for testing)
- Install the package
- Restore
/opt/opscode/embedded/postgresql/*
(need to remove this step) - Upgrade the chef-server
- Start and cleanse the chef-server
- Reindex the database
- Install version -> 14.5.29
- Upgrade version -> 14.6.33+20210719175317
- PG data -> 158G /var/opt/opscode/postgresql/9.6/data
- Number of nodes -> 565596
- opscode_chef size -> 49 GB
- bifrost -> 68 GB
- oc_id -> 27 GB
- machine type -> t3.2xlarge
- Total time take for vacuum full -> 183m49.091s
- PG data -> 21G /var/opt/opscode/postgresql/9.6/data (reduced from 158G)
- Number of nodes -> 565596
- opscode_chef size -> 21 GB (reduced from 49 GB)
- bifrost -> 7127 kB (reduced from 68 GB)
- oc_id -> 30 MB (reduced from 27 GB)
- Total time take for upgrade process -> approx 15 min
- PG data -> 21G /var/opt/opscode/postgresql/13.3/data (same as before)
- Number of nodes -> 565596
- opscode_chef size -> 21 GB (same as before)
- bifrost -> 8949 kB (increased from 7127 kB)
- oc_id -> 32 MB (increased from 30 MB)
- Total time take for reindex process -> approx 5 min
- PG data -> 21G /var/opt/opscode/postgresql/13.3/data (same as before)
- Number of nodes -> 565596
- opscode_chef size -> 20 GB (reduced from 21 GB)
- bifrost -> 8773 kB (reduced from 8949 kB)
- oc_id -> 32 MB (same as before)
- Running vacuum full before the upgrade is recommended as it will reduce the data size to optimal and all the further steps will take less time
- Need same amount of free space as the pg data consumes
- Total time take for vacuuming, upgrading and reindexing 158G data is approximately 3.5 hr
- Vacuum full (recommendation)
- Stop the front end chef server only
- Take a copy of the
/opt/opscode/embedded/postgresql/*
(need to remove this step) - Download and dpkg install the upgrade build on front end(14.7.11+20210727061052 used for testing)
- Restore
/opt/opscode/embedded/postgresql/*
(need to remove this step) - Stop the back end chef server
- Take a copy of the
/opt/opscode/embedded/postgresql/*
(need to remove this step) - Download and dpkg install the upgrade build on back end(14.7.11+20210727061052 used for testing)
- Restore
/opt/opscode/embedded/postgresql/*
(need to remove this step) - Upgrade the chef-server on the back end
- Zip and copy the
/etc
from back end to front end and unzip/etc
on front end - Reconfigure and start the chef-server on front end
- Install version -> 14.5.29
- Upgrade version -> 14.7.11+20210727061052
- PG data -> 23G /var/opt/opscode/postgresql/9.6/data/
- Number of nodes -> 565596
- opscode_chef size -> 22 GB
- bifrost -> 8311 kB
- oc_id -> 7327 kB
- machine type -> t3.medium (extended the storage to 150 GB)
- Total time take for upgrade process -> approx 20 min
- PG data -> 22G /var/opt/opscode/postgresql/13.3/ (reduced from 23 GB)
- Number of nodes -> 565596
- opscode_chef size -> 22 GB (same as before)
- bifrost -> 8885 kB (increased from 8311 kB)
- oc_id -> 7909 kB (increased from 7327 kB)
- Include vacuum full process
- Need same amount of free space as the pg data consumes
- Total time take for upgrading 23GB vacuumed data is approximately 20 min
chef-server box
- Download the upgrade build (typically using curl or mixlib).
- Install the package.
sudo rpm -U -v --force <path-to-package>
or
sudo dpkg -iEG <path-to-package>
- Upgrade chef-server.
sudo CHEF_LICENSE='accept' chef-server-ctl upgrade
sudo chef-server-ctl start
sudo chef-server-ctl cleanup
postgresql box
- Update packages and install the new PostgreSQL 13.3.
- Check if there are any differences in the config files.Make sure to update them if required
diff /etc/postgresql/12/main/postgresql.conf /etc/postgresql/13/main/postgresql.conf
diff /etc/postgresql/12/main/pg_hba.conf /etc/postgresql/13/main/pg_hba.conf
- Stop the PostgreSQL service.
sudo systemctl stop postgresql.service
- Log in as the postgres user.
su postgres
- Check clusters (notice the --check argument, this will not change any data).
/usr/lib/postgresql/13/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/9.6/main \
--new-datadir=/var/lib/postgresql/13/main \
--old-bindir=/usr/lib/postgresql/9.6/bin \
--new-bindir=/usr/lib/postgresql/13/bin \
--old-options '-c config_file=/etc/postgresql/9.6/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/13/main/postgresql.conf' \
--check
- Migrate the data (without the --check argument).
/usr/lib/postgresql/13/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/9.6/main \
--new-datadir=/var/lib/postgresql/13/main \
--old-bindir=/usr/lib/postgresql/9.6/bin \
--new-bindir=/usr/lib/postgresql/13/bin \
--old-options '-c config_file=/etc/postgresql/9.6/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/13/main/postgresql.conf'
- Go back to the regular user.
exit
- Swap the ports for the old and new PostgreSQL versions.
sudo vim /etc/postgresql/13/main/postgresql.conf
# ...and change "port = 5433" to "port = 5432"
sudo vim /etc/postgresql/9.6/main/postgresql.conf
# ...and change "port = 5432" to "port = 5433"
- Start the PostgreSQL service.
sudo systemctl start postgresql.service
- Log in as the postgres user again and Check the new PostgreSQL version.
sudo su postgres
psql -c "SELECT version();"
- log in to the chef-server box and see the status
chef-server-ctl status