# PostgreSQL升级时在重建过程中出现与地区设置相关的错误

**URL:** https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621
**Category:** Self-hosting
**Created:** [16.Май.2018 10:52:40 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621 "2018-05-16T10:52:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![\_vincent](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/_vincent/32/119557_2.png) [@\_vincent](https://meta.discourse.org/u/_vincent)
#### Post date: [16.Май.2018 10:52:40 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/1 "2018-05-16T10:52:40Z")

</div>

Hi,

I’m currently trying to rebuild my container, which desperately fails:

```
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "fr_FR.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

```

The first time, I got this message:

```
les valeurs de lc_collate de la base de données « postgres » ne correspondent pas : ancien « en_US.UTF-8 », nouveau « fr_FR.UTF-8 »

Échec, sortie

-------------------------------------------------------------------------------------

UPGRADE OF POSTGRES FAILED

You are going to need to export your data and import into a clean instance:

In containers/app.yml: Change "templates/postgres.template.yml" TO "templates/postgres.9.5.template.yml"

Run ./launcher rebuild app again

When your instance is running:

Run ./launcher enter app

Run apt-get remove postgresql-client-9.5

Run cd /shared/postgres_backup &amp;&amp; sudo -u postgres pg_dump discourse &gt; backup.db

Undo the base_image in your container config

Run: ./launcher stop app

Run: sudo mv /var/discourse/shared/standalone/postgres_data /var/discourse/shared/standalone/postgres_data_old

Run: ./launcher rebuild app

Run: ./launcher enter app

Run: cd /shared/postgres_backup

Run: sv stop unicorn

Run: sudo -iu postgres dropdb discourse

Run: sudo -iu postgres createdb discourse

Run: sudo -iu postgres psql discourse &lt; backup.db

Run: exit

Run: ./launcher rebuild app

```

I’m trying to follow the instructions but it keeps failing, apparently due to the previous locale error.  
I did locale-gen the correct locales.

Help anyone?

Thanks!

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [16.Май.2018 11:06:58 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/2 "2018-05-16T11:06:58Z")

</div>

have you tried `sudo dpkg-reconfigure locales`

---

<div class="post-metadata">

### Author: ![\_vincent](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/_vincent/32/119557_2.png) [@\_vincent](https://meta.discourse.org/u/_vincent)
#### Post date: [16.Май.2018 12:09:35 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/3 "2018-05-16T12:09:35Z")

</div>

Yes, and I set the default locale to en\_US.UTF-8.

```
λ vincent@zbeul /var/discourse/ master echo $LANG
en_US.UTF-8
λ vincent@zbeul /var/discourse/ master sudo echo $LANG
en_US.UTF-8

```

And yet…

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [16.Май.2018 12:11:19 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/4 "2018-05-16T12:11:19Z")

</div>

The problem with postgresql seems unrelated to locales to me. Can you please give it a shot once again?

---

<div class="post-metadata">

### Author: ![\_vincent](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/_vincent/32/119557_2.png) [@\_vincent](https://meta.discourse.org/u/_vincent)
#### Post date: [16.Май.2018 12:14:22 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/5 "2018-05-16T12:14:22Z")

</div>

Here is the resulting log for a rebuild:

> **[Alternatives to](https://alt.framasoft.org/framabin/)**
>
> Framasoft is at full capacity, but we are not leaving you:
> we are part of the collective CHATONS and other members of the network will
> be delighted to welcome you.

with the postgres.9.5 template in app.yml.

---

<div class="post-metadata">

### Author: ![itsbhanusharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/itsbhanusharma/32/180717_2.png) [@itsbhanusharma](https://meta.discourse.org/u/itsbhanusharma)
#### Post date: [16.Май.2018 12:21:59 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/6 "2018-05-16T12:21:59Z")

</div>

I don’t understand why is it falling back to C. are you sure dpkg reconfigure shown you the correct locales? (space is select, tab is toggle and enter is OK)  
Word of caution, It may totally not be related to locales, I’d wait for someone from team to comment.

---

<div class="post-metadata">

### Author: ![\_vincent](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/_vincent/32/119557_2.png) [@\_vincent](https://meta.discourse.org/u/_vincent)
#### Post date: [16.Май.2018 12:24:31 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/7 "2018-05-16T12:24:31Z")

</div>

Yes, I’m absolutely sure. Thanks for your replies.

The real error seems to lie along these lines:

```
Finding the real data directory for the source cluster
could not get data directory using "/usr/lib/postgresql//bin/postgres" -D "/shared/postgres_data" -C data_directory: No such file or directory
Failure, exiting

```

---

<div class="post-metadata">

### Author: ![\_vincent](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/_vincent/32/119557_2.png) [@\_vincent](https://meta.discourse.org/u/_vincent)
#### Post date: [16.Май.2018 13:43:17 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/8 "2018-05-16T13:43:17Z")

</div>

OK – back online.

I managed to go through the postgresql update process. The locale had to be changed container-side.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [08.Июнь.2024 12:37:28 UTC](https://meta.discourse.org/t/postgresql-upgrade-error-with-locale-on-rebuild/87621/9 "2024-06-08T12:37:28Z")

</div>

Эта тема была автоматически закрыта через 2215 дней. Новые ответы больше не принимаются.
