Conflicting versions of postgres database and server - database

I installed postgres on Mac OS X 10.6.x.
When I ran for postgres database version:
psql --versionpsql (PostgreSQL) 9.1.1
contains support for command-line editing
When I checked for the version of the server:
psql -c "select version();" version
--------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.0.5 on x86_64-apple-darwin10.8.0, compiled by GCC i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), 64-bit
(1 row)
So when I run
bash-3.2$ psql
psql (9.1.1, server 9.0.5)
WARNING: psql version 9.1, server version 9.0.
Some psql features might not work.
I am not sure what those features are. These versions are conflicting. I am new to using postgres so I dont know how to upgrade just the postgres server. I tried to search for something online but did not find much help. I don't want to uninstall and reinstall postgres. Is there anyway I could use them both together without them conflicting? Or just upgrade the server to the same version as database?
Edit:
which psql
/opt/local/lib/postgresql91/bin//psql
which postgres
/opt/local/lib/postgresql91/bin//postgres
ps -eaf|grep postgres
0 60 1 0 0:00.07 ?? 0:00.09 /opt/local/bin/daemondo --label=postgresql90-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper restart ; --pid=none
103 3971 3967 0 0:00.69 ?? 0:01.17 postgres: writer process
103 3972 3967 0 0:00.67 ?? 0:00.88 postgres: wal writer process
103 3973 3967 0 0:00.18 ?? 0:00.23 postgres: autovacuum launcher process
103 3974 3967 0 0:00.19 ?? 0:00.21 postgres: stats collector process
0 3616 2726 0 0:00.04 ttys000 0:00.06 su postgres
103 3967 3619 0 0:00.23 ttys000 0:00.34 postgres -D /usr/local/pgsql/data
0 4559 4055 0 0:00.03 ttys001 0:00.05 su postgres
103 5922 4560 0 0:00.01 ttys001 0:00.01 grep postgres
Thank you.

I suppose that you've already had PostgreSQL installed before. Please, confirm this, 'cos in this case you will have to upgrade your database. This is important step, it is not possible to just upgrade the software.
Please, try stopping currently running server. First, check the source of currently running PostgreSQL:
sudo launchctl list | grep -Ei "macports|postgres"
Then perform:
sudo launchctl unload -w <OldPostgreSQL.plist>
and start a new server like this:
sudo launchctl load -w <NewPostgreSQL.plist>
I would expect new plist to be /Library/LaunchDaemons/org.macports.postgresql91-server.plist.
In case you need to upgrade:
Make sure you do a full dump of the database first with the new version of pg_dump.
Execute new version of the initdb in the new PGDATA folder.
Start a new server as outlined above.
Upload the full dump.
Here's a small description I've came across on the subject. And this is the official PostgreSQL documentation on upgrading between major releases.

Mine was a homebrew install and here's what I did (brought me to a functioning psql with no version issues) -- I'm trying to install KyngChaos's mac build of postgresql
step 0 (already did):
brew uninstall postgresql
step1
which psql
=> "locationpath" (in my case, /usr/bin/psql)
sudo rm "locationpath"
step2
#inside ~/.bash_profile
export PATH=/usr/local/pgsql-9.3/bin:$PATH
step3
psql
#works

This may happen if you already had a version of PostgreSQL before new installation.
Since you have two versions of PostgreSQL, you need two versions of psql. Basically, now when you type psql, your system may not be certain to which version of database you are trying to connect.
Remove the previous version. Or install new psql along with new version of the server.

Related

Accessing existing windows postgresql database in WSL

I already have postgresql installed (psql (PostgreSQL) 13.4) and the local server set-up on my windows machine (along with pgAdmin4), and already have some databases in it.
I've recently installed WSL and planning on using it instead of windows+bash going forward. Hence I'm installing postgresql 13 for WSL. I follow https://pgdash.io/blog/postgres-13-getting-started.html for the installation:
# add the repository
> sudo tee /etc/apt/sources.list.d/pgdg.list <<END
> deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg main
> END
# get the signing key and import it
> wget https://www.postgresql.org/media/keys/ACCC4CF8.asc sudo apt-key add
> ACCC4CF8.asc
# fetch the metadata from the new repo
> sudo apt-get update
> sudo apt-get install -y postgresql-13
It installed postgres with psql --version = psql (PostgreSQL) 13.4 (Ubuntu 13.4-1.pgdg20.04+1)
Then I start the service with
> sudo service postgresql start
> sudo -u postgres psql
My questions are:
When I check the list of databases I have using \l, I can't see my existing postgres database that I have in my windows machine, why? and how do I connect/import it to the wsl?
How do I make the WSL database/server appears in my existing pgAdmin4 GUI? I have already a server for my windows machine (localhost, port 5432). How can I add database from the WSL server, since it has the same settings? For example, I tried creating new database via WSL psql command line CREATE DATABASE ubuntu;, and the new database appears in the WSL postgres list in terminal, but the pgAdmin GUI only shows database from my windows server. How do I sync both databases in windows and WSL and show them both in pgAdmin?
database list in windows (from pgAdmin4)
database list in WSL
Thanks for the help

Oracle XE Database Configuration failed

I am trying to create an oracle xe database in my vps.
VPS OS : Cent OS.
When try to run
/etc/init.d/oracle-xe configure
it throws an error Database confiration failed and to check the logs but logs just shows
ORA-01034: ORACLE not available
Below is the history...
[root#vmcx-43 Disk1]# rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing... ########################################### [100%]
/var/tmp/rpm-tmp.51363: line 186: bc: command not found
1:oracle-xe /var/tmp/rpm-tmp.51363: line 186: bc: command not fo und########################################### [100%]
Executing post-install steps...
/var/tmp/rpm-tmp.97984: line 76: bc: command not found
/var/tmp/rpm-tmp.97984: line 77: bc: command not found
/var/tmp/rpm-tmp.97984: line 78: [: -gt: unary operator expected
/var/tmp/rpm-tmp.97984: line 82: bc: command not found
You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
[root#vmcx-43 Disk1]# /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition. The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts. Press <Enter> to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:
Specify a port that will be used for the database listener [1521]:
Specify a password to be used for database accounts. Note that the same
password will be used for SYS and SYSTEM. Oracle recommends the use of
different passwords for each database account. This can be done after
initial configuration:
Password can't be null. Enter password:
Password can't be null. Enter password:
Confirm the password:
Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]: n
Starting Oracle Net Listener...Done
Configuring database...
Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details
[root#vmcx-43 Disk1]# cd /u01/app/oracle/product/11.2.0/xe/config/log
[root#vmcx-43 log]# ls
CloneRmanRestore.log cloneDBCreation.log postDBCreation.log postScripts.log
[root#vmcx-43 log]# tail postScripts.log
commit
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
[root#vmcx-43 log]# tail CloneRmanRestore.log
select TO_CHAR(systimestamp,'YYYYMMDD HH:MI:SS') from dual
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0
Add your servers name and IP to the /etc/hosts file
I had same issues.
I uninstalled oracle-xe. See How to reconfigure Oracle 10g xe on Linux
Then followed
yum install bc
rpm -i oracle-xe.rpm
/etc/init.d/oracle-xe configure
Everything went fine.
yum install bc
Then try again.
Ok the solution may sound weird but today i got the exactly same error while installing Oracle Xe on centos. I struggled a lot to find the answer but in the end the problem was the way i was installing the rpm.
Initailly i used the command
$rpm -ivh oracle-xe.rpm
and somehow it was giving the same error which you are getting.
After that i tried
$rpm -i oracle-xe.rpm
and it worked for me. Not very sure why will the "h" flag, which is the hash flag cause an issue but it worked for me.
for debian ... how to install oracle-XE from rpm
Configuring database...
Database Configuration failed. Look into /u01/app/oracle/product/11.2.0/xe/config/log for details
nano /u01/app/oracle/product/11.2.0/xe/config/scripts/init.ora
comment # memory_target=100663296
/etc/init.d/oracle-xe configure // will work
I too faced the similar issue on Linux Mint 17.3. Fortunately, I found the solution sooner. The issue is simply that your shared memory file is not where Oracle expects it to be i.e. /dev/shm but you'd be having it at /run/shm with /dev/shm linking to it.
So, to resolve this issue, before configuring the database, you must perform the below steps in order
$ sudo rm -rf /dev/shm
$ sudo mkdir /dev/shm
$ sudo mount -t tmpfs shmfs -o size=2048m /dev/shm
I have tested it, works perfect.
After googling 'oracle sucks' in frustration over the lack of logging from the installation I managed to resolve the issue that caused the configuration to fail on a docker container running the Hortonworks HDP 2.6 Sandbox:
Oracle XE requires 1 Gb of shared memory and fails otherwise (I didn't try 512 mb) according to https://blogs.oracle.com/oraclewebcentersuite/implement-oracle-database-xe-as-docker-containers.
vi /etc/fstab
change/add the line to:
tmpfs /dev/shm tmpfs defaults,size=1024m 0 0
Then reload the configuration by:
mount -a
Keep in mind that if you later restart the docker container you might have to do 'mount -a' once more as it starts with the default set on the container ~ 65 mb.
Normally the failed configuration will have succeeded in creating a listener and you will have to kill this before rerunning configuration.
ps -aux | grep tnslsnr
kill {process identified in the step above}
Lost a full day to this one as none of the other answers on this page worked for me (Ubuntu).
Proper instructions where here
The main trick missing from other tutorials was to execute
sed -i 's,/var/lock/subsys,/var/lock,' /etc/init.d/oracle-xe
before
/etc/init.d/oracle-xe configure
check the permissions for: /u01/
In my case these were set to root:root I changed this to oracle:dba and it worked for me.
But before that I tried the following:
Setting up the IP/hostname in the /etc/hosts
installing bc and reinstalling oracle
both the steps did not work for me but I uninstalled and reinstalled oracle-xe, changed permissions and then ran the command for configure.

installing postgres 9.2 on Mac OSX 10.6 with KyngChaos package

I'm trying to install postgres 9.2 on a mac 10.6 using using KyngChaos (because ultimately I'd like to enable PostGIS, and this seems to be the best package to that with).
I get exactly the problem spelled out at the bottom of the page: http://www.kyngchaos.com/software/postgres
--
NOTE: I've had reports of the installer not initializing the data cluster, which results in Postgres not starting. It seems to be random, and I haven't figured out the cause yet. If Postgres won't start (you get an error "could not connect to server: No such file or directory" when trying to connect with psql), try manually initializing the cluster with:
/usr/local/pgsql-9.1/bin/initdb -U postgres \
-D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
Or see the Locales and Encodings readme if you need a different locale or encoding.
Then stop and start Postgres as specified in the readme.
--
I run
/usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
which opens up a new line to enter additional commands with
>
but i'm lost there, even after combing the readme.

PostgreSQL 8.2 unsupported version (1.11) in file header message to do backup restore

I'm trying to restore a backup in postgreSQL pgAdmin and I get the following error message:
C:\Program Files\PostgreSQL\8.2\bin\pg_restore.exe -i -h localhost -p 5432 -U postgres -d gsan_comercial -v "C:\Users\usr\Desktop\GSAN\Data Base\gsan_comercial_pmss.backup"
pg_restore: [archiver] unsupported version (1.11) in file header
Process returned exit code 1.
I can not find the reason for this.
Tks
The version you find in the dump file header is related to the version of the tools used to do the dump, i.e., pg_dump. It is possible to dump an 8.2 database using pg_dump from a later version (for example one from the 8.4 distribution) because all tools are backward compatible but in the end you'll get a file that can only be restored using the new tools.
I suppose that is what happened and you're now trying to restore an 8.2 dump done using 8.4 tools on a pgAdmin using 8.2 tools.

PostgreSQL installation as a user on Cygwin

I'm trying to install PostgreSQL on Cygwin as a user following the instructions given in the cygwin package installation:
cygrunsrv -S cygserver
initdb -D /usr/share/postgresql/data
pg_ctl start -D /usr/share/postgresql/data -l /var/log/postgresql.log
createdb
psql
After I do the third step, I get the following output in the terminal,
$ postgres -D /usr/share/postgresql/data
LOG: database system was shut down at 2013-04-12 19:04:33 PDT
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
After that, I'm unsure on what to do since I never see the command line again(the "$" sign). I'm a complete beginner when it comes to databases, so are there any 'for dummies' pointers for me?
Use pg_ctl -D /usr/share/postgresql/data -l /path/to/write/log/to start if you want the server to start up and background its self.
I strongly recommend reading the PostgreSQL tutorial and manual, which cover this in detail.

Resources