1
1
Fork 0
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2024-05-26 06:06:04 +02:00

Migrate PostgreSQL to C.UTF-8

C.UTF-8 is installed by default, so we can avoid messing with locale-gen
by using that.

All the postgres servers (excluding matrix due to[1]) have been migrated
with the following commands:
# sudo -u postgres pg_dumpall > d
# sed "s/LOCALE = 'C'/LOCALE = 'C.UTF-8'/" -i d
# systemctl stop postgresql.service
# mv /var/lib/postgres/data{,.old}
$ ansible-playbook --diff -t postgres playbooks/<host>.yml
# sudo -u postgres psql < d

[1] 19a57f4a37/docs/postgres.md (fixing-incorrect-collate-or-ctype)

Fix #470
This commit is contained in:
Kristian Klausen 2022-10-22 21:12:41 +02:00
parent 3e2fdfce00
commit e9e44d445c
No known key found for this signature in database
GPG Key ID: E2BE346E410366C3
5 changed files with 6 additions and 19 deletions

View File

@ -48,11 +48,6 @@
- item.fstype == 'btrfs'
- not 'backup' in item.mount
- name: Generate locales
locale_gen: name={{ item }} state=present
with_items:
- en_US.UTF-8
- name: Configure locales
template: src=locale.conf.j2 dest=/etc/locale.conf owner=root group=root mode=0644

View File

@ -127,14 +127,6 @@
- name: Mount /dev to new chroot # noqa command-instead-of-module
command: mount --rbind /dev /mnt/dev creates=/mnt/dev/zero
- name: Configure locale.gen
lineinfile: dest=/mnt/etc/locale.gen line="en_US.UTF-8 UTF-8" owner=root group=root mode=0644
- name: Run locale-gen inside chroot
command: chroot /mnt locale-gen
register: chroot_locale_gen
changed_when: "chroot_locale_gen.rc == 0"
- name: Run systemd-firstboot
command: chroot /mnt systemd-firstboot --locale=C.UTF-8 --timezone=UTC --hostname={{ hostname }}
register: chroot_systemd_firstboot

View File

@ -46,7 +46,7 @@ chown postgres: /var/lib/postgres/data
chattr -f +C /var/lib/postgres/data || :
# initialize the new cluster
su - postgres -c 'initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data'
su - postgres -c 'initdb --locale C.UTF-8 -E UTF8 -D /var/lib/postgres/data'
# copy existing configuration and SSL certs from the old cluster
for f in pg_hba.conf postgresql.conf {fullchain,chain,privkey}.pem; do

View File

@ -21,7 +21,7 @@
become: true
become_user: postgres
become_method: su
command: initdb --locale en_US.UTF-8 -E UTF8 -D '/var/lib/postgres/data'
command: initdb --locale C.UTF-8 -E UTF8 -D '/var/lib/postgres/data'
args:
chdir: /var/lib/postgres
creates: /var/lib/postgres/data/postgresql.conf

View File

@ -707,11 +707,11 @@ timezone = 'UTC'
# encoding
# These settings are initialized by initdb, but they can be changed.
lc_messages = 'en_US.UTF-8' # locale for system error message
lc_messages = 'C.UTF-8' # locale for system error message
# strings
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
lc_numeric = 'en_US.UTF-8' # locale for number formatting
lc_time = 'en_US.UTF-8' # locale for time formatting
lc_monetary = 'C.UTF-8' # locale for monetary formatting
lc_numeric = 'C.UTF-8' # locale for number formatting
lc_time = 'C.UTF-8' # locale for time formatting
# default configuration for text search
default_text_search_config = 'pg_catalog.english'