Is there a problem with having 2 versions of postgres for Apache-Age - postgresql

I installed the Apache-Age extension for postgres and this extension specifies that it works with postgres-11 or postgres-12. However I have already installed postgres-14 on my system. Am i gonna have a problem with that? And if I am how do i only uninstall the postgres-14 version?
I tried searching the deb packages installed to see if i find postgres-14 but i can't seem to find it

So mainly the apache-age extension works with PostgreSQL versions 11 and 12. It creates problems with different other versions of PostgreSQL.
In order to have a smooth installation follow the below steps:
uninstall PostgreSQL version 14
reinstall PostgreSQL version 11 or 12
Uninstalling PostgreSQL version 14:
For uninstalling the PostgreSQL from ubuntu:
sudo apt remove postgresql postgresql-contrib
The output would look something like this:
After uninstalling PostgreSQL, uninstall the dependencies
sudo apt autoremove
The output of the above command would look like this:
enter Y here and the PostgreSQL will be uninstalled.
Now reinstall the PostgreSQL version 11 or 12 using the below commands:
Download the files in any folder:
wget https://ftp.postgresql.org/pub/source/v11.18/postgresql-11.18.tar.gz && tar -xvf postgresql-11.18.tar.gz && rm -f postgresql-11.18.tar.gz
The command will download and extract the tar files for Linux users from Source in the working directory.
Installing PG:
Now we will move toward installing PG
cd postgresql-11.18
# configure by setting flags
./configure --enable-debug --enable-cassert --prefix=$(path) CFLAGS="-ggdb -Og
# now install
make install
References:
For more references you can also see:
https://dev.to/talhahahae/installation-of-apache-age-and-postgresql-from-source-in-linux-part-1-gka
https://www.commandprompt.com/education/how-to-uninstall-postgresql-from-ubuntu/#:~:text=Conclusion-,To%20uninstall%20Postgres%20from%20your%20Ubuntu%20operating%20system%2C%20open%20the,“sudo%20apt%20autoremove”%20command.
https://github.com/git-guides/install-git
https://age.apache.org/age-manual/master/intro/setup.html
https://www.postgresql.org/docs/current/install-procedure.html

Apache AGE only supports Postgres-11 and Postgres-12. You can follow the following to install Apache AGE with Postgres:
How to install AGE extension of postgresql from source code in ubuntu?

While Apache Age is designed to work with PostgreSQL 11 and 12, you can have multiple versions of PostgreSQL installed in your computer. However, the installations need to be in "different directories". Each version of PostgreSQL will have its own set of binaries and configuration files.
When you install multiple versions of PostgreSQL, it is important to ensure that each version is installed in a separate directory and that the ports used by each instance do not conflict with each other. Additionally, you may need to specify the correct version of PostgreSQL when running commands, by using the appropriate version-specific binary or setting the PATH environment variable to include the correct directory.

Related

PostGIS extension on Postgres-xl

I'm trying to deploy a PostGIS cluster using Postgres-XL on AWS, for this I have the next architecture:
SO: ubuntu
1 GTM (172.31.45.190)
1 Coordinator (172.31.45.191)
2 Datanodes (172.31.45.192 and 172.31.45.193)
I had my cluster running but I can't manage to make PostGIS work, I tried the installation with sudo apt-get install postgis but when I try to create the extension inside my db (CREATE EXTENSION postgis;) I got the next error:
ERROR: could not open extension control file "/usr/local/pgsql/share/extension/postgis.control": No such file or directory
The postgis.control file installed by apt-get is in: "/usr/share/postgresql/9.5/extension/postgis.control" so I think is just a problem with the paths but I'm a little lost on that configuration
Thank you in advance for any help!
In case anyone is running in this issue, I solved following this steps:
Install Postgres-xl and PostGIS dependencies to compile (Be sure to install the package postgresql-server-dev-9.5 in this step, otherwise it's going to brake your postgres-xl installation)
Build and install Postgres-XL with ./configure -prefix=/usr/lib/postgresql/9.5
Build and install PostGIS
Start your cluster
You're using a version of PostgreSQL (in this case PostgreSQL-XL) that was installed from somewhere other than the Ubuntu repositories (similar to this issue). The /usr/local/pgsql/share is the configured $SHAREDIR for your installation of PostgreSQL. The default on Ubuntu for PostgreSQL 9.5 should be /usr/share/postgresql/9.5. As far as I can tell $SHAREDIR is configured at compile time and can't easily be changed.
PostGIS gets compiled against the version of PostgreSQL it's going to be used against. So in this case the Ubuntu version of PostGIS isn't going to be compatible with the version of PostgreSQL-XL you're running.
You have two options for fixing the issue:
Install PostgreSQL from the Ubuntu software repository (make sure you back up your database first!) and use that instead of PostgreSQL-XL.
Install PostGIS manually into PostgreSQL-XL.

Timescale not finding pg_config on AMI

I created a machine in AWS Cloud9 and I want to install timescale on that instance. I have previously installed and setup postgres 9.6 using yum.
OS version is:
Amazon Linux AMI release 2018.03
.
When I run 'which pg_config', it is found here:
/usr/bin/pg_config
Looking at the install instructions on the timescale website, I came up with this:
sudo yum install -y
https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
wget
https://timescalereleases.blob.core.windows.net/rpm/timescaledb-0.9.2-postgresql-9.6-0.x86_64.rpm
sudo yum install timescaledb-0.9.2-postgresql-9.6-0.x86_64.rpm
after the last command I get the following error:
Running transaction Installing :
timescaledb-0.9.2-0.el7.centos.x86_64
1/1 ERROR: Could not find pg_config, expected it at
/usr/pgsql-9.6/bin/pg_config. Please fix and try again.
warning: %post(timescaledb-0.9.2-0.el7.centos.x86_64) scriptlet
failed, exit status 1 Non-fatal POSTIN scriptlet failure in rpm
package timescaledb-0.9.2-0.el7.centos.x86_64
Do you have any more details on how you installed PostgreSQL on CentOS? I suspect this may have something to do with a mismatch between your pg_config installation and your PostgreSQL 9.6 installation, similar to the user in this issue.
I'd recommend uninstalling your current postgresql-devel and explicitly installing it for 9.6:
yum install postgresql96-devel
It seems the AMI is setup a bit differently than a normal CentOS install so PostgreSQL is installed in a different place than our installer expected. I've gone ahead and updated the RPMs to use a more robust method of finding the correct place to put the files. If you could re-download the latest RPM and confirm that it works that'd be great.
I've met exactly the same problem.
I solve this by manually linking them together.
sudo ln -s /usr/lib64/pgsql96/bin/pg_config /usr/pgsql-9.6/bin/pg_config

How to install Postgis to a Keg installation of Postgres#9.6 using Homebrew?

I have installed Postgresql#9.6 and Postgis via Homebrew. However, installing Postgis via Homebrew installs the latest version of Postgresql at 10 as dependency and pinning Postgresql at 9.6.5 blocks the install of Postgis via Homebrew.
Performing 'CREATE EXTENSION postgis;' returns:
ERROR: could not open extension control file "/usr/local/Cellar/postgresql#9.6/9.6.5/share/postgresql#9.6/extension/postgis.control": No such file or directory
I've also tried uninstalling the Postgresql (at 10) and editing the Postgis formula to depend on Postgres#9.6 instead of Postgresql.
This is similar to How to install Postgis to a Keg installation of Postgres#9.5 using Homebrew? but with a later keg formula
I managed to do it after many combinations.
In a nutshell, solution is to install the old version of the original package postgres, switch to it, and install the old version of postgis.
Install postgres
1/ Install the current version of postgres (10.1 as speaking)
brew install postgres
2/ Install the old version of postgres using its old formula. Proper link can be found using github or git log on the Tap repo (/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/).
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgresql.rb
This will install the version 9.6.5 (last one before 10.x series).
3/ Switch to it so links are defaulted to postgres 9.6
brew switch postgres 9.6.5
Install postgis
4/ Install old version of postgis (2.3). This is using the same sha version of the Formula so everything is linked correctly (using the current postgis will expect postgresql 10, so it will end up to a version mismatch when initializing extension).
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgis.rb
Use them
5/ If required initialise the DB
initdb /usr/local/var/postgres
6/ Create and use your DB
createdb mydb
psql mydb
mydb=# CREATE EXTENSION postgis;
Installing PEX, a package manager for Postgresql allowed me to install Postgis for the keg version of Postgresql#9.6 and use CREATE EXTENSION postgis;
This isn't a Homebrew solution but after a lot of searching, it finally allowed me to use Postgis.
HelloI ran into this same problem of multiple implementation of pgsql versions including legacy ones. So after a bit of research I would like to share my solution.
Problem:
I am working on a macbook pro 2013 with 10.11 el capitan. I am GIS developer and extensive user of homebrew. I didn't pin the postgresql package for compatibility reasons. Thus, the package got updated to postgresql version 10.5 along other packages. This caused me to be unable to use postgresql version 9.4. The cleverest solution would have been to use a brew switch postgresql 9.4.19. Except that when compiling postgis 2.5.0 from osgeo/osgeo4mac it defautls (looks for) the postgresql binary folder to install the symlinked (or not) extensions. Here again another compatibility problem. One could tinker a bit with homebrew files and transfer files manually. That's ill advice...the package manager (homebrew) needs to stay a coherent ecosystem to provide for a stable workspace.
Proposed Solution:
Go here BigSQL and download the dmg of your chosen version
install the software where you want in your filesystem
within the installation folder you'll find a directory named pg9x ; x being the version number (e.g pg95 for postgresql 9.5 and so on...
in this folder you'll find a file named pg9x.env
source this file to your .profile with source /your/path/pg9x/pg9x.env line
in the main installation folder, for instance /your/path/pg9x/, you'll finde a python script called pgc, alias it to your .profile with alias pgc="your/path/pgc"
save your .profile and refresh your environment variable with source .profile on the command prompt
still within the command prompt, type pgc list, you'll get a list of installed packages. You'll see the version of postgesql you've downloaded
to install another version of postgresql, say 9.6, type pgc install pg96
to install postgis for pg95 type pgc install postgis22-pg95
to install postgis for pg96 type pgc install postgis23-pg96
now, after installation you'll need to initialize the downloaded component with pgc init pg96 or pgc init postgis23-pg96 etc...
to check if your daemon is running correctly type pgc status
to start a version daemon of your choice type for example pgc start pg95
to stop a version daemon of your choice type pgc stop pg95
the installation also comes with an LTS release of pgadmin3 that works fine with all versions (not the case of brew version of pgadmin3), this is very convenient
type pgc help for more options
Let the elephant dance^^
Hope this helps.
Spicy.
I faced a similar issue and what worked for me was to follow the instructions at https://github.com/CloverHealth/homebrew-tap, which seem similar in spirit to #Antwan's solution but with a few more clean up steps, also it gets slightly later versions: postgresql 9.6.10 and postgis 2.5.
My steps differed slightly from those at CloverHealth: My brew version no longer supports brew switch postgresql 9.6.10 and I tried first brew link postgresql#9.6.10 and then brew link postgresql#9.6 but both gave
Error: no such keg
Trying brew search postgresql showed a little green checkmark next to the cloverhealth Formulae, so I tried brew link cloverhealth/tap/postgresql and got
Warning: Already linked: /usr/local/Cellar/postgresql/9.6.10
So, ok it was already linked. Other than that my steps were the same as described at the CloverHealth page, and now I'm up and running again.

Creating Postgis extension: "ERROR: could not open extension control file"

I am getting the following error when I run create extension postgis;
ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory
I am using Postgres 9.6.3 and PostGIS 2.3.2 installed using Homebrew on OS X El Capitan.
mdfind -name postgis.control shows:
/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control
brew info postgis shows:
PostGIS extension modules installed to:
/usr/local/share/postgresql/extension
When I start the Postgres console I see:
psql (9.6.3, server 9.6.1)
I read a similar question, PostGIS Homebrew installation referencing an old path?, and tried to reload postgresql using the commands given in the top answer, but I am still seeing psql (9.6.3, server 9.6.1). Also, I believe my issue is different because it's looking for the extension control file in /Library and not /usr/local/Cellar.
Any help would be appreciated.
When you try to install postgis it install latest version of postgresql along with it as dependency.
So if you installed postgres#V (where V is user desired version )
brew install postgresql#V
later you run this command
brew install postgis
it will install postgres10.1 or whatever is latest.
So after that if run
create extension postgis;
In postgresql#V it will try to check its extension directory and it won't find postgis.control in extension directory as this postgis is installed in extension folder of postgresql version that is installed with that.
To solve this problem, you have to create a symlink from given installation of postgis to the desired postgresql#V
This example for postgresql#9.6
ln -s /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/postgresql#9.6/9.6.6/share/postgresql#9.6/extension/
ln -s /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/postgresql#9.6/9.6.6/lib/postgis-2.3
ln -s /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/postgresql#9.6/9.6.6/lib/
before running these commands, please check postgresql version and file path in your system
Thanks this gist for help.
I had a similar problem with full details here. When the server is mentioned in your Postgres console, it means that you're referencing an older codebase. Stop that server and launch the correct server with the following commands.
$ brew services list
That will give you a list of database servers that are running.
$ brew services stop postgresql#<older-version>
$ brew services start postgresql

How do I install older version of postgresql and postgis?

I am new to Linux and I found it really difficult to install older version of postgresql (along with postgis). I have uninstalled everything I could find connected to postgresql in aptidude. As only the newest version is available through apt-get install, I have went through several tutorials how to get 9.1 installed.
Example: https://wiki.postgresql.org/wiki/Apt (with 9.1 at the end, not 9.3)
After I was done with this tutorial, pgAdmin III is still showing 9.3 as version.
What's the correct way to dump 9.3 and install 9.1 as well as postgis 1.5?
I am using Mint 17
Okay. First off it is perfectly fine to run multiple versions of postgresql alongside one another. You can have more than one cluster on a box, and each cluster can run different versions. The debian pacakges are very well designed to make this easy to do.
However since you've indicated you're a newby to linux/postgresql it's probably best to get 9.3 completely cleaned from your system to avoid frustrating hiccups which will take you a long time to figure out.
To do this you need to:
Purge all postgresql 9.3 packages from dpkg
Manually delete any 9.3 data and configuration for 9.3 cluster
Make sure you've created a 9.1 cluster
Step 1 – purge DPKG
DPKG manages the packages on your system. APT acts as a mechanism for getting packages to install. A lot of DPKG functionality is available through apt, but some things are just easier on dpkg. In your comments you've shown that DPKG is still showing remnants of 9.3. When you uninstall a package some parts of it may hang around (such as configuration files). You can remove multiple packages in one command. To get rid of these completely you can tell dpkg to purge them dpkg --purge <package name>. You can remove multiple packages in one command and it's best to do so.
dpkg --list will list everything on your system. dpkg --list | grep postgresql searches this list for postgresql.
Step 2 – Manually delete data and configuration from the old 9.3 cluster.
When you first install postgresql it creates a cluster for you; no questions asked. This trips up a lot of new users because they neither knew that it happened nor how to replace it. Now that 9.3 is uninstalled you can go ahead and simply delete the configuration and data:
If there was anything you wanted to keep in the installed 9.3 database DO NOT run the following commands
sudo rm -rf /etc/postgresql/9.3 Removes the configuration.
sudo rm -rf /var/lib/postgresql/9.3 Removes the data.
Step 3 – Create a new cluster
You've indicated in comments that postgresql 9.1 is installed. Before you run this command it's worth reading the manual. man pg_createcluster.
sudo pg_createcluster 9.1 <think up a name>
Now you should be able to start up postgresql sudo service postgresql start
Edit
If pg_config is still listing the incorrect version then... this can be a result of remnants of 9.3 still left on your system. This may not be a problem. To allow multiple versions to run along side one another pg_config is a wrapper script which searches for the latest (highest version) of /usr/lib/postgresql/*/bin/pg_config. So what you're seeing is the result of running /usr/lib/postgresql/9.3/bin/pg_config. If 9.3 is completely cleaned from your system then /usr/lib/postgresql/9.3 should have gone.
If you want to see the configuration of 9.1 then try running:
/usr/lib/postgresql/9.1/bin/pg_config.
The wrapper scripts which starts the server will use the file structure of /etc/postgresql and use the apropriate version. So /etc/postgresql/9.1/main will startup version as 9.1.