# [SOLVEDemerge --config =dev-db/postgresql-server-9.0.3-fails

## Joseph_sys

When I try to emerge postgresql-server-9.0.3 it fails:

```
...

creating configuration files ... ok

creating template1 database in /var/lib/postgresql/9.0/data/base/1 ... initdb: input file "/usr/share/postgresql-8.4/postgres.bki" does not belong to PostgreSQL 9.0.3
```

There was a similar bug posted about 8.4

https://bugs.gentoo.org/show_bug.cgi?id=284437

but when I tried to follow that solution it doesn't work 

```
...

2. eselect postgresql set-all 9.0

3. emerge dev-db/postgresql-server:9.0

4. strings /usr/lib/postgresql-9.0/bin/*|grep 'postgresql-8\.4'

The last command lists the references to directories from 8.4. This list should

be empty, otherwise, e.g. as in this bug report,
```

It lists bunch of files that shouldn't be there (I think)

```
strings /usr/lib/postgresql-9.0/bin/*|grep 'postgresql-8\.4'

/usr/lib/postgresql-8.4/bin

/usr/share/postgresql-8.4

/etc/postgresql-8.4

/usr/include/postgresql-8.4

/usr/lib/postgresql-8.4/lib

/usr/share/doc/postgresql-8.4

/usr/share/postgresql-8.4/man

...

```

Last edited by Joseph_sys on Wed Feb 16, 2011 8:15 pm; edited 1 time in total

----------

## Joseph_sys

It seems to me it is looking for the file postgres.bki in a wrong directory it should be in directory.

"/usr/share/postgresql-9.0

Anybody knows how to correct it.

I've filed a bug:

https://bugs.gentoo.org/show_bug.cgi?id=355245

----------

## Joseph_sys

SOLVED

user has to run:

eselect postgresql set 9.0

before emerging "postgresql-server-9.0.3" so the links get correctly

configured.

I wish there was some note about it before emerging postgresql-server

----------

## mansuetus

I had the same trouble : to upgrade postgresql from 8.4 --> 9.0 : upgrade did not work...

So, I ran (after "emerge -Du world" and several tests)

```

# eselect postgresql set 9.0

# emerge -1 postgresql-server 

# emerge --config =dev-db/postgresql-server-9.0.3

(enter when << Are you ready to continue? (Y/n) >>)

# chmod 777 /var/lib

(pg_upgrade needs to write /var/lib/pg_upgrade_dump_all.sql)

# su postgres -

$ cd

(important to leave /root)

$ pg_upgrade -d /var/lib/postgresql/8.4/data/ -D /var/lib/postgresql/9.0/data/ -b /usr/lib64/postgresql-8.4/bin/ -B /usr/lib64/postgresql-9.0/bin/

$ exit

#  rc-update del postgresql-8.4

#  rc-update add postgresql-9.0 default

# /etc/init.d/postgresql-9.0 start

# chmod 755 /var/lib/

Your DB now works fine again... But still, you can :

# su postgres -

$ vacuumdb --all --analyze-only

$ /var/lib/delete_old_cluster.sh

```

Hope this help !

----------

## sam_i_am

Thank you so much. This worked and saved me a lot of time.

----------

## theBlackDragon

 *mansuetus wrote:*   

> I had the same trouble : to upgrade postgresql from 8.4 --> 9.0 : upgrade did not work...
> 
> So, I ran (after "emerge -Du world" and several tests)
> 
> ```
> ...

 

How do you manage to get pg_update past the part where it tries to launch the servers?

```
% su -l postgres -c "pg_upgrade -d /var/lib/postgresql/8.4/data -D /var/lib/postgresql/9.0/data -b /usr/lib64/postgresql-8.4/bin -B /usr/lib64/postgresql-9.0/bin"

Password:

Performing Consistency Checks

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

Checking old data directory (/var/lib/postgresql/8.4/data)  ok

Checking old bin directory (/usr/lib64/postgresql-8.4/bin)  ok

Checking new data directory (/var/lib/postgresql/9.0/data)  ok

Checking new bin directory (/usr/lib64/postgresql-9.0/bin)  ok

Checking for reg* system oid user data types                ok

Checking for /contrib/isn with bigint-passing mismatch      ok

Checking for large objects                                  ok

Creating catalog dump                                       ok

Trying to start new server                                  .................ok

 Unable to start new postmaster with the command: "/usr/lib64/postgresql-9.0/bin/pg_ctl" -l "/dev/null" -D "/var/lib/postgresql/9.0/data" -o "-p 5432 -c autovacuum=off -c autovacuum_freeze_max_age=2000000000" start >> "/dev/null" 2>&1

Perhaps pg_hba.conf was not set to "trust".% 
```

pg_hba.conf is just the default ending with these lines (which are correct I think):

```
# TYPE  DATABASE        USER            CIDR-ADDRESS            METHOD

# "local" is for Unix domain socket connections only

local   all             all                                     trust

# IPv4 local connections:

host    all             all             127.0.0.1/32            trust

# IPv6 local connections:

host    all             all             ::1/128                 trust
```

On a semi related note, the postgres 9 init script seems stuck thinking it's been started now, there's no locks in /var/run and no socket in the data dir either and no running postgres processes (of course). Any idea how to convince it to reset? There used to be an init switch for that but it seems to have gone the way of the dodo somewhere over the past years.

----------

## titanofold

Try with the latest revision of the 9.0.3 ebuilds.

And don't forget to look at /var/log/postgresql/9.0/data/postmaster.log for a hint as to why it isn't starting properly.

----------

