How to configure PostgreSQL server on MacOS 10.8.5? - macos

I'm trying to connect to my postgres server from command line :
$> psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
And I'm trying to run the server :
$>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.
Can anyone point out for me how can I configure my server so it works?

I've solved this problem. Actually Mac OS 10.8.5 has his own psql command. So it's a path issue. If you install postgres from MacPort, the system will always refer to the initial psql command.
I advice you to install postgres from brew as shown here.
You'll have also redefine your PATH environment variable and export it in your .profile file:
export PATH=/usr/local/bin:$PATH

Related

Alias for Start/Stop Postgres as root

I have installed Postgres on my M1 mac using a dmg file which I downloaded from their website. The homebrew installation was causing some issues, that's why I installed it this way.
Previously with homebrew I could start/stop postgres using brew services start/stop postgres. Currently I have to do this
sudo -u postgres pg_ctl -D /Library/PostgreSQL/14/data start/stop to start/stop the server. I tried to make things a bit easier by adding an alias to .zshrc file, but as I learned I can't just add a command to shell with sudo like that.
My question is there any way to add an alias to simplify the start/stop of postgres.
Use a function instead of an alias:
start_postgres() {sudo -u postgres pg_ctl -D /Library/PostgreSQL/14/data start}

Installing Glassfish, Wildfly using homebrew on Mac OSX

Trying to install Glassfish(Java EE App. Server) and Wildfly App Server using Homebrew .
http://macappstore.org/wildfly-as/
http://macappstore.org/glassfish/
used these above mentioned tutorials .
I got the following errors while trying to run them by typing just "glassfish" & "wildfly-as" respectively.
Output(Error):
-bash: glassfish: command not found
-bash: wildfly-as: command not found
Searched about it and I think it has something to do with $PATH. I don't understand $PATH Variable . Need help.
The issue is that there are two asadmin scripts. One at $GLASSFISH_HOME/bin and one at $GLASSFISH_HOME/glassfish/bin
Here are full instructions to get your domain up
brew update
brew install glassfish
you should see message, add that line to your .bash_profile
==> Caveats
You may want to add the following to your .bash_profile:
export GLASSFISH_HOME=/usr/local/opt/glassfish/libexec
Open a new terminal then, cd $GLASSFISH_HOME/glassfish/bin
./asadmin start-domain --verbose
Browse to http://localhost:8080 for welcome page and http://localhost:4848 for admin console
I actually installed Wildfly-Application Server using homebrew but could not find a way to run it.
https://tomylab.wordpress.com/2016/07/03/how-to-install-wildfly-on-mac/
This tutorial helped me .
And for glassfish, my installation was again successful using homebrew but was not able to run it . I did figure it out when I ran the following commands.
$ cd /usr/local/opt/glassfish/libexec/bin
$ ./asadmin
asadmin> start-domain
You need to understand about the PATH variable. It is an environment variable on Unix-like operating systems, specifying a set of directories in which executable programs are located. In general, each executing process, or user session, has its own PATH setting.
So, you need to add the glassfish home path to your actual path variable.
Now, as per your problem with running the Glassfish server; try this:
export GLASSFISH_HOME=/usr/local/opt/glassfish/libexec/
export PATH=$PATH:$GLASSFISH_HOME/bin
Add it to your bash profile, if you do not want to do this everytime.

Can not run docker command directly after installation on windows

I installed docker on windows 10 with DockerToolbox (1.11.2) executable. However, I can't evaluate my environment using docker-machine env default directly.
Instead, only when I use this command
C:\Program Files\Docker Toolbox\docker-machine.exe env default *
Can I evaluate the environment?
When I want to check help information, I also have to run
C:\Program Files\Docker Toolbox\docker.exe run --help
In their official tutorial: Install Docker for Windows, they mentioned that after installation, I could use docker,docker-machine,docker-compose directly.
In fact, I found this problem when I met this error:
C:\Program Files\Docker Toolbox\docker.exe: An error occurred trying
to connect: Post https://192.168.99.103:2376/v1.23/containers/create:
dial tcp 192.168.99.103:2376: connectex: A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host has
failed to respond..
And I solved it by restart my machine, and evaluate it again with the full path of the executable.
Some thing interesting is that docker-machine create -d virtualbox default worked for me while docker stop $(docker ps -a -q) failed.
I can just add those executable to environment variable on Windows.
But I want to what's happaning to that installation which caused this problem.
Screenshot of my installation console:
First, you don't have to use docker-machine env at all: you can simply ssh to your machine, and make your docker commands from there.
docker-machine ssh default
Second, try and use those commands from a regular CMD session (you don't need a bash).
As documented in docker-machine env:
$ docker-machine.exe env --shell cmd dev
set DOCKER_TLS_VERIFY=1
set DOCKER_HOST=tcp://192.168.99.101:2376
set DOCKER_CERT_PATH=C:\Users\captain\.docker\machine\machines\dev
set DOCKER_MACHINE_NAME=dev
# Run this command to configure your shell: copy and paste the above values into your command prompt
(Replace "dev" by the name of your machine, like "default" for instance)

I get this error while trying to launch the command ./runInstaller

I have this error while trying to launch the command ./runInstaller
Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
From Oracle help docs:
sudo yum install xorg-x11-utils -y
worked for me.
If you are executing this via Putty, then I suggest you have a look at Xming, this allows you to have a Putty remote ssh session, and forward your display to you Windows machine...
If you're executing this from a Linux server without a gui, you will either need to connect remotely with a pc with a GUI installed (Gnome, KDE, etc) or you'll need to install the Gui directly on the server.
Check if it's not already installed by using the command on the terminal
$ startx
Error is reproducible thus:
$ export DISPLAY=:0.0
$ ./runInstaller
ERROR: Unable to verify the graphical display setup. This application requires X display. Make sure that xdpyinfo exist under PATH variable.
Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
OP's X server was Hummingbird Exceed. Xming will work as well.
The actual solution depends on:
whether you are su'd to oracle from a different login account.
whether you are using X11 forwarding.
the actual port used by X11 forwarding, which could be 6010 or a different port.
If you logged in and then su'd to oracle, then copy ~/.Xauthority to the oracle account.
If you are using X11 forwarding and the forwarding port is 6010, then DISPLAY=localhost:10.0 is correct.
If you are not using X11 forwarding, and if port 6000 on your PC is reachable from the oracle server, then export DISPLAY=your.pc.ip.address:0.0 is correct.
Install xterm and use xterm to test X windows.
Be sure to install xdpyinfo.
For more details, please refer to my article X windows for Oracle DBAs

How to restart PostgreSQL server on MacOS?

I tried the following and it failed
bash-3.2$ pg_ctl restart
pg_ctl: no database directory specified and environment variable PGDATA unset
I am using Macbook Pro and dont remember the directory where my data is stored and so can't set PGDATA either, is there a way to restart Postgres at all without losing data?
Thank you
As you want to re-start Postgres I assume the server is already running.
Using the superuser account you can query the location of the data directory through SQL:
select name, setting
from pg_settings
where name = 'data_directory'
With that information you can supply the data directory to the pg_ctl command using the -D switch (see the manual for details)
If you used brew you could find the restart(start|stop) instructions by doing a brew info postgresql Some issues that happen stem from the fact I've seen the plist not load, on OS startup, for some reason. I always forgot what to do and this helped.
on my Postgres 9.2 brew recipe it had:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
One liner (with default postgresSql 9.6 install)
sudo su postgres -c "/Library/PostgreSQL/9.6/bin/pg_ctl restart -D /Library/PostgreSQL/9.6/data"
Full version
Get the pgdata folder (gave me /Library/PostgreSQL/9.6/data) (thanks #a_horse_with_no_name)
select name, setting from pg_settings where name = 'data_directory';
For me it returns '/Library/PostgreSQL/9.6/data'
Then
sudo su - postgres
./bin/pg_ctl restart -D /Library/PostgreSQL/9.6/data
Note: postgres' user home dir should be "/Library/PostgreSQL/9.6"

Resources