install mongoDB (child process failed, exited with error number 100) - macos

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!

Related

Error with starting PostgreSQL database on macOS

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.

Elasticsearch, Failed to obtain node lock, is the following location writable

Elasticsearch won't start using ./bin/elasticsearch.
It raises the following exception:
- ElasticsearchIllegalStateException[Failed to obtain node lock, is the following location writable?: [/home/user1/elasticsearch-1.4.4/data/elasticsearch]
I checked the permissions on the same location and the location has 777 permissions on it and is owned by user1.
ls -al /home/user1/elasticsearch-1.4.4/data/elasticsearch
drwxrwxrwx 3 user1 wheel 4096 Mar 8 13:24 .
drwxrwxrwx 3 user1 wheel 4096 Mar 8 13:00 ..
drwxrwxrwx 52 user1 wheel 4096 Mar 8 13:51 nodes
What is the problem?
Trying to run elasticsearch 1.4.4 on linux without root access.
I had an orphaned Java process related to Elasticsearch. Killing it solved the lock issue.
ps aux | grep 'java'
kill -9 <PID>
I got this same error message, but things were mounted fine and the permissions were all correctly assigned.
Turns out that I had an 'orphaned' elasticsearch process that was not being killed by the normal stop command.
I had to manually kill the process and then restarting elasticsearch worked again.
the reason is another instance is running!
first find the id of running elastic.
ps aux | grep 'elastic'
then kill using kill -9 <PID_OF_RUNNING_ELASTIC>.
There were some answers to remove node.lock file but that didn't help since the running instance will make it again!
In my situation I had wrong permissions on the ES dir folder. Setting correct owner solved it.
# change owner
chown -R elasticsearch:elasticsearch /data/elasticsearch/
# to validate
ls /data/elasticsearch/ -la
# prints
# drwxr-xr-x 2 elasticsearch elasticsearch 4096 Apr 30 14:54 CLUSTER_NAME
After I upgraded the elasticsearch docker-image from version 5.6.x to 6.3.y the container would not start anymore because of the aforementioned error
Failed to obtain node lock
In my case the root-cause of the error was missing file-permissions
The data-folder used by elasticsearch was mounted from the host-system into the container (declared in the docker-compose.yml):
volumes:
- /var/docker_folders/common/experimental-upgrade:/usr/share/elasticsearch/data
This folder could not be accessed anymore by elasticsearch for reasons I did not understand at all. After I set very permissive file-permissions to this folder and all sub-folders the container did start again.
I do not want to reproduce the command to set those very permissive access-rights on the mounted docker-folder, because it is most likely a very bad practice and a security-issue. I just wanted to share the fact that it might not be a second process of elasticsearch running, but actually just missing access-rights to the mounted folder.
Maybe someone could elaborate on the apropriate rights to set for a mounted-folder in a docker-container?
As with many others here replying, this was caused by wrong permissions on the directory (not owned by the elasticsearch user). In our case it was caused by uninstalling Elasticsearch and reinstalling it (via yum, using the official repositories).
As of this moment, the repos do not delete the nodes directory when they are uninstalled, but they do delete the elasticsearch user/group that owns it. So then when Elasticsearch is reinstalled, a new, different elasticsearch user/group is created, leaving the old nodes directory still present, but owned by the old UID/GID. This then conflicts and causes the error.
A recursive chown as mentioned by #oleksii is the solution.
You already have ES running. To prove that type:
curl 'localhost:9200/_cat/indices?v'
If you want to run another instance on the same box you can set node.max_local_storage_nodes in elasticsearch.yml to a value larger than 1.
Try the following:
1. find the port 9200, e.g.: lsof -i:9200
This will show you which processes use the port 9200.
2. kill the pid(s), e.g. repeat kill -9 pid for each PID that the output of lsof showed in step 1
3. restart elasticsearch, e.g. elasticsearch
I had an another ElasticSearch running on the same machine.
Command to check : netstat -nlp | grep 9200 (9200 - Elastic Port)
Result : tcp 0 0 :::9210 :::* LISTEN 27462/java
Kill the process by,
kill -9 27462
27462 - PID of ElasticSearch instance
Start the elastic search and it may run now.
In my case, this error was caused by not mounting the devices used for the configured data directories using "sudo mount".
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
It directly shows it doesn't have permission to obtain a lock. So need to give permissions.
In my case the /var/lib/elasticsearch was the dir with missing permissions (CentOS 8):
error: java.io.IOException: failed to obtain lock on /var/lib/elasticsearch/nodes/0
To fix it, use:
chown -R elasticsearch:elasticsearch /var/lib/elasticsearch
To add to the above answers there could be some other scenarios in which you can get the error.In fact I had done a update from 5.5 to 6.3 for elasticsearch.I have been using the docker compose setup with named volumes for data directories.I had to do a docker volume prune to remove the stale ones.After doing that I was no longer facing the issue.
If anyone is seeing this being caused by:
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/docker/es]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
The solution is to set max_local_storage_nodes in your elasticsearch.yml
node.max_local_storage_nodes: 2
The docs say to set this to a number greater than one on your development machine
By default, Elasticsearch is configured to prevent more than one node from sharing the same data path. To allow for more than one node (e.g., on your development machine), use the setting node.max_local_storage_nodes and set this to a positive integer larger than one.
I think that Elasticsearch needs to have a second node available so that a new instance can start. This happens to me whenever I try to restart Elasticsearch inside my Docker container. If I relaunch my container then Elasticsearch will start properly the first time without this setting.
Mostly this error occurs when you kill the process abruptly. When you kill the process, node.lock file may not be cleared. you can manually remove the node.lock file and start the process again, it should work
For me the error was a simple one: I created a new data directory /mnt/elkdata and changed the ownership to the elastic user. I then copied the files and forgot to change the ownership afterwards again.
After doing that and restarting the elastic node it worked.
check these options
sudo chown 1000:1000 <directory you wish to mount>
# With docker
sudo chown 1000:1000 /data/elasticsearch/
OR
# With VM
sudo chown elasticsearch:elasticsearch /data/elasticsearch/
If you are on windows then try this:
Kill any java processes
If the start batch is interrupted in between then rather than closing the terminal, press ctrl+c to properly stop the elastic search service before you exit the terminal.

Mongodb: Failed to connect to 127.0.0.1:27017, reason: errno:10061

Here is my mongod.cfg file:
bind_ip = 127.0.0.1
dbpath = C:\mongodb\data\db
logpath = C:\mongodb\log\mongo-server.log
verbose=v
Here is my mongod service command:
mongod -f c:\mongodb\mongod.cfg --install
I have installed MongoDB about a week ago and it all worked fine, however today when I ran mongo command I got the following error:
Failed to connect to 127.0.0.1:27017,
reason: errno:10061 No connection could be made because the target machine actively refused it
How can I fix that? I use Windows 8.1
Solution:
I forgot to start mongodb service with this command:
net start mongodb
Improved solution:
1) Change directory to root drive C:\, and type the command below into an admin cmd prompt window,
C:\mongodb\bin\mongod.exe --config c:\mongodb\mongod.cfg --install
2) Then type net start MongoDB after which you should see the following message:
"The Mongo DB service was started successfully"
3) Then go to the control panel Start>Administrative Tools>Services, scroll down to MongoDB in the list of services and change start up type to automatic, if you so desire. Press OK.
4) Finally type C:\mongodb\bin\mongo.exe and you should be connected to the Mongo test DB.
Reference: https://www.youtube.com/watch?v=-mik4dPArCU
This is how I solved it, You can follow step by step here:
MongoDB Steps:
Download the latest 64-bit MSI version of MongoDB for Windows.
Run the installer (.msi file)
Add it to your PATH of environment variables. it Should be from:
C:\Program Files\MongoDB\Server\3.0\bin
now Create a “\data\db” folder in C:/ which is used by mongodb to store all data. You should have this folder:
C:\data\db
Note: This is the default directory location expected by mongoDB,
don’t create anywhere else
.
Finally, open command prompt and type:
>> mongod
You should see it asking for permissions (allow it) and then listen to a port.
After that is done, open another command prompt, leaving the previous one running the server.
Type in the new command prompt
>> mongo
You should see it display the version and connect to a test database.
This proves successful install!=)
Reference link
When you typed in the mongod command, did you also give it a path? This is usually the issue. You don't have to bother with the conf file. simply type
mongod --dbpath="put your path to where you want it to save the working area for your database here!! without these silly quotations marks I may also add!"
example: mongod --dbpath=C:/Users/kyles2/Desktop/DEV/mongodb/data
That is my path and don't forget if on windows to flip the slashes forward if you copied it from the or it won't work!
I was also faced the same issue with mongodb 2.6.
What solved my problem was I just run mongod --repair command
and then start mongod.exe
It's worked for me
just create a folder
C:\data\db
Run below commands in command prompt
C:\Program Files\MongoDB\Server\3.4\bin>mongod
Open another command prompt
C:\Program Files\MongoDB\Server\3.4\bin>mongo
mongodb 2.6.8 on windows7 32bits
you only need create a folder c:/data/db
execute mongod, and execute mongo
Point to your mongodb instalation e.g C:\Program Files\MongoDB\Serve\bin and run mongod.exe so you can open connection to 127.0.0.1:27017.
If it writes that you had not properly shut down or that mongod.lock is not empty
, only delete mongod.lock from C:\data\db\ and it will start.
The problem is that I missed out 'db' folder for the dbpath in the command:
C:\mongodb\bin> mongod --directoryperdb --dbpath C:\mongodb\data\db --logpath C:\mongodb\log\mongodb.log --logappend -rest --install
Under normal conditions, at least 3379 MB of disk space is needed. If you do not have that much space, to lower this requirement;
mongod.exe --smallfiles
This is not the only requirement. But this may be your problem.
What solved my issue was creating a file startmongo.conf that sets the bind_ip to 127.0.0.1 . After that, I just created a *.bat to start the mongo using something like:
mongod --config c:\mongodb\bin\startmongo.conf
When This Error is Coming it is lack of the following
1)Setting the path to mongo db
go to "C" Drive and the installation of Mongo db directory and then go to bin folder in the mongo and copy the path of it
c:/mongodb/server/3.2/bin/ and create a new environmental variable in system properties then name is path and value="c:/mongodb/server/3.2/bin/" here my version is 3.2
2)create a data directory for the data in C Drive
c:/Data/twitter
3)start the server with **
c:/> mongod
check your port config if there is any error as the local port may be assigned to any other
4)start your Mongo database with
Mongo
then your mongo db will start
then in your mongo database
create a database
use DATABASE_NAME
for example:
use twitterdata
switched to db twitterdata
to check your current database
db
twitterdata
to get total databases
show dbs
I started mongod in cmd,It threw error like C:\data\db\ not found.
Created folder then typed mongod
opened another cmd typed mongo it worked.
Here are the steps to solve this issue:
Just go to your MongoDB bin folder and run the mongod.exe file.
Navigate to your mongodb bin folder via Command prompt and start mongo by typing "mongo"
Change file permission to 755 for the file:
/var/lib/mongodb/mongod.lock
first you run the command mongod and check weather the port 27017 has started or not if yes then hit the command mongo....and database will start.
The Port is not open. Thats why the machine refuses communication
Try this, it worked for me.
mongod --storageEngine=mmpav1

Mac OSX - mongod and mongo not working

I'm completely new to databases and am trying to set up mongodb.
I've followed all the steps but neither the mongod or mongo commands work.
This is the output from mongod:
ERROR: could not read from config file
That is followed by all the mongo options (-h, -f, -v, etc.)
This is the output from mongo:
MongoDB shell version: 2.4.6
connecting to: test
Fri Sep 6 22:55:35.889 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
Any help is appreciated!
Try starting mongod with --config option specified. Something like /path/to/mongod --config /path/to/mongodb.conf.
In your mongodb.config check the location to the mongodb log. You should find additional details about errors there. Possible problems are: db path does not exist or is not writable, after an unclean shutdown mongod.lock file still exists etc.

How to resolve this PostgreSQL error on OS 10.6 (Snow Leopard)

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.)

Resources