Running `mongod --config path` yields Error parsing command line - mongodb

I was trying to create a mongodb (6.1.1) server with mongod with a custom config, but when I run mongod --config path the console yields Error parsing command line: Multiple occurrences of option "--config".
Running mongod alone or stuff like mongod --port 12345 seems to create the server, so I'm not sure why it's giving an error parsing the command line. Any path I give (absolute, relative, invalid) it yields the same error. The alias -f yields the same.
I doubt it matters but I installed mongo through scoop.

Alright found out the issue, it really is because of scoop.
Since one of scoop's objective is to prevent PATH polution, it writes an exe with the same name as the real executable, which runs behind the screen the real executable, with the help of the shim file.
Get-Command mongod yielded C:\Users\Plancha\scoop\shims\mongod.exe, and I thought that was the actual mongod. Turns out it isn't because it's in this shims folder. I understood this when I tried to copy and run this exe in the desktop (as kinda suggested by one of the commenters), and yielding Could not read shim file, leading me to make some further research about the package manager.
In conclusion, mongod.shim was:
path = "C:\Users\Plancha\scoop\apps\mongodb\current\bin\mongod.exe"
args = --config "C:\Users\Plancha\scoop\apps\mongodb\current\bin\mongod.cfg"
,
and the mongod.exe shim was simply passing the path, those args, and my additional args, leading to the multiple occurrences.
So to fix this, removing the args line was enough. I'll try and write a pull request to the main bucket.

Related

BadValue: error: no args for --configdb try 'C:\Program Files\MongoDB\Server\6.0\bin\mongos.exe --help' for more information

I finished installing MongoDB and I am trying the command $ mongo and I keep getting an error:
BadValue: error: no args for --configdb try 'C:\Program Files\MongoDB\Server\6.0\bin\mongos.exe --help' for more information
I think you might have set up the config server as a standalone process and you might have to use a replicaset instead.
This might help:
https://www.mongodb.com/docs/manual/sharding/
Your command will look something like this:
mongos --configdb replsetname/localhost:27010 --port 27011
But if you are trying to use the mongoDb shell then you might have to download it separately. They do not bundle the shell together as they used to before. So you have to download mongosh as a zip and extract the contents of the "bin" folder to the "bin" folder where you have installed mongo. Then you can use the MongoDB shell(mongosh.exe).
You need to install mongos shell separately. It can be downloaded as a zip file you need to extract it to the program files. Then add the location of mongos.exe to the vim.
If you face any difficulty in adding the path to vim use this link.
Make sure to change the version in the path example, mine will look like this.
alias mongod="/c/Program\ Files/MongoDB/Server/6.0/bin/mongod.exe"
alias mongos="/c/Program\ Files/mongosh-1.6.1-win32-x64/mongosh-1.6.1-win32-x64/bin/mongos.exe"
Don't make an exact copy of this. Change the path according to your setup and add these values in vim and close it using
:wq!
Use the provided link for handling the vim.

Run mongod in ZSH shell on Mac and and get command not found

I'm trying to run mongodin my terminal, but I'm getting a command not found. I've consulted other questions on this issue, including this these:
mac: command not found: mongod
Mongod: Command Not Found (OS X)
But the solutions have not worked for me.
Here is the full path of mongod:
/Users/danno/mongodb/bin/mongod
In .zshrc, I've tried two scripts, but neither one works:
Attempt 1 (from other Stack Overflow questions):
export PATH="$PATH:/usr/local/mongodb/bin"
Attempt 1 (My own guess):
export PATH="$PATH:/Users/danno/mongodb/bin/mongod"
I've restarted the terminal multiple times to no avail.
From the terminal, I'm trying to run:
mongod --dbpath=/Users/danno/mongodb-data
Getting a command not found while running that and also just with mongod alone.
Is something wrong with my pathing?
Maybe you forgot to do this step:
$ source ~/.bash_profile
It is better to put $PATH at the end.
I hope this will help. Additional options can be found in the post and the video.

second line on my system or python terminal now saying: “ -bash: zzzzz#: command not found“

I have been trying to pip install psycopg2 for some time now
I have just updated to python 3.7.4, before this problem started.
To set my path to a specific python version I used the code below.
nano .bash_profile
I thought that it would now be easy for my system to identify the path of the newly installed python, as to enable it to install psycopg2. Then the below started happening.
The second line of system terminal or python terminal is now always showing:
-bash: zzzzz#: command not found on my terminal
No matter what I type on my terminal, I am always getting command not found
This would mean you literally have "zzzzz" somewhere in the bash_profile. Bash is seeing "zzzzz" as just another command to run at startup like the rest of the profile script. As there is nothing in your PATH matching that string, bash reports the issue back to you.
Either remove the extra line from your .bash_profile. OR use a terribly wasteful work-around!
ln -s /bin/true /bin/zzzzz
This will create a symbolic link to the "true" binary (all it ever does is return true) from zzzzz. Now bash can find zzzzz and run it during start up, which does nothing. No more error and an absurd work around. You should fix the file.

Failed Global Initialization: BadValue logpath requires an absolute file path with windows services

I am getting this error constantly while i am trying to install mongod using a configuration file. So, I am looking at this tutorial on Pluralsight on mongodb. The person's programming environment going as smoothly as it can. However, i am encountering several problems. First of all, i am trying to setup a different logpath and database path.This is the basic layout of the conf file
dbpath=/Pluralsight/db
logpath=/Pluralsight/mongod.conf
verbose=vvvvv
My syntax:
c:\Program Files\MongoDB\Server\3.0\bin\mongod -f c:\Pluralsight\mongod.conf
//Trying to run mongod using a configuration file
When i press enter, i am supposed to get a message that says everything is being directed to this new logfile and a new database. I do not get any message. However, that did not stop it from creating a log file with information in the expected folder. Now, I proceed to install mongod as a service. This is when i type
C:\Program Files\MongoDB\Server\3.0\bin\mongod -f c:\Pluralsight\mongod.conf --install
//using the configuration file to install mongod as a service
I get an error:
Failed Global Initialization: BadValue logpath requires an absolute
file path with windows services
I have no idea how to fix this!
I was having the same problem with MongoDB's instructions because I was using relative path in the CLI for my mongo.cfg once I had navigated to the MongoDB bin:
mongod.exe --config mongod.cfg --install.
Instead I needed to specify the config file's absolute path:
mongod.exe --config "C:\Program Files\MongoDB\Server\3.0\bin\mongod.cfg" --install
The error message spells out the problem. Your MongoDB confguration file has a relative path, not an absolute path.
Try setting the logpath as follows
logpath=c:/Pluralsight/mongod.log
I got the same problem. After I read this doc, resolved.
https://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows
Open an Administrator command prompt.
Press the Win key, type cmd.exe, and press Ctrl + Shift + Enter to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
Create directories.
Create directories for your database and log files:
mkdir c:\data\db
mkdir c:\data\log
Create a configuration file.
Create a configuration file. The file must set systemLog.path. Include additional configuration options as appropriate.
For example, create a file at C:\mongodb\mongod.cfg that specifies both systemLog.path and storage.dbPath:
systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db
Install the MongoDB service.
Important
Run all of the following commands in Command Prompt with “Administrative Privileges”.
Install the MongoDB service by starting mongod.exe with the --install option and the -config option to specify the previously created configuration file.
"C:\mongodb\bin\mongod.exe" --config "C:\mongodb\mongod.cfg" --install
To use an alternate dbpath, specify the path in the configuration file (e.g. C:\mongodb\mongod.cfg) or on the command line with the --dbpath option.
If needed, you can install services for multiple instances of mongod.exe or mongos.exe. Install each service with a unique --serviceName and --serviceDisplayName. Use multiple instances only when sufficient system resources exist and your system design requires it.
Start the MongoDB service.
net start MongoDB
Stop or remove the MongoDB service as needed.
To stop the MongoDB service use the following command:
net stop MongoDB
To remove the MongoDB service use the following command:
"C:\mongodb\bin\mongod.exe" --remove
echo logpath=C:/myProgra/MongoDB/log/mongo.log > "C:\MyProgram\MongoDB\mongod.cfg"
C:\myprogram\MongoDB\Server\3.0\bin\mongod.exe --config "C:\myProgram\MongoDB\mongod.cfg" --install
I ran into the same problem. But I could resolve it by updating the paths as follows. I could see the problem is with Forward and backward slashes in file paths.
mongod.conf (instead of giving the relative path provide absolute path and also make sure you have "/" instead of "\")
dbpath= C:/mongolearning/db
logpath= C:/mongolearning/mongo-server.log
verbose=vvvvv
and then go to Command prompt:
C:\Program Files\MongoDB\Server\3.2\bin>mongod -f "C:\Program Files\MongoDB\Server\3.2\bin\mogod.conf" --install
and then
C:\Program Files\MongoDB\Server\3.2\bin>net start mongodb
Boom it started.
The MongoDB service is starting.
The MongoDB service was started successfully.
I faced the same problem while installing the MongoDB service by specifying the logpath and dbpath flags directly from the command line.
mongod --install --logpath='<my log path>' --dbpath='<my db path>'
It turned out that the logpath and dbpath values had to be wrapped inside double quotes (i.e. "") instead of single qoutes, or otherwise no quotes at all if the paths are without any spaces in the absolute directory path.
So the following did the trick for me:
mongod --install --logpath="<my log path>" --dbpath="<my db path>"
Notice the paths wrapped within double qoutes.
Thanks for the suggestions guys. I just went with MongoDB's instructions on their website on installing mongod as a service in windows instead of Pluralsight tutorial's and it went well.
there can't be quotation marks in your configure file .
way like this is wrong:
dbpath="D:/Program Files/MongoDB/Data/DB"
logpath="D:/Program Files/MongoDB/Data/Log/mongo.log"
downside is right:
dbpath=D:/Program Files/MongoDB/Data/DB
logpath=D:/Program Files/MongoDB/Data/Log/mongo.log
In the config file use absolute path instead of relative path for dbpath & logpath as like below and run the command to install the MongoDB service.
dbpath = c:/Pluralsight/db (instead of /Pluralsight/db)
logpath = c:/Pluralsight/mongo-server.log (instead of Pluralsight/mongo-server.log)
verbose = vvvvv
Command to install the MongoDB service is like:
mongod -config "C:\Pluralsight\mongod.conf" --install
I got the same error
**Failed Global Initialization: BadValue logpath requires an absolute file path with windows services**
as I was specifying log path folder in mongo.config but I have to specify a log file
dbpath=C:\Program Files\MongoDB\Server\3.4\data\db
logpath=C:\Program Files\MongoDB\Server\3.4\log
diaglog=3
i changed my log file to
dbpath=C:\Program Files\MongoDB\Server\3.4\data\db
logpath=C:\Program Files\MongoDB\Server\3.4\log\mongo.log
diaglog=3
and after that this command solved my problem. hope this workfor you as well.
mongod.exe --config "C:\Program Files\MongoDB\Server\3.4\mongo.config" --install
then finally
net start MongoDB

Executable file to run java on CentOS 5

I'm trying to make a simple file so I can call it in SSH and it will start my minecraft server.
I tried making a batch file called start.bat with this code:
java -Xmx512M -Xmx512M -jar craftbukkit-1.2.5-R1.0.jar nogui
However, when I run it in SSH:
$ cd /Minecraft/server_1/
$ start.bat
The SSH returns that it is an invalid or unknown command. Is there any other way I can make a quick command/file to start my server? What file extensions would I use to get this working? It works if I paste that java command in SSH and run it, but I'd rather have a file.
The current working directory is not included in your PATH by default because it is a security risk on multiuser systems. (And a potential annoyance even on machines that are single user.) You would use ./start.bat to start the program.
Since you're using Windows naming conventions, I presume you also forgot to set the execution mode bit -- and you probably also forgot the shebang line at the top of the file.
Try this:
#!/bin/sh
java -Xmx512M -Xmx512M -jar craftbukkit-1.2.5-R1.0.jar nogui
Run chmod 500 on this file. (Strictly speaking, 555 could also work, if you didn't mind other people on the machine executing the file. But they don't need to, so don't let them.) See the chmod(1) manpage for more details on the modes -- 1 bits mean executable, 2 bits means writable, and 4 bits means readable -- thus, 5 is executable and readable.
Then, when you want to run the script, run it like this:
cd /Minecraft/server_1
./start.bat
Note the ./ -- that means the shell should start the search for the executable program in the current working directory. (It could be ./bin/start.bat if your current working directory had a bin subdirectory with a start.bat executable file.)
Is start.bat executable? Make sure you have #!/bin/sh as the first line of the file. Also the directory is probably not in in the path, so try this:
$ chmod 555 start.bat
$ ./start.bat