Restart PostgreSQL Remotely - postgresql

Can I remotely restart a PostgreSQL server throught PGAdmin ? The user I currently is the administrative privileges.
Regards,
Dino

I don't think there is such possibility. At best you can reload connected PostgreSQL server using pg_reload_conf() function:
pg_reload_conf sends a SIGHUP signal
to the server, causing configuration
files to be reloaded by all server
processes.
Command:
SELECT pg_reload_conf();
You can also install adminpack contrib module and reload server using Tools menu.
EDIT:
According to pgAdmin documentation:
If pgAdmin is running on a Windows
machine, it can control the postmaster
service if you have enough access
rights. Enter the name of the service.
In case of a remote server, it must be
prepended by the machine name (e.g.
PSE1\pgsql-8.0). pgAdmin will
automatically discover services
running on your local machine.
If pgAdmin is running on a Unix
machine, it can control processes
running on the local machine if you
have enough access rights. Enter a
full path and needed options to access
the pg_ctl program. When executing
service control functions, pgAdmin
will append status/start/stop keywords
to this. Example: sudo
/usr/local/pgsql/bin/pg_ctl -D
/data/pgsql
You can try use Start Service/Stop Service options (in Tools menu) to restart remote server.

Related

docker and elevated priv

Is it possible to run docker without elevated priv ex. (docker version).
Im trying to run a command on another machine (windows server with docker as service) with powershell invoke command but it seems as long as the docker insists on elevated priv i cannot.
So if i can get "docker verison" to work im all set.
The error i get is
docker.exe: error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.39/containers/create: open //./pipe/docker_engine: Access is denied. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
See 'C:\Program Files\Docker\docker.exe run --help
it works with an elevated powershell.
Any ideas?
This is normal - by default, a local named pipe is used for the Docker CLI to communicate with the service (aka daemon).
For development use you can configure the host machine's Docker service ("daemon") for TCP access but this is the least secure option. Just put this text in file daemon.json:
{
"hosts": ["tcp://0.0.0.0:2375"]
}
Once this is done you can connect with e.g.
docker --host tcp://1.2.3.4:2375 version
If this is for production use, you probably need to look at a container orchestration system.
A middle ground would be to useAttach-PSSession to attach to an admin PowerShell session on the remote machine. This still requires a privileged user but does work remotely.

Cannot Add PgAdmin New Connection on Ubuntu 15.10

After install pgAdmin III from Ubuntu Software Center, I opened it and it required to add a connection to a server. So I filled in information as below:
Upon clicking on Ok Button, it showed the error message
Error connecting to the server: could not translate host name
"http://127.0.0.1" to address: Name or service not known
As message indicated, I thought the postgres service was not started. Therefore, I went on go terminal console and start service by entering sudo service postgresql start, but it returned Failed to start postgresql.service: Unit postgresql.service failed to load: No such file or directory.
. What's wrong or missing for my pgAdmin III? I'm just using Ubuntu earlier and I have never this problem on windows. Thanks.
http://127.0.0.1 is more a URL, that field is looking for a host so simply remove the http:// to leave the localhost's IP address 127.0.0.1 or type localhost if that resolves to the correct address (it should, usually, via /etc/hosts or the like)
Also, Debian/Ubuntu tend to ship the database servers separately. For Ubuntu, the postgresql package (which requires postgresql-common) package should include /lib/systemd/system/postgresql.service therefore you should be able to sudo systemctl start postgresql
Do you have postgresql (as opposed to postgresql-client) installed?

Access guest from virsh

I am running Centos 7 x86-64. I installed a guest (again Centos 7) through kickstart as an exercise. I prepared my kickstart file, I validated it and I launched with virt-install.
If something went wrong with the network configuration (During install I got no problem, I created a local repo on Host FTP server as source for the install) how can I connect to the machine?
Only SSH or virsh foresee some other connection method?
How can I find my machine running network configuration from outside?
I am running a barebone Centos7 installation so only command line, no graphical interface at all.
Thanks,
M.
You can ssh to your physical host from another one having graphical interface with X forwarding enabled (ssh -X machinename), and look at the the VM with virt-manager
You will need X running on the machine you're connecting from. For Mac OS it's XQuartz

How to run postgres on centos when installed via YUM repo as default daemon user

With a freshly installed version of Postgres 9.2 via yum repository on Centos 6, how do you run postgres as a different user when it is configured to run as 'postgres:postgres' (u:g) out of the box?
In addition to AndrewPK's explanation, I'd like to note that you can also start new PostgreSQL instances as any user by stopping and disabling the system Pg service, then using:
initdb -D /path/to/data/directory
pg_ctl start -D /path/to/data/directory
This won't auto-start the server on boot, though. For that you must integrate into your init system. On CentOS 6 a simple System V-style init script in /etc/init.d/ and a suitable symlink into /etc/rc3.d/ or /etc/rc3.d/ (depending on default runlevel) is sufficient.
If running more than one instance at a time they must be on different ports. Change the port directive in postgresql.conf in the datadir or set it on startup with pg_ctl -o "-p 5433" .... You may also need to override the unix_socket_directories if your user doesn't have write permission to the default socket directory.
pg_ctl
initdb
This is only for a fresh installation (as it pertained to my situation) as it involves blowing away the data dir.
The steps I took to resolve this issue while utilizing the packaged startup scripts for a fresh installation:
Remove the postgres data dir /var/lib/pgsql/9.2/data if you've already gone through the initdb process with the postgres user:group configured as default.
Modify the startup script (/etc/init.d/postgresql-9.2) to replace all instances of postgres:postgres with NEWUSER:NEWGROUP.
Modify the startup script to replace all instances of postgres in any $SU -l postgres lines with the NEWUSER.
run /etc/init.d/postgres initdb to regenerate the cluster using the new username
Make sure any logs created are owned by the new user or remove old logs if error on initdb (the configuration file in my case was found in /var/lib/pgsql/9.2/data/postgresql.conf).
Startup postgres and it should now be running under the new user/group.
I understand this might not be what other people are looking for if they have existing postgres db's and want to restart the server to run as a different user/group combo - this was not my case, and I didn't see an answer posted anywhere for a 'fresh' install utilizing the pre-packaged startup scripts.

How to connect eclipse from local to server

I have a eclipse on windows 7 system and I am trying some code on it.
But as my database is on server that is not my local systems so how can I connect eclipse to remote server so that I can write code on local and run on server.
Is it possible then please let me know and that server to which I want to connect that is Linux server.
Do you have to run your program remotely just because your database resides on the other server? Most databases allow connecting over TCP/IP.
Otherwise my suggestion is to add you public ssh key on the server, and then create a script which copies your class files and then executes your java program on your server, such as:
scp -r classfolder remoteuser#remotesystem:folderpath
ssh remoteuser#remotesystem java -cp folderpath the.created.Program
The public key removes the need for you to enter your password for each command.