$ mongod --config /etc/mongod.conf
ERROR: could not read from config file
Allowed options:
General options:
-h [ --help ] show this usage information
--version show version information
When I run "mongo" command terminal becomes unresponsive:
$ mongo
MongoDB shell version: 2.4.5
connecting to: test
--- no response ----
Please note: I'm running MongoDB on MacOS X for the first time.
The default mongo.config file on installation did not have:
port = 27017
i updated the config file from http://docs.mongodb.org/manual/administration/configuration/
the running the mongo command in Terminal works fine:
mongo
did not fall into an infinite loop instead the mongodb prompt > was activated.
MongoDB shell version: 2.4.5
connecting to: test
Server has startup warnings:
Fri Jul 12 02:17:19.667 [initandlisten]
Fri Jul 12 02:17:19.667 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
If you have installed on a previous mongodb installation in linux you shoud check for the path
/etc/mongod.conf
if mongod.conf is present with some other name change it to mongod.conf and it works fine after
sudo service mongod restart
Related
When I try to start elasticsearch on my macOS laptop, it does not appear to have started. So much of the answers I find on the internet do not relate to using brew on macOS.
See this command line history of trying to start it.
:>brew services stop elasticsearch
Stopping `elasticsearch`... (might take a while)
==> Successfully stopped `elasticsearch` (label: homebrew.mxcl.elasticsearch)
:>brew services start elasticsearch
==> Successfully started `elasticsearch` (label: homebrew.mxcl.elasticsearch)
:>curl http://localhost:9200
curl: (7) Failed to connect to localhost port 9200: Connection refused
:>curl https://localhost:9200
curl: (7) Failed to connect to localhost port 9200: Connection refused
:>lsof -i :9200
:>sudo ps -ef | grep elastic
501 85360 68989 0 9:51AM ttys000 0:00.00 grep elastic
Also using the Network Utility I see nothing is listening at the port 9200.
I am using Catalina Version 10.15.7 (19H1030).
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
My elasticsearch version is
Version: 6.0.1, Build: 601be4a/2017-12-04T09:29:09.525Z, JVM: 1.8.0_121
The location of the binary on my PATH is /usr/local/bin/elasticsearch
EDIT:
There was a comment to include any error messages or the output. If this was not clear, what I wrote is the only output. The only output to stdout or stderr from brew services start elasticsearch is "Successfully started elasticsearch".
However, when trying elasticsearch -d from the command line I get this:
:>elasticsearch
2021-05-24 09:33:08,875 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.checkMBeanTrustPermission(DefaultMBeanServerInterceptor.java:1848)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:322)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)
at org.apache.logging.log4j.core.jmx.Server.register(Server.java:389)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:167)
at org.apache.logging.log4j.core.jmx.Server.reregisterMBeansAfterReconfigure(Server.java:140)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:556)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:206)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:220)
at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:197)
at org.elasticsearch.common.logging.LogConfigurator.configureStatusLogger(LogConfigurator.java:172)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:141)
at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:120)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:290)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:130)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:121)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:69)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85)
ERROR: no log4j2.properties found; tried [/usr/local/etc/elasticsearch] and its subdirectories
The /usr/local/etc/elasticsearch directory exists but is empty.
:>ls -l /usr/local/etc
...
drwxr-xr-x 2 marlpier admin 64 May 19 16:30 elasticsearch
...
:>find /usr/local/etc/elasticsearch
/usr/local/etc/elasticsearch
Maybe my jvm.options file is not found. Where should it be?
Answer was that brew reinstall elasticsearch was not working.
Doing brew uninstall elasticsearch gave a java error. So to uninstall java, brew uninstall java also gave a java error.
Answer to uninstall java was here by removing the java directory.
After that I was able to uninstall elasticsearch and then install it again with brew. Now it works.
How can I set Postgres in Travis CI OS X build?
I can't start and I don't know how to set these:
--dbaddress localhost --dbport 5432 --dbname testDb --dbusername postgres
With the Travis CI OS X instances the environment is similar to a typical Homebrew installation.
Here is the Travis CI OS X environment you can configure.
The database services that are available:
postgis version 2.1.3, postgresql version 9.3.5
Unlike Linux, the service configuration is not currently available in OSX. You start a database service using the install script and making use of the Postgresql tools directly.
An example .travis.yml looks like this:
addons:
postgresql: "9.4"
language:
- objective-c
os:
- osx
sudo:
- false
install:
- export PG_DATA=$(brew --prefix)/var/postgres
- pg_ctl -w start -l postgres.log --pgdata ${PG_DATA}
- createuser -s postgres
- psql -c 'create database testDb;' -U postgres
- cat postgres.log
So what does it do?
“add ons” is selecting your specific postgresql version over the default
“sudo” commands cannot be executed in Travis CI
“install” contains the commands we need to run and others you want to add
The pg_ctl command requires a data directory, “PG_DATA” contains a path to the local home-brew installation and your directory to store database files.
pg_ctl will start the existing service and wait(-w) to be connected.
A unix user/role "postgres" must be created and is used in the final creation script for your database “testDb”.
Finally, the postgres.log is sent to Travis CI log.
Hopefully, that gives you an idea of where to start.
Additional information to griffio's answer:
In the meantime Travis is running PostgreSQL 9.5 (even with addon postgresql: "9.4") and I got the following log output when starting:
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.4, which is not compatible with this version 9.5.4.
It's working after creating a new cluster first:
install:
- export PG_DATA=$(brew --prefix)/var/postgres
- rm -rf $PG_DATA
- initdb $PG_DATA -E utf8
- pg_ctl -w start -l postgres.log --pgdata ${PG_DATA}
- createuser -s postgres
- psql -c 'create database testDb;' -U postgres
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.
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.)