start postgres as service on windows - windows

I am working on windows server and I want to start postgreSQL as service by the following command but it does not work. Could you tell me what is wrong ?
sc create postgresql binPath="C:\Program Files\PostgreSQL\13\bin\pg_ctl.exe" runservice -w -N "P4" -D "C:\Program Files\PostgreSQL\13\data" - start auto
UPDATE
I succedeed to create the service by running the command
pg_ctl.exe register -N PostgreSQL -D "%ProgramData%/db_data" –S auto
but when i tried to start it I have the following error message
The PostgreSQL service on local computer started and then stopped some services stop automatically if they are not in use by other services or programs
UPDATE2
One of my colleague resolved the issue. It was a per'ission issue. I hadn't the permission to start the service. The discussion is closed

Related

PostgreSQL "Database cluster initialisation failed"

I got the error in question on my Windows11 for Postgres-V-12.
The followed the below steps suggested by ASL:
initdb -D "D:\PostgreSql\12\data" -U postgres
pg_ctl start -D "D:\PostgreSql\12\data"
Now after the last step I am getting an error message;
It says:
waiting for server to start....
postgres: could not find the database system
Expected to find it in the directory "D:/postgresqldata", but could not open file "D:/postgresqldata/global/pg_control": No such file or directory
stopped waiting
pg_ctl: could not start server.
Can someone please help me to resolve this issue?
Please check the service postgresql status in windows services.
Ensure it is running.

Cassandra server is getting restarted when using stop-server -p ../pid.txt -f command on windows 2016

Cassandra server is getting restarted when using stop-server -p ../pid.txt -f command on windows 2016
The cassandra process gets killed initially with the process id present in the pid.txt file, but process with new id gets created.
In Services, check the properties of the cassandra service - you might have auto-restart enabled. Look at the recovery tab and set no action on first / second failure.

Screen freezes on connecting to mongodb in Windows 10

I was trying to set up mongo server on Windows 10.
It looked like everything alright and the service was listening on 27017.
However on another command prompt, mongo failed to connect and the screen just froze as follow
I've checked the firewall rule, port 27017 is open. And ping 127.0.0.1 is responding.
Any idea why the connection would get stuck?
Try running mongo.exe with verbose mode
c:\mongodb\bin>mongo.exe --verbose
This will help you diagnose this further.
I have just got this situation.
Solution: Edit mongo configuration
mongodb.conf
linux: sudo nano /etc/mongodb.conf
and disable auth=true. Then restart mongo server service.
linux: sudo service mongodb restart
Incorrect config authentication steps lead to this hanging in mongo shell.
After that, config following this link: https://medium.com/#matteocontrini/how-to-setup-auth-in-mongodb-3-0-properly-86b60aeef7e8
Then re-enable auth=true

PostgreSQL pg_ctl register error under Windows 7

Under Windows 7, PostgreSQL 9.3.2, I'm trying to register as a service a second instance of PostgreSQL on the same server, using a different port number and data directory. The 2nd cluster was successfully created with the initdb command, under C:\Program Files\PostgreSQL\9.3\data2.
When I run the following pg_ctl register command from C:\Program Files\PostgreSQL\9.3\bin, I get an error message:
pg_ctl register -N postgresql9.2_2nd_cluster -U "NT AUTHORITY\NetworkService" -D "C:\Program Files\PostgreSQL\9.3\data2" -S auto -o "-p 5431"
pg_ctl: could not open service manager
I googled this, but without much success.
This error:
pg_ctl: could not open service manager
would suggest that you're probably on a UAC-enabled machine, and you're running in a non-admin console.
When you launch your console from Start->Command Prompt, right click on it and choose "Run as Administrator".
Open Command Prompt as admin
Open services (win+R -> services.msc)
If u can see PostgreSQL, then unregister it.
To Unregister the PostgreSQL,
pg-ctl unregister [-N SERVICENAME]
**%path%\PostgreSQL\12\bin\pg_ctl unregister -N "service_name"**
*service name will be displayed on services

How to setup "svnserve --service" to run on Windows?

When starting from cmdline
svnserve.exe -d -r d:\svn\mytools
all working fine.
Then I had tried to set it up to run as Windows service:
#echo off
set SvnHome=C:\Program Files\TortoiseSVN
set SvnRepository=D:\Svn\mytools
sc delete SvnMyTools
sc create SvnMyTools binPath= "%SvnHome%\bin\svnserve.exe --service -r %SvnRepository%" start= delayed-auto type= share
service was installed but it is unable to start.
All the time it is reporting an error
Error 1083: The executable program that this service is configured to run in does not implement the service.
I have tried to edit service cmdline using regedit, so tried to add double quotes arround ref to exe, tried to change cmdline parameters (used -d instead of --service, used both -d and --service) and so on. Sometimes reported errors are looks a bit different but it does not work anyway. :-(
Question is - how to setup it to make it working as service on Windows 7 x64?
Is it possible at all? I mean - if that "--service" cmdline switch is able to work in svnserve?
Note: svnserve version is 1.7.9 (r1462340).
Rest of TortoiseSVN components are 1.7.12.24070.
Thanks in advance.
It took me a while to figure out that the selected answer was not final, but a supplement to the question. This is the final one line command to execute:
sc create svnserve binpath="\"C:\Program Files\TortoiseSVN\bin\svnserve.exe\" --service -r D:\Repositories" displayname="Subversion Server" depend=Tcpip start=auto
Looks fine to me. My server is installed with this binary path:
"C:\Program Files\Subversion\svnserve.exe" --service -r "D:\Repositories" --listen-port "3690"
Did you try to install it outside of a script?
I realize this is an old question, but in case you need to do this on a more current Windows OS version...
On Windows Server 2012 with CollabNet subversion Edge SVN v5.2.4, this syntax worked in an elevated cmd window (NOTE the space after the = character and where the quote " characters are located):
sc create svnserve binpath="E:\csvn\bin\svnserve.exe --service -r E:\csvn\data\repositories --listen-port 3690 --log-file E:\csvn\data\logs\svnserve.log" displayname="SVN Serve" depend= Tcpip start= auto
After creating the svnserve Windows service, to add a description :
sc description svnserve "SVN Server providing the svn:// or svn+ssh:// protocol scheme"
Screenshot of Services.msc showing the newly created svnserve service:
Reference: http://svnbook.red-bean.com/en/1.7/svn.serverconfig.svnserve.html

Resources