upgrading postgresql cluster from 9.5 to 11 nominatim.so incompatible - postgresql

PostgreSQL 9.5
Database nominatim
if I try to upgrade postgresql to 11 with:
sudo pg_upgradecluster -m upgrade -k 9.5 main
result:
more /var/log/postgresql/pg_upgradecluster-9.5-11-main.Dzbj/loadable_libraries.txt
could not load library "/mnt/data/openstreetmap/nominatim/Nominatim-2.5.1/module/nominatim.so": ERROR: biblioteca «/mnt/data/openstreetmap/nominatim/Nominatim-2.5.1/mo
dule/nominatim.so» incompatible: versión no coincide
DETALLE: Server is version 11, library is version 9.5.
What steps should I follow to avoid having to delete the database and recreate it?

postgresql 9.5 to 11
nomintaim with postgis 2.2 to 2.5
sudo apt-get install curl ca-certificates
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql-11
sudo service postgresql stop
sudo pg_dropcluster --stop 11 main
sudo apt-get install postgresql-11-postgis-2.5
sudo apt-get install postgresql-server-dev-11
sudo apt-get install postgresql-doc-11
sudo apt-get install postgresql-contrib
sudo apt-get install postgresql-9.5-postgis-2.5
sudo cp /usr/lib/postgresql/11/lib/postgis-2.5.so /usr/lib/postgresql/11/lib/postgis-2.2.so
sudo cp /usr/lib/postgresql/11/lib/rtpostgis-2.5.so /usr/lib/postgresql/11/lib/rtpostgis-2.2.so
sudo service postgresql start
sudo psql gis postgres -c 'ALTER EXTENSION postgis UPDATE TO "2.5.1";'
sudo psql nominatim postgres -c 'ALTER EXTENSION postgis UPDATE TO "2.5.1";'
sudo service postgresql stop
sudo service postgresql start
sudo -u postgres psql -d nominatim
psql (11.1 (Ubuntu 11.1-3.pgdg16.04+1), servidor 9.5.14)
Digite «help» para obtener ayuda.
nominatim=# SELECT postgis_full_version();
nominatim=# \q
sudo service postgresql stop
su - nominatim
cd /..../Nominatim-3.2.0/
mv build build.old
mkdir build
cd build/
cmake ..
make
sudo pg_upgradecluster -m upgrade 9.5 main
sudo su postgres -c "/usr/lib/postgresql/11/bin/vacuumdb --all --analyze-in-stages"
sudo pg_dropcluster 9.5 main --stop
...

Related

Is it possible to install postgresql 11 on Ubuntu 14.04?

I'm running on a Ubuntu 14,04 ('trusty') with no possibility to upgrade (a complex website-management platform is dependant upon it), but I'd like to install the latest version of postgresql in parallel... are there any compatibility issues?
Yes, I tried it just now, I followed the guide here: https://gist.github.com/alistairewj/8aaea0261fe4015333ddf8bed5fe91f8
# add postgresql to apt repository
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
# get the signing key and update
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
# install postgresql
sudo apt-get install postgresql-11
# ensure that the server is started by switching to the postgres user
sudo su - postgres
# I didn't do this part since the database was started during install
# and I checked via `psql`
# /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main -l logfile start

There is no cubedata.h and contrib directory in Postgresql

I has 128-dimensional vectors of float (face recognition issue). To store these vectors I use datatype cube in Postgresql.
This type has limit by default - 100 dim.
In the psql (PostgreSQL) 10.5 (Ubuntu 10.6-0ubuntu0.18.04.1) this limit don't work: I can store my vector without any problems.
But yeasterday one of my machine was updated to PostgreSQL 10.6 and now I receive an error when try to add new cube-vector into my database. Error about too long vector.
To resolve this problem I have to change this limit in the file cubedata.h which is in contrib directory. But I have no this file and such directory at all!
I try install
sudo apt-get install postgresql-contrib
but, I get the message about the newest postgresql-contrib version is already installed.
After I tried to manually download cubedata.h file into the directory of Postgresql (/usr/share/postgresql/10/extension/), but it doesn't help.
My be someone encountered with such problem?
In Ubuntu 18.04.1 cubedata.h included in the postgres-server-dev-10 package from the PostgreSQL official repository. But prebuilt cube.so included in the postgresql-10 package with default limit.
To increase the limit you should recompile cube.so from source. Below the example of code for the Ubuntu.
Add repository:
PG_VER=10.6
source /etc/os-release
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${VERSION_CODENAME}-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get install -y postgresql-${PG_VER%.*}
Compile cube extension from source:
PG_VER=10.6
sudo apt-get install -y unzip gcc make zlib1g-dev libreadline-dev postgresql-server-dev-${PG_VER%.*} bison flex
wget https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.bz2 --quiet -O postgresql.tar.bz2
tar xvf postgresql.tar.bz2
cd postgresql-${PG_VER}
./configure
cd contrib/cube
sed -i 's/#define CUBE_MAX_DIM (100)/#define CUBE_MAX_DIM (128)/' cubedata.h
make USE_PGXS=1
sudo make USE_PGXS=1 install
Check result after restart server:
sudo -u postgres psql dbname -c 'CREATE EXTENSION cube'
sudo -u postgres psql dbname -c 'SELECT cube_dim(cube(array(select generate_series(1, 128)))) as dim'

Cannot install postgres on Ubuntu (E: Unable to locate package postgresql)

So I'm having this problem where for some reason I can't install any package on my ubuntu system.
I'm currently on Ubuntu 16.10.
terminal install logs
Update:
I've done entered those commands and got this.
after update and apt-cache
What should I do now?
sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
After installing the PostgreSQL database server, by default, it creates a user ‘postgres’ with role ‘postgres’. Also creates a system account with the same name ‘postgres’. So to connect to Postgres server, log in to your system as user postgres and connect database.
sudo su - postgres
psql
First do
sudo apt-get update
You should get no errors upon updating. In case you do, then you might have issues with your firewall, or something blocking you from updating repositories. Check the output carefully.
And then search for the correct (exact!) package name using this command:
apt-cache search postgresql
As a last resort you could add external 3rd Party repository as described in this answer. Just remember to use your distribution name instead of "xenial".
It should work.
$ sudo apt-get install postgresql postgresql-client
If you are getting (E: Unable to locate package postgresql-12) while migrating following step may helps you:
sudo apt-get -y install bash-completion wget
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc |
sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-12 postgresql-client-12
sudo systemctl status postgresql
ref:install postgres12 in ubuntu-18.04
Following Commands worked for me: sudo apt-get install wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ lsb_release -cs-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt install postgresql-11 libpq-dev

Enable Postgis extension Postgres in Dockerfile

How can i enable the Postgis extension in a Dockerfile? The Postgres installation is already working
this is the command in Ubuntu:
sudo -u postgres psql -c "CREATE EXTENSION postgis;"
My Dockerfile:
# Set the base image to Ubuntu
FROM ubuntu:14.04
# Update the repository sources list
RUN apt-get update -y
################## BEGIN INSTALLATION ######################
# Postgres with Postgis
# Install wget
RUN apt-get install wget -y
# Setup Postgres repository
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# Add Postgres repository
RUN sh -c "echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list"
# Update repository
RUN apt-get update -y
# Install Postgres with Postgis
RUN apt-get install postgresql-9.3-postgis-2.1 -y
# Change rights for start Postgresql
RUN chmod +x /etc/init.d/postgresql
# Start Postgresql
CMD service postgresql start && tail -F /var/lib/postgresql/data/serverlog
The solution for enable an extension
# Enable Postgis
RUN service postgresql start \
&& sudo -u postgres psql -c "CREATE EXTENSION postgis;"
RUN service postgresql stop
If you see other Dockerfiles using that psql -c command, like apache/marmotta Dockerfile, you will see lines like:
RUN service postgresql start \
&& psql --command "CREATE USER $DB_USER WITH PASSWORD '$DB_PASS';" \
&& psql --command "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER;"
USER root
RUN service postgresql stop
In other words, you need to make sure the postgresql service is running for those commands to succeed.

Docker Entrypoint for Postgres 9.3

This is my Dockerfile for installing Postgres.
# Set the base image to Ubuntu
FROM ubuntu:14.04
# Update the repository sources list
RUN apt-get update -y
################## BEGIN INSTALLATION ######################
# Install wget
RUN apt-get install wget -y
# Setup Postgres repository
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc
| sudo apt-key add -
# Add Postgres repository
RUN sh -c "echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list"
# Update repository
RUN apt-get update -y
# Install Postgres with Postgis
RUN apt-get install postgresql-9.3-postgis-2.1 -y
How can i add an Entrypoint for Postgres so that Postgres is automatically started in a Docker-container
My solution to start Postgres automatic:
RUN chmod +x /etc/init.d/postgresql
CMD service postgresql start && tail -F /var/lib/postgresql/data/serverlog
You can take ideas from the official docker-library/postgres Dockerfile:
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
They use a docker-entrypoint.sh script which will, at the end, launch postgres
exec gosu postgres "$#"