MongoDB 2.6 legacy won't start as Windows Service - mongodb

I have a replica set with 3 Windows Server 2008 R2, and I can't get the MongoDB 2.6 Legacy service working in none of them (I had services with MongoDB 2.4 without any problem in these servers).
This is my YAML config file:
systemLog:
destination: file
path: Z:\MongoDB\log\db02.log
quiet: false
logAppend: true
net:
port: 28019
storage:
dbPath: Z:\MongoDB\data\db02
directoryPerDB: true
journal:
enabled: true
replication:
replSetName: rs0
Assumptions:
logpath and dbpath exist (and db02.log file).
I have access to Z drive
Steps:
1. Run command:
mongod --config "C:\Program Files\MongoDB 2.6 Standard Legacy\mongod.cfg" --install
2. Service is correctly created, and if I copy the ImagePath of the service and paste to a console without the --service option, mongo runs fine. ImagePath is:
"C:\Program Files\MongoDB 2.6 Standard Legacy\bin\mongod.exe" --config "C:\Program Files\MongoDB 2.6 Standard Legacy\mongod.cfg" --service
3. The service doesn't start, complaining with Error 1054 - Service did not respond in Timely Fashion. In Windows event viewer I have no more information than that (no access errors, no other relevant info).
Other attemps with no success and same result (1054):
Even though ImagePath is correct (with quotes for blankspaces and full paths), I tried with a "C:\mongo" installation to avoid blankspaces.
Tried putting quotes to paths in YAML file.
As YAML is a new format, I tried with this config file
port = 28019
logpath = Z:\MongoDB\log\db02.log
logappend = true
dbpath = Z:\MongoDB\data\db02
directoryperdb = true
journal = true
replSet = rs0
quiet = false
Any help would be very appreciated.

This is a known issue from version 2.6 onwards. A link in the docs explains how to create the service manually. I experienced the same issue, followed the documentation and it's now working:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#manually-create-windows-service

Related

How to provide mongoSQLd Authentication failed ERROR 1043 (08S01)

To run BI on project we have used mongsqld to convert the JSON into tables.
On our first installation, everything was running fine and we were able to make analytics.
After installing the security on mongod, the monsqld failes to establish the connection with following error:
connection accepted from 127.0.0.1:44530 #11219 (1 connection now open)
handshake error: ERROR 1043 (08S01): MongoDB schema not yet available
end connection 127.0.0.1:44530 (0 connections now open)
Thanks in Advance.
It can also be the case that you haven't set up your mongosqld.conf correctly on your mongo bi connector side.
This will be evident if you check the log files for your mongosqld.conf and find that it has repeated entries for "[Sampler] sampling mongodb for schema permanently". In my case this happened all night until I fixed the config file.
In my particular case - I didnt configure authentication as per the following.
logAppend: false
path: "/var/log/mongosqld/mongosqld.log"
verbosity: 2
security:
enabled: true
mongodb:
net:
uri: "mongo.example.com:27017"
auth:
username: "root"
password: "changeme"
net:
bindIp: 192.0.2.14
port: 3307
As soon as I made the change, uninstalled mongosqld (sudo mongosqld uninstall), installed momgosqld with the new conf (sudo mongosqld install ), and restarted it - it worked.
More about the configuration here - https://docs.mongodb.com/bi-connector/master/reference/mongosqld/#std-label-config-format

Data not moving to new shard servers mongodb

I have added a shard server to my mongodb cluster. After adding the new shard server, I am getting this error on primary node.
DBException thrown :: caused by ::
CannotImplicitlyCreateCollection{ ns: "config.system.sessions" }:
request doesn't allow collection to be created implicitly
The new shard server is new and did not have any data earlier.
How did I add the shard server?
I create a file /etc/mongod.conf (just like my other shard servers)
sharding:
clusterRole: shardsvr
replication:
replSetName: shardReplicaSet10
storage:
dbPath: /mnt/mongodb
systemLog:
traceAllExceptions: true
path: /mnt/log/mongodb/out.log
logAppend: true
logRotate: rename
destination: file
processManagement:
fork: true
net:
bindIp: localhost,172.6.7.5
Then I have another member in this replicaSet with same config file, just the bindIp is changed.
I connected to my mongos node and add the replicaSet
sh.addShard("shardReplicaSet10/172.6.7.5:27018,172.6.7.6:27018")
I can confirm that I have initiated the replicaset using rs.initiate()
It turns out that whenever we add a new shard replicaSet, We need to give it a identity manually. I tried the steps given in this answer
https://dba.stackexchange.com/a/227877
and It worked. On primary of shard replicaSet, simply do this :
use admin
and add identity
db.system.version.insert({
"_id" : "shardIdentity",
"clusterId" : ObjectId("5f098ac1077eb0e078fd5c1e"),
"shardName" : "NameOfYourShardReplicaSet",
"configsvrConnectionString" : "configReplicaSet/ipofconfigserver:27019,ipofotherconfigserver:27019"
})
you can get cluster Id by using
sh.status()
on any of the mongos cluster.

MongoDB - configure encryption in cfg file

MongoDB v4 Ent, Windows Server 2016 Std
Starting mongodb from command line works fine:
mongod --enableEncryption --encryptionKeyFile c:\key\mongodb-keyfile
Now I need to change mongod.cfg so windows service starts with encryption enabled. After adding following parameters to file
security:
enableEncryption: true
encryptionKeyFile: c:\key\mongodb-keyfile
service throw error while starting
error 1067: the process terminated unexpectedly
Any ideas?

how to restore mongodb data after my mongdb container has been removed

I run a mongodb in docker container, and i have data file backup.
But today I removed my mongodb careless.
I tried to run an another container and put the datafile into the container, but it did not work.
How can I restore my data from the data file?
the database file I only have now:
the container I use is tutum/mongodb.my docker-compose.yml file is
mongo_db:
image: tutum/mongodb
privileged: true
restart: always
ports:
- 27016:27017
- 28016:28017
volumes:
- /var/mongodb:/data/db
environment:
- MONGODB_PASS=xxxxxx
- AUTH=yes
and now I want restore my data from dirctory /var/mongodb to my new container
I put the file except mongod.lock in my new container,but my mongodb can't run.
it's the screenshot:
the mongod.conf is:
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongod.log
logappend=true
#port = 27017
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip = 127.0.0.1
# Disables write-ahead journaling
# nojournal = true
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#diaglog = 0
# Ignore query hints
#nohints = true
# Enable the HTTP interface (Defaults to port 28017).
#httpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Replication Options
# in replicated mongo databases, specify the replica set name here
#replSet=setname
# maximum size in megabytes for replication operation log
#oplogSize=1024
# path to a key file storing authentication info for connections
# between replica set members
#keyFile=/path/to/keyfile
the container ower set STORAGE_ENGINE in env while the container start running
the enviroment of the container is:
# mongod.conf
STORAGE_ENGINE=wiredTiger
HOSTNAME=bb544551ec2b
MONGODB_PASS=xxxxxx
LS_COLORS=
AUTH=yes
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/etc
SHLVL=1
HOME=/root
LESSOPEN=| /usr/bin/lesspipe %s
JOURNALING=yes
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/
the logs under tutum/mongodb:3.0:
It depends how you performed your backup.
1 - You took a filesystem snapshot.
=> you can untar your snapshot in your data folder (check on mongod.conf where is located your data folder).
2 - You used mongodump command.
=> you need to use mongorestore command
I am struggling with mongodb and the lack of persistent storage across reboots myself. Reading your post here makes me wonder what this means:
From your mongod.conf:
Disables write-ahead journaling
nojournal = true
and from your environment variable:
JOURNALING=yes
Perhaps your env should be:
NOJOURNAL=false
or
NOJOURNAL=no
(Im also struggling with the markdown here)
I personally was finally able to persist data using this compose section - and by setting an ENV variable NODE_ENV: production (in a different service which was depending on the mongodb service)
image: mongo:4.4
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: something
MONGO_INITDB_ROOT_PASSWORD: otherthanthis
volumes:
- ./mongodata:/data/db:cached

Mongod doesn't recognize net.http in yaml config?

I have the following config as mongod.cfg:
systemLog:
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:
http:
enabled: true
I'm running MongoDB 2.6.3 on Windows 7 64 bit by running: mongod --config mongod.cfg I'm inside the folder and I know it's parsing the correct mongod.cfg. However, I'm getting the following output:
Unrecognized option: net.http
try 'mongod --help' for more information
I am pulling my hair out wondering why it's not parsing. I'm reading straight from the configuration page on Mongo's site and I still can't make it work. Any ideas?
Turns out I needed spaces after the headers. It needed to be:
systemLog:<space>
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:<space>
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:<space>
http:<space>
enabled: true
I also met the similar issue when add auth to MongoDB admin user. When install MongoDB 3.0.8 or 3.0.15, the error appears:
CONTROL Hotfix kb2731284 or a later update is not installed, will zero-out files.
Fail to install kb2731284(obtained from MS's mail) in my PC whose OS is win7 enterprise version, no vaild resolution online.
Unrecognized option: net.http
try 'mongod --help' for more information
Then update MongoDB to v3.6 can avoid the error in the beginning, but now if want to add auth for MongoDB user using the mongod.cfg file, following content need to be used:
systemLog:
destination: file
path: "D:\\mongodb\\log\\mongodb.log"
logAppend: true
storage:
dbPath: "D:\\mongodb"
journal:
enabled: true
engine: wiredTiger
net:
port: 27017
setParameter:
enableLocalhostAuthBypass: false
Save the file mongod.cfg.
Create folder C:\mongodb\data\,
then create subfolder C:\mongodbdata\log,
Copy the mongod.cfg file to related location of MongoDB bin, such as C:\ProgramFiles\MongoDB\Server\3.6\bin\.
Then set value enableLocalhostAuthBypass in mongod.cfg file to true.
Open cmd.exe with the administrator privilege:
"C:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.exe" "--config=c:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.cfg" --auth --install
If the mongodb service is not running, type net start mongodb
C:\Users\{username}\Desktop>netstart mongodb
> use admin
> db.createUser("admin", "yourpassword", roles: ["root"]})
> db.auth(user, yourpassword)
Restart MongoDB from commond line.
Set value enableLocalhostAuthBypass to false.
Since for MongoDB 3.6 (actually any version after v3.2) have removed the net.http options (Refer: https://docs.mongodb.com/manual/reference/configuration-options/).
Then all issues met can be completely solved.