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
Related
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.
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
Followed link OSM Quick start
Had little bilt problems but i managed to perform all the steps. But when my opened my newly created project in tilemill we just mad it shows error
Could not create datasource for type: 'postgis' (searched for datasource plugins in '/usr/lib/mapnik/input') encountered during parsing of layer 'landuse_gen0' in Layer at line 197
Can somebody tell me what this error and how to resolve it. I have followed all steps n provide link above?
The "OSM Bright Quick Start" page is a bit outdated. A few differences to handle installing postgres/postgis for Linux Mint 17.1/Ubuntu 14.04 to handle in Step 0 + 1:
sudo apt-get install postgresql-9.3-postgis-2.1
sudo apt-get install mapnik-input-plugin-postgis
# Set every method to "trust"
sudo vim /etc/postgresql/9.3/main/pg_hba.conf
sudo /etc/init.d/postgresql restart
psql -U postgres -c "create database osm;"
psql -U postgres -d osm -f /usr/share/postgresql/9.3/contrib/postgis-2.1/postgis.sql
psql -U postgres -d osm -f /usr/share/postgresql/9.3/contrib/postgis-2.1/spatial_ref_sys.sql
This worked for me. Then follow with Step 2...
You should check the directory /usr/local/lib/mapnik/input, and you will find the file postgis.input is missing.
The reason is that when you compile mapnik, the dependency for plugin 'postgis' can not be satisfied. You can run python scons/scons.py INPUT_PLUGINS='postgis' in the shell and you would be reminded some dependency problem. So you should add the postgresql and postgis to the system environment before make mapnik.
Make sure postgresql94-devel has been already installed or you can run sudo yum install postgresql94-devel.Then, you can do like this
export PATH=$PATH:/usr/pgsql-9.4/bin:/usr/pgsql-9.4/lib:/usr/local/lib
and then use the ./configure,make and make install command for mapnik. After reinstallation of mapnik, you should find postgis.input in the directory /usr/local/lib/mapnik/input and then try again.
I upgraded to mavericks and had some trouble installing/compiling new gems so I reinstalled xcode and did a brew update and upgrade. Gems work now, and even postgres continued to work for a while until a recent reboot. Now postgres seems to be having issues.
postgres:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
brew info postgres:
postgresql: stable 9.3.2 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.2.4 (2842 files, 39M)
Built from source
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 39M) *
Poured from bottle
postgres -D /usr/local/var/postgres:
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.3.2.
What should I do now to get my database working again?
$ brew tap homebrew/versions
$ brew install postgresql92
$ brew switch postgresql 9.2.8 # might need to check this one, could be newer by the time you read this
$ pg_dumpall > ninedottwo-dump
$ brew uninstall postgresql92
$ brew switch postgresql 9.3.4 # again, check version
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
$ createdb # i got an error about my database not existing, so i had to run this
$ psql < ninedottwo-dump
$ bundle exec rails s
Thanks to Peter for getting me started in the right direction.
edit: this'll teach me to upgrade everything all at once...
You need to get a copy of PostgreSQL 9.2 installed somehow, to be able to access the existing data directory.
Options for installing 9.2 via Homebrew include:
Get a checkout of Homebrew from before the postgresql formula was upgraded to 9.3.
Install postgresql92 from homebrew/versions tap.
Install postgresql-9.2 from petere/postgresql tap (disclosure: that's my project).
Install from source.
Then you ought to upgrade that to 9.3 using either pg_dump or pg_upgrade.
pg_upgrade comes for this very purpose, and using it is straightforward. Just make sure you're specifying the right paths for the old data and binaries ( -d and -b ) and the right paths to the new data and binaries (-D and -B):
pg_upgrade \
-d /usr/local/var/postgres/9.2/ -D /usr/local/var/postgres/9.3/ \
-b /usr/local/Cellar/postgresql/9.2.4/bin/ -B /usr/local/Cellar/postgresql/9.3.2/bin/
If everything goes fine, you can then cleanup old versions with brew cleanup postgresql,
and since a new version of PostgreSQL means new versions of the native libraries that are used by the Ruby pg gem, you may want to recompile it:
gem uninstall pg
ARCHFLAGS="-arch x86_64" gem install pg
For 9.2 to 9.5, on El Capitan, I ran into a couple problems which might help others.
It seems now the name of the package used in the switch statement has changed to include the version number (postgresql92 vs postgresql). So, I needed to have the added step of unlinking the current version of postgres:
brew unlink postgresql
brew link postgresql92
brew switch postgresql92 9.2.13 # match version
In order to perform the dump I needed to start the postgres server,
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
But then I ran into the dreaded:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I check out the logs and found this:
could not open directory "pg_tblspc": No such file or directory
According to this answer by Donovan, Yosemite and El Capitan remove some needed directories. So I also needed to add those directories back in using this awesome command by Nate
mkdir /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_snapshots}/
So the full updated version is:
brew tap homebrew/versions
brew install postgresql92
brew unlink postgresql
brew switch postgresql92 9.2.13 # might need to check this one, could be newer by the time you read this
mkdir /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_snapshots}/
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_dumpall > ninedottwo-dump
pg_ctl -D /usr/local/var/postgres stop
brew unlink postgresql92
brew uninstall postgresql92
brew switch postgresql 9.5.2 # again, check version
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
createdb # i got an error about my database not existing, so i had to run this
psql < ninedottwo-dump
bundle install # need to make sure you have pg gem for 9.5
bundle exec rails s
All credit goes to sentinel, Nate, and Donovan. Thanks so much!
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