Skip to content

Commit

Permalink
Merge pull request #128 from radixdlt/DO-2764-node-cli-upgrade-postgr…
Browse files Browse the repository at this point in the history
…es-version-from-12-15

Remove postgres 12 and install version 15
  • Loading branch information
shambupujar authored Oct 2, 2024
2 parents 64c86c6 + 0eb08b3 commit 21a67bc
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,5 @@ node-runner-cli/systemd.settings.yml

.DS_Store
node-runner-cli/out/
requirements.txt
requirements.txt
node-runner-cli/node-keystore.ks
32 changes: 32 additions & 0 deletions Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,37 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
----

== Upgrading Postgres from 12 to 15
From gateway release 1.7.0, upgrading Postgres is required. Follow the steps below to upgrade Postgres from version 12 to 15:

=== Shutdown the node, and gateway:
[source, bash]
----
./babylonnode docker stop
----

=== Install the new Postgres 15
This is part of cli docker install process. The ansible provision.yml is updated to take care of uninstalling the old version and installing the new version. This removes the existing data on gateway and will reingest. So if you running production gateway, suggestion is to setup new instance and switch over to new instance once it is all synced up.

[source, bash]
----
./babyonnode docker install
----

=== Check if node is running:
For more information on node monitoring and health, refer to the documentation at https://docs.radixdlt.com/docs/node-monitoring-health.


=== Check if the gateway is running:
For more information on ensuring the gateway is running, refer to the documentation at https://docs.radixdlt.com/docs/setup-with-cli#6-make-sure-the-gateway-is-running.


=== Gateway still reporting issues
Both gateway_api and data_aggregator might need a restart. Try below commands
[source, bash]
----
docker compose down data_aggregator gateway_api
docker compose up data_aggregator gateway_api -d
----
56 changes: 55 additions & 1 deletion node-runner-cli/ansible/project/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
setup_swap: false
setup_limits: false
postgres_local: false
postgresql_version: 12
postgresql_version: 15
postgresql_user: postgres
postgresql_db_name: radixdlt_ledger
tasks:
Expand Down Expand Up @@ -78,6 +78,12 @@
state: present
filename: pgdg

- name: Remove PostgreSQL 12 if installed
ansible.builtin.package:
name: postgresql-12
state: absent
ignore_errors: true

- name: install PostgreSQL
ansible.builtin.package:
name:
Expand All @@ -87,6 +93,54 @@
- acl
state: present

- name: Debug print command pg_lsclusters
command: pg_lsclusters
register: pg_lsclusters_output
changed_when: false

- name: Print pg_lsclusters output
debug:
var: pg_lsclusters_output.stdout_lines

- name: Remove PostgreSQL 12 cluster if exists
shell: |
pg_lsclusters | grep '12' && pg_dropcluster --stop 12 main
ignore_errors: true

- name: Check if PostgreSQL {{postgresql_version}} is listening on port 5432
shell: |
ss -ltn | grep ':5432'
register: postgres_port_check
changed_when: false
ignore_errors: true

- name: Stop PostgreSQL {{postgresql_version}} if it is running
service:
name: postgresql
state: stopped
when: postgres_port_check.stdout != ""

- name: Modify PostgreSQL {{postgresql_version}} to listen on port 5432
lineinfile:
path: /etc/postgresql/{{ postgresql_version }}/main/postgresql.conf
regexp: '^#?port ='
line: 'port = 5432'
state: present

- name: Stop PostgreSQL service
service:
name: postgresql
state: stopped


- name: Reload systemd daemon
command: systemctl daemon-reload

- name: Start PostgreSQL {{postgresql_version}}
service:
name: postgresql
state: started

- name: Install psycopg2-binary python package
ansible.builtin.pip:
name: psycopg2-binary
Expand Down

0 comments on commit 21a67bc

Please sign in to comment.