cannot find adminpack.sql in postgresql 9.1 - postgresql

I'm trying to get it installed and use in ubuntu. Was following this page to install the additional instrumentation packages.
Install Server Instrumentation for Postgresql 8.4
To install Server Instrumentation for Postgresql 8.4 you may use the command line and type:
sudo apt-get install postgresql-contrib
Run the adminpack.sql script, simply type:
sudo -u postgres psql < /usr/share/postgresql/8.4/contrib/adminpack.sql
But I couldn't find adminpack.sql in 9.1 version.

In PostgreSQL 9.1 and later, extensions can be installed via the CREATE EXTENSION command:
sudo -u postgres psql
CREATE EXTENSION "adminpack";

Try locate adminpack. But first, run updatedb to make sure the locate database is up to date.
sudo updatedb
locate adminpack
The output is:
/usr/lib/postgresql/9.1/lib/adminpack.so
/usr/share/postgresql/9.1/extension/adminpack--1.0.sql
/usr/share/postgresql/9.1/extension/adminpack.control

Looks like this is old and comments are closed, so I'm opening another answer.
ldalonzo's answer is correct once you have all the components, but I found I also had to run:
sudo apt-get install postgresql-contrib-9.1
Looks like the bare postgresql package doesn't include the additional modules.

Once you install postgresql-contrib using below command
sudo apt-get install postgresql-contrib
Adminpack is located in the below path
/usr/share/postgresql/9.1/extension/adminpack--1.0.sql
To load the adminpack use the below command
sudo su postgres -c psql < /usr/share/postgresql/9.1/extension/adminpack--1.0.sql
Then
sudo /etc/init.d/postgresql restart

Related

How to install postgresql-client to Amazon EC2 Linux machine?

I am trying to install postgresql for the meta data of hive on Amazon EC2 Linux machine.
And at that point, I am trying to connect postgresql outside docker image. Inside, I can connect the postgresql.
I tried this command:
[ec2-user#ip-****-***-** ~]$ sudo yum install postgresql-client -y
and the result:
Failed to set locale, defaulting to C
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00:00
No package postgresql-client available.
Error: Nothing to do
To ensure locale, I tried these ones:
[ec2-user#ip-***-***-*** ~]$ echo "$LANG"
en_US.UTF-8
[ec2-user#ip-***-***-*** ~]$ echo "$LC_CTYPE"
UTF-8
Then, I tried this one install postgresql-client lastly:
[ec2-user#ip-***-***-*** ~]$ sudo amazon-linux-extras install postgresql-client
Topic postgresql-client is not found.
I am not so familiar with these technologies, if you can help I will be so appreciated
Install postgresql package
sudo yum install postgresql
As mentioned by #Anon Coward in comments, this package contains the postgresql client. Check it with
yum search postgresql
If you get the error...
No match for argument: postgresql ...
I found that AWS Linux is a dynamic changing OS, so here is the current method + how to detect a new way to do this...
Current method (as of Oct 21, 2022)
(I have Machine Image (AMI): Amazon Linux 2022)
$ sudo yum update
$ sudo yum install postgresql13
$ psql --version
psql (PostgreSQL) 13.5
Future proof answer
Try this first ...
$ sudo yum update
$ sudo yum search "postgres"
... and look in the output for a line like this: postgresql13.aarch64 : PostgreSQL client programs. This tells you the current version of an installable client package name - in this case postgresql13. Now you know which package to install and avoid: No match for argument: postgresql error.
TLDR;
It seems, for Linux that Amazon now says to use yum directly vs. the old amazon-linux-extras here... Install software packages on an Amazon Linux instance. Then you wonder, how to know which package name to use to install it, which is here: Find software packages on an Amazon Linux instance. I used a small part of the name as a 'key' to search for: sudo yum search "postgres" which got me the answer, by looking at the output.
This currently works for my version of Amazon linux:
$ uname -a
Linux ip-0-0-0-0.ec2.internal 5.15.43-20.123.amzn2022.aarch64 #1 SMP Thu May 26 17:03:36 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
This is a new instance with almost nothing added, not even additional yum archives, YMMV.

How to upgrade psql on Amazon ec2?

I'm aware of how one can upgrade the PostgreSQL version on an RDS instance by using the management console's point-and-click. However, doing so leaves me with mismatched client and server psql versions. I want to upgrade the psql client on my ec2 instance. How does one do so?
You can also use amazon-linux-extras command to install new major versions of postgresql, for example:
$ sudo amazon-linux-extras install postgresql13
$ psql --version
psql (PostgreSQL) 13.3
Note that previous versions will remain enabled, but you can explicitly disable them (even though there's no uninstall, try yum to get rid of packages):
$ sudo amazon-linux-extras disable postgresql11
Tested on:
$ hostnamectl | grep -E -w 'Operating|Kernel|Architecture'
Operating System: Amazon Linux 2
Kernel: Linux 4.14.243-185.433.amzn2.aarch64
Architecture: arm64
The exact solution is going to vary depending on your AMI, but here's what worked for me on Amazon Linux:
sudo yum erase postgresql92 -y
sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm -y
sudo yum install postgresql96 postgresql96-devel -y
sudo ln -sf /usr/pgsql-9.6/bin/pg_config /usr/bin/
You might not need the last step unless you're trying to get the pg gem working in Ruby on Rails.

PostgreSQL ,Postgis and Pgrouting compatible versions

I am trying to work with PostgreSql 9.3, Postgis 2.1.3 and Pgrouting 2.0.0 versions in Ubuntu (VPS). I have installed PostgreSql 9.3,but when i run CREATE EXTENSION postgis SCHEMA public VERSION "2.0.0"; in PgAdmin3 i get ERROR: could not stat file "/usr/share/postgresql/9.3/extension/postgis--2.1.3.sql": No such file or directory and same error with Pgrouting 2.0.0.Are these versions compatibles running in that system?,in localhost work fine.
sudo apt-get update
sudo apt-get install postgresql-9.3 postgresql-9.3-postgis-2.1 postgresql-9.3-postgis-scripts postgresql-contrib-9.3 postgresql-client-common postgresql-common postgresql-server-dev-9.3 postgresql-client-9.3
This should install everything and start the server. Read the following man pages. to create a user and a database.
man createuser
man createdb
and this will install postgis into database 'mydatabase' for user 'user':
psql -U user mydatabase -c "create extension postgis"

No passwd entry for user 'postgres' error

I'm trying to setup Postgres on Ubuntu 14.04 without success. After running
sudo apt-get install libpq-dev python-dev
and
sudo apt-get install postgresql postgresql-contrib
I've managed to install the packages successfully. However upon executing sudo su - postgres, I'm receiving the following error:
No passwd entry for user 'postgres'
It seems like the installation did not create the user postgres as it is not in the /etc/passwd file. Reinstalling the package does not resolve the issue. How can I add the required postgres user?
It sounds like you want the PostgreSQL server:
apt-get install postgresql-server
Also, you never need to use sudo su - postgres. Just:
sudo -u postgres -i
to get an interactive shell, or
sudo -u postgres psql
(or whatever) to run a command.
I've solved the issue by purging and re-installing the packages, i.e.
sudo apt-get --purge remove postgresql*
sudo apt-get install postgresql postgresql-contrib

Cannot use commands 'postgres' or 'pg_ctl'

I am on Unix. I have got postgresql-9.3 installed.
When I want to start the server using pg_ctl or postgres, the terminal gives me:
The program 'postgres' is currently not installed. You can install it by typing:
sudo apt-get install postgres-xc
Can't I start the server without this postgres-xc?
This must be remnants of the postgres-xc package you had installed previously.
Since you just installed postgresql-9.3 and don't seem to have any databases in use, yet, I suggest to completely purge all postgres packages.
sudo apt-get purge postgresql-9.2
sudo apt-get purge postgresql-xc
...
Until there's nothing left:
dpkg -l | grep postgres
Then start from scratch. Your instance of pg_ctl seems to belong to the package postgres-xc. This should be gone after you've uninstalled the package. Find out with one of these commands:
dpkg -S pg_ctl
dlocate pg_ctl
apt-file search pg_ctl
pg_ctlcluster is provided by the package postgresql-common.
pg_ctl is provided by the package postgresql-9.3.
More about starting Postgres in the manual.
It is possible you might be missing a few things.
Try:
sudo apt-get install postgresql-client and
sudo apt-get install postgresql postgresql-contrib
The message about installing xc is a dud, it's probably suggesting that based on what it scanned inside the xc repositories.
Here's a good reference to this problem and its solution:
https://dba.stackexchange.com/questions/72580/missing-the-pg-ctl-package-in-postgres-9-3-installation
Due to reasons a normal install of postgres will not place the postgres binary file in the path.
Adding the right directory to the path solves the problem (temporarily).
PATH=/usr/lib/postgresql/9.3/bin:$PATH
To make it permanent on my Ubuntu machine I added the line to /etc/environment this makes it work for all users.
The correct way to set the PATH is different for different systems, for more info see see:
How to permanently set $PATH on Linux?
You must install postgresql-client:
sudo install postgresql-client
Try to enter this command to the console:
sudo -u postgres psql