SOLVED: Problems with bootstrap and recovery

View: New views
11 Messages — Rating Filter:   Alert me  

SOLVED: Problems with bootstrap and recovery

by Rogerio Luz Coelho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok I'll recolect my steps just so it looks good on future searches.

The problem occured in a fresh install of Debian Lenny's PostgreSQL-8.3 server (postgresql-8.3 family packages)

After install the Postres server automatically creates a "main" cluster witch inherits the LC_CTYPE of the system, the problem is that it does not have support for many of the locales the usual Lenny system has, as an example, my "pt_BR" system got Postgres to make a "LATIN1" cluster.

#------------------------------------------------------------
- You find this out by:

1) switching user to postgres
~# su postgres

2) starting psql
postgres@machine# psql

3) asking the database encoding
postgres=# show server_encoding; (the dot-comma IS important)

server_encoding
-----------------
LATIN1
(1 registro)

#-------------------------------------------------------

So when the bootstrap / recovery script finds this it automatically shuts down, as it expects a UTF-8 enco.

How to fix this:

1)Change your LC-CTYPE to 'C'
~# export LC_CTYPE=C

2) Uninstall postgresql-8.3
~# aptitude purge postgresql?

3) Reinstall postgresql-8.3
~# aptitude install postgresql-8.3

4) Edit again the /etc/postgresql/8.3/main/pg_hba.conf file to include the information
as in the GNUmed wiki :
http://wiki.gnumed.de/bin/view/Gnumed/ConfigurePostgreSQL 

5) Restart postgresql
~# /etc/init.d/postgresql-8.3 restart

6) Now you can just restore a Backup and then adjust the db settings:
~# sh /GNUmed-v11.1/server/gm-adjust_db_settings.sh

This sould do it :)

Rogerio




_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Jim Busser :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 2009-10-29, at 6:57 PM, Rogerio Luz Coelho wrote:

> After install the Postres server automatically creates a "main"  
> cluster witch inherits the LC_CTYPE of the system, the problem is  
> that it does not have support for many of the locales the usual  
> Lenny system has, as an example, my "pt_BR" system got Postgres to  
> make a "LATIN1" cluster.

Wonderful... referenced now from

        http://wiki.gnumed.de/bin/view/Gnumed/TroubleshootPostgreSQL


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Jerzy Luszawski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Friday 30 October 2009 02:57:11 Rogerio Luz Coelho napisał(a):
> Ok I'll recolect my steps just so it looks good on future searches.
>
> The problem occured in a fresh install of Debian Lenny's PostgreSQL-8.3
> server (postgresql-8.3 family packages)
>
> After install the Postres server automatically creates a "main" cluster
> witch inherits the LC_CTYPE of the system, the problem is that it does not
> have support for many of the locales the usual Lenny system has, as an
> example, my "pt_BR" system got Postgres to make a "LATIN1" cluster.

This is the correct diagnosis, but the cure doesn't require complete exstirpation of postgres  :)

How I would fix it:
0) Backup your databases (all you have, not only gnumed)!
1) Stop the server using pg_ctlcluster or pg_ctl (depends on your distribution, see man pages for details)
2) Remove the cluster: either manually delete the contents of the $PGDATA directory or use pg_dropcluster if your distro has it.
3) recreate a cluster with desired locale using initdb --locale=...
see http://www.postgresql.org/docs/8.3/static/creating-cluster.html
and http://www.postgresql.org/docs/8.3/static/locale.html
4) Restart the server using pg_ctlcluster or pg_ctl
5) Restore databases to the new cluster or bootstrap gnumed database.

Warning: I'm not sure, but if you have other databases, changing the locale may affect their restoration, read the postgres manual carefully. If you only want to bootstrap gnumed database - no
problem.

Note: You may want to change your system LC_CTYPE anyway, to support UTF-8.

Jerzy Luszawski


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Karsten Hilbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 29, 2009 at 07:15:22PM -0700, Jim Busser wrote:

> On 2009-10-29, at 6:57 PM, Rogerio Luz Coelho wrote:
>
> >After install the Postres server automatically creates a "main"
> >cluster witch inherits the LC_CTYPE of the system, the problem is
> >that it does not have support for many of the locales the usual
> >Lenny system has, as an example, my "pt_BR" system got Postgres to
> >make a "LATIN1" cluster.
>
> Wonderful... referenced now from
>
> http://wiki.gnumed.de/bin/view/Gnumed/TroubleshootPostgreSQL

This is the sort of self-propelled user community activity
that makes me happy spending free time on further developing
GNUmed.

Keep it up, guys ! (and gals - no offence, Liz)

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Karsten Hilbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 29, 2009 at 11:57:11PM -0200, Rogerio Luz Coelho wrote:

> Ok I'll recolect my steps just so it looks good on future searches.

Thanks.

> The problem occured in a fresh install of Debian Lenny's PostgreSQL-8.3
> server (postgresql-8.3 family packages)

Under Lenny, the system still used a non-utf8 locale. In
later versions of Debian this was switched to utf8 so things
should work out of the box.

> After install the Postres server automatically creates a "main" cluster
> witch inherits the LC_CTYPE of the system, the problem is that it does not
> have support for many of the locales the usual Lenny system has, as an
> example, my "pt_BR" system got Postgres to make a "LATIN1" cluster.

Correct.

> How to fix this:
>
> 1)Change your LC-CTYPE to 'C'
> ~# export LC_CTYPE=C

As Jerzy pointed out it'd be beneficial to use UTF-8. What I
don't know is whether that will bring about any problems on
Lenny. It shouldn't though.

Make sure you've got the locales-all package installed ;-)

> 2) Uninstall postgresql-8.3
> ~# aptitude purge postgresql?

After a full backup (as Jerzy pointed out) and
/etc/init.d/postgresql-8.3 stop

        pg_dropcluster

is your friend. pg_lsclusters will tell you more.

> 3) Reinstall postgresql-8.3
> ~# aptitude install postgresql-8.3

        pg_createcluster

> 4) Edit again the /etc/postgresql/8.3/main/pg_hba.conf file to include the
> information as in the GNUmed wiki :
> http://wiki.gnumed.de/bin/view/Gnumed/ConfigurePostgreSQL
>
> 5) Restart postgresql
> ~# /etc/init.d/postgresql-8.3 restart
>
> 6) Now you can just restore a Backup and then adjust the db settings:
> ~# sh /GNUmed-v11.1/server/gm-adjust_db_settings.sh

:-)

Please do read the file that script creates because it
contains a few hints as to some settings which cannot
technically be modified during running of this script ...

I improved this script to also give some indication of the
lc_ctype and server_encoding :-)

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Karsten Hilbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 05:59:46AM +0100, Jerzy Luszawski wrote:

> > After install the Postres server automatically creates a "main" cluster
> > witch inherits the LC_CTYPE of the system, the problem is that it does not
> > have support for many of the locales the usual Lenny system has, as an
> > example, my "pt_BR" system got Postgres to make a "LATIN1" cluster.
>
> This is the correct diagnosis, but the cure doesn't require complete exstirpation of postgres  :)
>
> How I would fix it:
> 0) Backup your databases (all you have, not only gnumed)!
> 1) Stop the server using pg_ctlcluster or pg_ctl (depends on your distribution, see man pages for details)

On Debian, preferably /etc/init.d/postgresql-8.3 stop.

> 2) Remove the cluster: either manually delete the contents of the $PGDATA directory or use pg_dropcluster if your distro has it.

On Debian: pg_dropcluster (pg_lsclusters will show you which
clusters are there).

> 3) recreate a cluster with desired locale using initdb --locale=...
> see http://www.postgresql.org/docs/8.3/static/creating-cluster.html
> and http://www.postgresql.org/docs/8.3/static/locale.html

on Debian: pg_createcluster

> 4) Restart the server using pg_ctlcluster or pg_ctl

On Debian, preferably /etc/init.d/postgresql-8.3 start

> 5) Restore databases to the new cluster or bootstrap gnumed database.
>
> Warning: I'm not sure, but if you have other databases, changing the locale may affect their restoration,

It will but the dump file contains a directive

        set client_encoding to ...

for each of them so when the cluster is utf-8 eventually
that shouldn't pose a problem.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Jerzy Luszawski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> > Restore databases to the new cluster or bootstrap gnumed database.
> >
> > Warning: I'm not sure, but if you have other databases, changing the locale may affect their restoration,
>
> It will but the dump file contains a directive
>
> set client_encoding to ...
>
> for each of them so when the cluster is utf-8 eventually
> that shouldn't pose a problem.

The important thing is, that we destroy a cluster, so if a user has another databases in it, they will be erased. Restoring them under different locale will require special attention. So I just put a warning.

Jerzy Luszawski


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Karsten Hilbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 01:27:21PM +0100, Jerzy Luszawski wrote:

> Subject: Re: SOLVED: [Gnumed-devel] Problems with bootstrap and recovery
> User-Agent: KMail/1.9.10
>
> > > Restore databases to the new cluster or bootstrap gnumed database.
> > >
> > > Warning: I'm not sure, but if you have other databases, changing the locale may affect their restoration,
> >
> > It will but the dump file contains a directive
> >
> > set client_encoding to ...
> >
> > for each of them so when the cluster is utf-8 eventually
> > that shouldn't pose a problem.
>
> The important thing is, that we destroy a cluster, so if a
> user has another databases in it, they will be erased.
> Restoring them under different locale will require special
> attention. So I just put a warning.

That's correct. I was just pointing out that since pg_dump
puts a "set client_encoding to ..." into the backups
restoring them into a utf8 cluster should work just fine -
for whatever "should" means in IT.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Rogerio Luz Coelho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I tried to find how to erase a cluster ... drop cluster was what I was looking for :)

Well anyways, it is almost the same as purge - install ... since you lose everything anyways ;)

Rogerio

2009/10/30 Karsten Hilbert <Karsten.Hilbert@...>
On Fri, Oct 30, 2009 at 01:27:21PM +0100, Jerzy Luszawski wrote:
> Subject: Re: SOLVED: [Gnumed-devel] Problems with bootstrap and recovery
> User-Agent: KMail/1.9.10
>
> > > Restore databases to the new cluster or bootstrap gnumed database.
> > >
> > > Warning: I'm not sure, but if you have other databases, changing the locale may affect their restoration,
> >
> > It will but the dump file contains a directive
> >
> >     set client_encoding to ...
> >
> > for each of them so when the cluster is utf-8 eventually
> > that shouldn't pose a problem.
>
> The important thing is, that we destroy a cluster, so if a
> user has another databases in it, they will be erased.
> Restoring them under different locale will require special
> attention. So I just put a warning.

That's correct. I was just pointing out that since pg_dump
puts a "set client_encoding to ..." into the backups
restoring them into a utf8 cluster should work just fine -
for whatever "should" means in IT.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Karsten Hilbert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 30, 2009 at 09:34:10PM -0200, Rogerio Luz Coelho wrote:

> I tried to find how to erase a cluster ... drop cluster was what I was
> looking for :)
>
> Well anyways, it is almost the same as purge - install ... since you lose
> everything anyways ;)

Not quite. You don't lose configuration information in
pg_hba.conf and postgresql.conf.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel

Re: SOLVED: Problems with bootstrap and recovery

by Rogerio Luz Coelho :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Granted !

Rogerio

2009/10/30 Karsten Hilbert <Karsten.Hilbert@...>
On Fri, Oct 30, 2009 at 09:34:10PM -0200, Rogerio Luz Coelho wrote:

> I tried to find how to erase a cluster ... drop cluster was what I was
> looking for :)
>
> Well anyways, it is almost the same as purge - install ... since you lose
> everything anyways ;)

Not quite. You don't lose configuration information in
pg_hba.conf and postgresql.conf.

Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel


_______________________________________________
Gnumed-devel mailing list
Gnumed-devel@...
http://lists.gnu.org/mailman/listinfo/gnumed-devel