This repository was archived by the owner on Dec 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
PMM-5885 upgrade postgres to 14 #212
Merged
Merged
Changes from 11 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1526028
PMM-5885 upgrade postgres to 14
nikita-b 0899905
fix
nikita-b 605d914
Merge branch 'main' into PMM-5885-upgrade-postgres-to-14
nikita-b 507feaf
PMM-5885 clean yum
nikita-b abbfd23
Merge branch 'PMM-5885-upgrade-postgres-to-14' of github.com:percona/…
nikita-b 241f53d
fix check mode
nikita-b 79983bc
fix service name
nikita-b fea7544
fix become
nikita-b 0d6c64b
fix
nikita-b 2a6eb65
ansible check
nikita-b f8ad500
fix syntax
nikita-b d323438
Update ansible/playbook/tasks/roles/postgres/tasks/main.yml
nikita-b d8fe797
Update ansible/playbook/tasks/roles/initialization/tasks/main.yml
nikita-b b7f3838
Merge branch 'main' into PMM-5885-upgrade-postgres-to-14
4eaead7
Update ansible/playbook/tasks/roles/postgres/tasks/main.yml
nikita-b 0676ea1
Update ansible/playbook/tasks/roles/postgres/tasks/main.yml
nikita-b 7f6cdcb
Update ansible/playbook/tasks/roles/postgres/tasks/main.yml
nikita-b 40b09b5
fix
nikita-b a153011
Merge branch 'PMM-5885-upgrade-postgres-to-14' of github.com:percona/…
nikita-b ffb52fd
fix
nikita-b c1d0ae1
fix
nikita-b 44e3e48
fix python deps
nikita-b a02cbcc
fix ext postgres
nikita-b 420b965
fix
nikita-b f7ce725
add supervisor config
nikita-b 09ba813
fix
nikita-b 5f95392
Merge branch 'main' into PMM-5885-upgrade-postgres-to-14
nikita-b 9cd07e3
fix
nikita-b 6b56d72
Merge branch 'PMM-5885-upgrade-postgres-to-14' of github.com:percona/…
nikita-b 166f71f
move supervisor settings from pmm-server
nikita-b b9c372f
fix
nikita-b 11fea48
fix module name
nikita-b 46835de
fix upgrade bug
nikita-b 71e2154
Merge branch 'main' into PMM-5885-upgrade-postgres-to-14
nikita-b ed00819
fix upgrade
nikita-b 650bef6
Merge branch 'PMM-5885-upgrade-postgres-to-14' of github.com:percona/…
nikita-b dcd7323
fix
nikita-b df80942
fix upgrade
nikita-b da42706
fix
nikita-b f411364
fix
nikita-b eba1cf0
remove useless steps
nikita-b 2bae6d2
fix supervisor issues
nikita-b 4b8a1fd
fix
nikita-b fbfe714
add pmm-managed user
nikita-b 3e1bab3
fix
nikita-b a3263dd
Merge branch 'main' into PMM-5885-upgrade-postgres-to-14
nikita-b File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,23 +39,12 @@ | |
| path: /srv/backup | ||
| state: directory | ||
|
|
||
| - name: Wait until postgres socket is present before continuing | ||
| wait_for: | ||
| path: /var/run/postgresql/.s.PGSQL.5432 | ||
|
|
||
| - name: Get postgres encoding | ||
| postgresql_query: | ||
| db: pmm-managed | ||
| query: SHOW SERVER_ENCODING; | ||
| register: postgres_encoding | ||
| become: yes | ||
| become_user: postgres | ||
| become_method: su | ||
|
|
||
| - debug: | ||
| var: postgres_encoding.query_result | ||
|
|
||
| - name: Change encoding of pmm-managed database | ||
| - name: Check if Postgres 11 exist | ||
| stat: | ||
| path: /srv/postgres | ||
| register: is_postgres_11 | ||
|
|
||
| - name: Upgrade Postgres database | ||
| include_role: | ||
| name: postgres-ascii-to-utf8 | ||
| when: "'SQL_ASCII' == postgres_encoding.query_result[0].server_encoding" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed this role because we use new instance and this instance has UTF8 by default |
||
| name: postgres | ||
| when: is_postgres_11.stat.exists | ||
84 changes: 0 additions & 84 deletions
84
ansible/playbook/tasks/roles/postgres-ascii-to-utf8/tasks/main.yml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| --- | ||
| # Install Postgres | ||
| - name: Create Postgres data dir | ||
| file: | ||
| path: "/srv/postgres14" | ||
| state: directory | ||
| owner: postgres | ||
| group: postgres | ||
|
|
||
| - name: Add PostgreSQL YUM repository | ||
|
nikita-b marked this conversation as resolved.
Outdated
|
||
| yum_repository: | ||
| name: percona-ppg-14 | ||
| description: PostgreSQL YUM repository - x86_64 | ||
| baseurl: http://repo.percona.com/ppg-14/yum/release/7/RPMS/x86_64 | ||
| gpgcheck: yes | ||
| enabled: yes | ||
| gpgkey: file:///etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY | ||
|
|
||
| - name: Add PostgreSQL YUM repository | ||
|
nikita-b marked this conversation as resolved.
Outdated
|
||
| yum_repository: | ||
| name: percona-ppg-11 | ||
| description: PostgreSQL YUM repository - x86_64 | ||
| baseurl: http://repo.percona.com/ppg-11/yum/release/7/RPMS/x86_64 | ||
| gpgcheck: yes | ||
| enabled: yes | ||
| gpgkey: file:///etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY | ||
|
|
||
| # we need old postgres binary for upgrade process | ||
| - name: Install Postgres | ||
| yum: | ||
| name: | ||
| - percona-postgresql14-server | ||
| - percona-postgresql14-contrib | ||
| - percona-postgresql14 | ||
| - percona-postgresql11-server | ||
| - percona-postgresql11-contrib | ||
| - percona-postgresql11 | ||
| state: installed | ||
| when: not ansible_check_mode | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need old postgres for migration |
||
|
|
||
|
|
||
| - name: Create Postgres log file | ||
| file: | ||
| path: /srv/logs/postgresql14.log | ||
| state: touch | ||
| force: yes | ||
| group: postgres | ||
| owner: postgres | ||
| mode: 0644 | ||
|
|
||
| - name: Add the user 'postgres' to group 'pmm' | ||
| user: | ||
| name: postgres | ||
| groups: pmm | ||
| append: yes | ||
|
|
||
| - name: Check if Postgres 11 exist | ||
|
nikita-b marked this conversation as resolved.
Outdated
|
||
| stat: | ||
| path: /srv/postgres | ||
| register: is_postgres_11 | ||
|
|
||
| - name: Upgrade postgres from 11 to 14 | ||
| block: | ||
| - name: Create Postgres data cluster | ||
|
nikita-b marked this conversation as resolved.
Outdated
|
||
| command: /usr/pgsql-14/bin/initdb -D /srv/postgres14 | ||
| become: yes | ||
| become_user: postgres | ||
| become_method: su | ||
|
|
||
| - name: Stop pmm-managed and postgres before changing encoding | ||
| supervisorctl: | ||
| name: "{{ item }}" | ||
| state: stopped | ||
| loop: | ||
| - pmm-managed | ||
| - postgresql | ||
|
|
||
| - name: Run Postgres database without supervisor | ||
| command: /usr/pgsql-11/bin/pg_ctl start -D /srv/postgres | ||
| become: yes | ||
| become_user: postgres | ||
| become_method: su | ||
|
|
||
| - name: Dump pmm-managed database | ||
| postgresql_db: | ||
| name: pmm-managed | ||
| state: dump | ||
| target: /tmp/pmm-managed-upgrade.sql | ||
|
|
||
| - name: Stop Postgres database without supervisor | ||
| command: /usr/pgsql-11/bin/pg_ctl stop -D /srv/postgres | ||
| become: yes | ||
| become_user: postgres | ||
| become_method: su | ||
|
|
||
| - name: Start Postgres 14 database without supervisor | ||
| command: /usr/pgsql-14/bin/pg_ctl stop -D /srv/postgres14 | ||
| become: yes | ||
| become_user: postgres | ||
| become_method: su | ||
|
|
||
| - name: Create pmm-managed database | ||
| postgresql_db: | ||
| name: pmm-managed | ||
| state: present | ||
|
|
||
| - name: Restore pmm-managed database | ||
| postgresql_db: | ||
| name: pmm-managed | ||
| state: restore | ||
| target: /tmp/pmm-managed-upgrade.sql | ||
|
|
||
| - name: Stop Postgres 14 database without supervisor | ||
| command: /usr/pgsql-14/bin/pg_ctl stop -D /srv/postgres14 | ||
| become: yes | ||
| become_user: postgres | ||
| become_method: su | ||
|
|
||
| - name: Remove old postgres packages | ||
| yum: | ||
| name: | ||
| - percona-postgresql11-server | ||
| - percona-postgresql11-contrib | ||
| - percona-postgresql11 | ||
| - percona-postgresql11-libs | ||
| state: absent | ||
|
|
||
| - name: Delete old repo file | ||
| file: | ||
| state: absent | ||
| path: "/etc/yum.repos.d/percona-ppg-11.repo" | ||
|
|
||
| - name: Rename old Postgres directory | ||
| copy: | ||
| remote_src: true | ||
| src: /srv/postgres | ||
| dest: /srv/postgres11 | ||
| when: is_postgres_11.stat.exists | ||
|
|
||
| - name: Disable logging_collector | ||
| lineinfile: | ||
| path: /srv/postgres14/postgresql.conf | ||
| regexp: '^logging_collector' | ||
| line: 'logging_collector = off' | ||
| when: not ansible_check_mode | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.