I am running the latest version of macOS Sierra and I installed PostgreSQL via brew. Then I ran the command:
pg_ctl -D /Users/tmo/PSQL-data -l logfile start
but received for output:
waiting for server to start..../bin/sh: logfile: Permission denied
stopped waiting
pg_ctl: could not start server
Examine the log output.
EDIT: After restarting my operating system and rerunning the command... I'm now receiving a slightly modified output... but the modification is significant.
waiting for server to start.... stopped waiting
pg_ctl: could not start server
Examine the log output.
Where is the "log output" stored?
How do I make this command work?
The problem could be one of two things, that I can see:
A typo in your database path:
/Users/tmo/PSQL-data --> /Users/tmp/PSQL-data
If the above was just a transcription error, I would guess that your postgres user doesn't have write access to the directory where you are setting the logfile. The argument following the -l switch tells PG where to save the logfile. When you don't provide the -l switch with a path, but just a filename, it will use the same dir you use to specify the database cluster (with the -D flag). So in this case, PG is trying to write to /Users/tmp/PSQL-data/logfile, and getting a permission error.
To fix this, I would try:
If the directory /Users/tmp/PSQL-data/ doesn't exist:
sudo mkdir /Users/tmp/PSQL-data
Then create the logfile manually:
sudo touch /Users/tmp/PSQL-data/logfile
Then make the postgres user own the file (I'm assuming user is postgres here)
sudo chown postgres /Users/tmp/PSQL-data/logfile
Try again, and hopefully you can launch the server.
Caveat: I'm not a macOS user, so I'm not sure how the /tmp folder behaves. If it is periodically cleared, you may want to specify a different logfile location, so that you don't need to create and chown the file each time you need to launch the cluster.
Related
I have the following commands on MacOS
$ sl
slapacl slapadd slapauth slapcat slapconfig slapdn
slapindex slappasswd slapschema slaptest sleep slogin
I am following this tutorial on running an ldap server on MacOS:
http://krypted.com/mac-security/starting-openldap-on-mac-os-x-client/
seems strange that I don't have a slapd command - anyone know why?
Since slapd is almost never run "by hand", it's not in one of the binaries directories that're in the default PATH. Instead, it's in /usr/libexec, which is the usual place for things that're run automatically rather than manually. So run it with sudo /usr/libexec/slapd instead of just as slapd. (BTW, the sudo is needed so it can allocate low-numbererd TCP ports, and get full access to its database).
Hello everyone all help is much appreciated. Using MongoDB for the first time, I usually use postgresql. Cannot get any database action, including generating models. Continually get this error:
Mongo::ConnectionFailure: Failed to connect to a master node at localhost:27017
The internet says to try these, none of which work:
1-
sudo rm /var/lib/mongodb/mongod.lock
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo start mongodb
sudo status mongodb
This returns the error that
rm: /var/lib/mongodb/mongod.lock: No such file or directory
2- This is in a file I put in the initialize folder
require 'rubygems'
require 'mongo'
db = Mongo::Connection.new.db("mydb")
db = Mongo::Connection.new("localhost").db("mydb")
db = Mongo::Connection.new("localhost", 27017).db("mydb")
The problem seems to stem from a path, which I have no idea how it works or how to alter it, so if the advice is to alter paths and folders etc. please be very specific. Thank you guys so much.
The mongo daemon has not successfully started.
Usually you do
sudo mongod
Make sure you can connect to the database by typing mongo on the command line which should connect you to the daemon running on 27017.
Then try running your ruby code again.
I entered ssh-host-config into the cygwin prompt (started with admin privileges), said yes to privilege separation, new local account sshd, install sshd as a service; I entered no value for CYGWIN for daemon; I entered no for using a different name; yes for creating new privilege user account.
In my services.msc I am unable to start the service:
The CYGWIN sshd service on Local Computer started and then stopped.
Some services stop automatically if they are not in use by other services
or programs.
In the cygwin prompt, net start sshd produces:
The CYGWIN sshd service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534
In the cygwin prompt, cygrunsrv -S sshd produces:
cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
The service has not been started.
My /var/log/sshd.log says the following:
Unable to initialize device PRN
I've searched the questions on SO related to this issue, as well as the general Internet, and I guess what makes my question unique has to do with the sshd.log. I can't find anyone else who has received this.
I'm doing this to install Hadoop on my Windows. I cannot run a virtual machine on this slow computer as everything just bogs down.
I followed the steps in this topic and the problem was still happening, then I checked the sshd log file and it was complaining that the privilegies of the ssh private key were to open.
I executed the follow command:
chmod 400 /etc/ssh_host_ecdsa_key
Then I run the service:
net start sshd
It finally worked (BTW: I am using Windows 8)
I had the same problem and here is the solution that worked for me.
Solution 1
Restart the machine after you set the path environment variables to point to Cygwin bin directories and then start the service.
Solution 2
First add the account that runs the Cygwin sshd demon service to administrators group (this is by default)
Go to your cygwin installation folder (mine is at c:\cygwin64 and yours may differ)
add administrators group as full control. remove the property
Remove Readonly for your cygwin installation folder so anyone can write into it
Run the cygwin terminal as administrator and remove the service by typing
cygrunsrv -R sshd
Reboot your system
Run the cygwin terminal as administrator and reinstall the service again by typing
ssh-host-config -y
Run the cygwin terminal as administrator and start the service by typing
net start sshd
Your service now be running!
I tried above solutions but nothing worked for me.
I am using Windows 8 and was able to solve it.
My sshd.log file says : "Privilege separation user sshd does not exist FAILED"
So to remove this error while starting sshd as service just following below steps:
Edit the file /etc/passwd --
add " sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin ".
Edit the file /etc/group --
add " sshd:x:74: ".
Now start service as
net start sshd
It worked for me!
Followed the steps provide by Andrea Solution 1 and solution 2 , it did not work. Event viewer did not provide any info.
So took a look at the log var/log/sshd.log first it complained that it was unable to load the dll:
/usr/sbin/sshd.exe: error while loading shared libraries: cygcrypto-1.0.0.dll
Solution:
Reinstalled the package and ensured that the dll were in lib.
Started the service again still it failed but this time it complained about missing host key.
Could not load host key: /etc/ssh_host_dsa_key
Could not load host key: /etc/ssh_host_ecdsa_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.
Solution:
go to the Cygwin Command prompt (with run as admin ) and
enter ssh-keygen -A
the missing host key were generated .
Finally I was able to start it.
I would recommend looking at the log file further if the above solution does not work.
In my case (using a Polish version of Windows 8) I had to manually modify the /etc/passwd and /etc/group files.
Some lines for Administrator, Administrators, Guest, Guests, etc. had been missing, so I merely inserted them, and copied all other fields from their non-English versions. Eg.
nano /etc/passwd
SYSTEM:*:18:544:,S-1-5-18::
LocalService:*:19:544:U-NT AUTHORITY\LocalService,S-1-5-19::
NetworkService:*:20:544:U-NT AUTHORITY\NetworkService,S-1-5-20::
Administrators:*:544:544:,S-1-5-32-544::
Administratorzy:*:544:544:,S-1-5-32-544::
TrustedInstaller:*:4294967294:4294967294:U-NT SERVICE\TrustedInstaller,S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464::
Administrator:unused:500:513:U-gordito\Administrator,S-1-5-21-580982140-4090956935-1935414389-500:/home/Administrator:/bin/bash
Guest:unused:501:513:U-gordito\Gość,S-1-5-21-580982140-4090956935-1935414389-501:/home/Gość:/bin/bash
Gość:unused:501:513:U-gordito\Gość,S-1-5-21-580982140-4090956935-1935414389-501:/home/Gość:/bin/bash
HomeGroupUser$:unused:1004:513:HomeGroupUser$,U-gordito\HomeGroupUser$,S-1-5-21-580982140-4090956935-1935414389-1004:/home/HomeGroupUser$:/bin/bash
sshd:unused:1006:513:sshd privsep,U-gordito\sshd,S-1-5-21-580982140-4090956935-1935414389-1006:/var/empty:/bin/false
cyg_server:unused:1007:513:Privileged server,U-gordito\cyg_server,S-1-5-21-580982140-4090956935-1935414389-1007:/var/empty:/bin/false
nano /etc/group
root:S-1-5-32-544:0:
SYSTEM:S-1-5-18:18:
TrustedInstaller:S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464:4294967294:
Administrators:S-1-5-32-544:544:
Administratorzy:S-1-5-32-544:544:
Czytelnicy dzienników zdarzeń:S-1-5-32-573:573:
Guests:S-1-5-32-546:546:
Goście:S-1-5-32-546:546:
IIS_IUSRS:S-1-5-32-568:568:
Users:S-1-5-32-545:545:
Users DCOM:S-1-5-32-562:562:
Użytkownicy:S-1-5-32-545:545:
Użytkownicy DCOM:S-1-5-32-562:562:
Użytkownicy dzienników wydajności:S-1-5-32-559:559:
Użytkownicy monitora wydajności:S-1-5-32-558:558:
Użytkownicy zarządzania zdalnego:S-1-5-32-580:580:
HomeUsers:S-1-5-21-580982140-4090956935-1935414389-1003:1003:
TelnetClients:S-1-5-21-580982140-4090956935-1935414389-1005:1005:
WinRMRemoteWMIUsers__:S-1-5-21-580982140-4090956935-1935414389-1000:1000:
None:S-1-5-21-580982140-4090956935-1935414389-513:513:
Brak:S-1-5-21-580982140-4090956935-1935414389-513:513:
Only after this, I was finally able to chmod g-rwx all the files that offended sshd, in a way that 'ls -la' indeed confirmed the dropped permissions for group and other.
Then finally, privileged CYGWIN services installed and started (sshd, cron)
I tried to install mongoDB on my macbook air.
I've downloaded zipped file from official website and extract that file and move to root directory.
After that, under that directory, I've made /data/db and /log folder.
Here is my mongodb.config which describes the basic config for my DB.
dbpath = /mongodb/data/db
logpath = /mongodb/log/mongo.log
logappend = true
#bind ip = 127.0.0.1
port = 27017
fork = true
rest = true
verbose = true
#auth = true
#noauth = true
Additionally, I want to know what the # means in the config file.
I put this file to /mongodb/bin, /mongodb is the directory I extracted the files into.
I opened terminal and entered ./mongod --config mongodb.config and I got this back.
Juneyoung-ui-MacBook-Air:bin juneyoungoh$ ./mongod --config mongodb.config
about to fork child process, waiting until server is ready for connections.
forked process: 1775
all output going to: /mongodb/log/mongo.log
ERROR: child process failed, exited with error number 100
How can I handle this error and what this means?
The data folders you created were very likely created with sudo, yes? They are owned by root and are not writable by your normal user. If you are the only user of your macbook, then change the ownership of the directories to you:
sudo chown juneyoungoh /data
sudo chown juneyoungoh /data/db
sudo chown juneyoungoh /data/log
If you plan on installing this on a public machine or somewhere legit, then read more about mongo security practices elsewhere. I'll just get you running on your macbook.
I had a similar issue and it was not related to any 'sudo' problem. I was trying to recover from a kernel panic!
When I look at my data folder I found out a mongod.lock file was there. In my case this page helped a lot: http://docs.mongodb.org/manual/tutorial/recover-data-following-unexpected-shutdown/. As they explain,
if the mongod.lock is not a zero-byte file, then mongod will refuse to start.
I tested this solution in my environment and it works perfectly:
Remove mongod.lock file.
Repair the database: mongod --dbpath /your/db/path --repair
Run mongod: mongod --dbpath /your/db/path
There was the same problem on my machine. In the log file was:
Mon Jul 29 09:57:13.689 [initandlisten] ERROR: Insufficient free space for journal file
Mon Jul 29 09:57:13.689 [initandlisten] Please make at least 3379MB available in /var/mongoexp/rs2/journal or use --smallfiles
It was solved by using mongod --smallfiles. Or if you start mongod with --config option than in a configuration file disable write-ahead journaling by nojournal=true (remove the beginning #). Some more disk space would also solve the above problem.
It's because you probably didn't shutdown mongodb properly and you are not starting mongodb the right way. According your mongodb.config, you have dbpath = /mongodb/data/db - so I assume you created the repository /mongodb/data/db? Let me clarify all the steps.
TO START MONGODB
In your mongodb.config change the dbpath = /mongodb/data/db to dbpath = /data/db. On your terminal create the db repository by typing: mkdir /data/db. Now you have a repository - you can start your mongo.
To start mongo in the background type: mongod --dbpath /data/db --fork --logpath /dev/null.
/data/db is the location of the db.
--fork means you want to start mongo in the background - deamon.
--logpath /dev/null means you don't want to log - you can change that by replacing /dev/null to a path like /var/log/mongo.log
TO SHUTDOWN MONGODB
Connect to your mongo by typing: mongo and then use admin and db.shutdownServer(). Like explain in mongoDB
If this technique doesn't work for some reason you can always kill the process.
Find the mongodb process PID by typing: lsof -i:27017 assuming your mongodb is running on port 27017
Type kill <PID>, replace <PID> by the value you found the previous command.
Similar issue with the same error - I was trying to run the repair script
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
Checked ps aux | grep mongo and see that the daemon was running. Stopped it and then the repair script run without an issue.
Hope that could be helpful for someone else.
I had the same error on linux (Centos) and this worked for me
Remove mongod.lock from the dbpath
$ rm /var/lib/mongo/mongod.lock
Repair the mongod process
$ mongod --repair
Run mongod config
$ mongod --config /etc/mongod.conf
I had the same error. I ran it interactively to see the log.
2014-10-21T10:12:35.418-0400 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
Then I used lsof to find out which process was using my port.
$ lsof -i:27017
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mongod 2106 MYUSERID 10u IPv4 0x635b71ec3b65b4a1 0t0 TCP *:27017 (LISTEN)
It was a mongod that I had forked previously and forgot to turn off (since I hadn't seen it running in my bash window).
Simply killing it by running kill 2106, enabled my process to run without the error 100.
Generally, this error comes when the mongod.conf file is not able to
find a certain path for
Database store
or log store
or maybe processid store
or maybe it's not getting the file permission to access the config directories and files which has been declared in mongod.conf
to resolve this error we need to observe the log generated by the MongoDB
it will clearly indicate whether which file or directory you MongoDB is not able to access
the above error may look like below screenshot
create folder "data" and "db" inside it, in "/" path of your server.
actually you should create or modify permissions of folder that the data is going to be stored!
I followed the instructions for setting up postgresql from this site
All seems to go fine until I try:
createuser --superuser myname -U
postgres
I get the following exception:
createuser: could not connect to
database postgres: 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"?
For the life of me I can't figure out how to resolve this. Any ideas???
I had to remove the existing postgres user before doing the install.
Perhaps you moved your postgres data directory after you installed postgres using macports
Find where your launchctl startup script is located.
ps -ef | grep postgres
Outputs
0 54 1 0 0:00.01 ?? 0:00.01 /opt/local/bin/daemondo --label=postgresql84-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper restart ; --pid=none
So I edit
sudo vim /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper
And find the line
Start() {
su postgres -c "${PGCTL} -D ${POSTGRESQL84DATA:=/opt/local/var/db/postgresql84/wrong_place} start -l /opt/local/var/log/postgresql84/postgres.log"
}
Ahh.. my data directory is in the wrong place. I fix it by changing
/opt/local/var/db/postgresql84/wrong_place
to
/opt/local/var/db/postgresql84/right_place
for both the start and stop command.
Did you install the postgresql84-server port? If so, did you start the server:
$ sudo port load postgresql84-server
If you did both of those, I've noticed that sometimes the MacPorts daemon handler (daemondo) doesn't start handling requests for PostgreSQL until you restart your machine. (This only happens the first time it is started; subsequent attempts should work fine.)