Can't set mongo as replica set - mongodb

Hi I am trying to use mongo-connector for transport data from mongo db to elasticsearch. For that I need to set mongodb as replica set. So I run the mongodb first by executing mongod command and run mongod --replSet "rs0 command after that. But it showed me an error as below.
2017-10-03T21:16:46.571-0700 I CONTROL [initandlisten] MongoDB starting : pid=12180 port=27017 dbpath=C:\data\db\ 64-bit host=ME
2017-10-03T21:16:46.572-0700 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-10-03T21:16:46.572-0700 I CONTROL [initandlisten] db version v3.4.6
2017-10-03T21:16:46.572-0700 I CONTROL [initandlisten] git version: c55eb86ef46ee7aede3b1e2a5d184a7df4bfb5b5
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] allocator: tcmalloc
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] modules: none
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] build environment:
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-10-03T21:16:46.574-0700 I CONTROL [initandlisten] distarch: x86_64
2017-10-03T21:16:46.574-0700 I CONTROL [initandlisten] target_arch: x86_64
2017-10-03T21:16:46.574-0700 I CONTROL [initandlisten] options: { replication: { replSet: "rs0" } }
2017-10-03T21:16:46.575-0700 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: C:\data\db\mongod.lock The process cannot access the file because it is being used by another process.. Is a mongod instance already running?, terminating
2017-10-03T21:16:46.575-0700 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-10-03T21:16:46.575-0700 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-10-03T21:16:46.575-0700 I CONTROL [initandlisten] now exiting
2017-10-03T21:16:46.576-0700 I CONTROL [initandlisten] shutting down with code:100

Just Run the command directly mongod --replSet "rs0", don't use mongod and then the replSet command.

Related

How to fix mongodb Error: Network is unreachable

I get this error, when I try to connect to MongoDB
Error:
Network is unreachable.
Running mongod before mongo shell didn't help .
When I restart my computer it works!!!Anyway I get that error again, something like 30 minutes later.
This is output from cmd, when I run command mongod
C:\Program Files\MongoDB\Server\4.0\bin>mongod
2019-04-26T18:50:26.559+0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-04-26T18:50:26.562+0400 I CONTROL [initandlisten] MongoDB starting : pid=1092 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-47AK9D5
2019-04-26T18:50:26.562+0400 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-04-26T18:50:26.563+0400 I CONTROL [initandlisten] db version v4.0.7
2019-04-26T18:50:26.563+0400 I CONTROL [initandlisten] git version: 1b82c812a9c0bbf6dc79d5400de9ea99e6ffa025
2019-04-26T18:50:26.564+0400 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] modules: none
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] build environment:
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] distmod: 2008plus-ssl
2019-04-26T18:50:26.566+0400 I CONTROL [initandlisten] distarch: x86_64
2019-04-26T18:50:26.566+0400 I CONTROL [initandlisten] target_arch: x86_64
2019-04-26T18:50:26.567+0400 I CONTROL [initandlisten] options: {}
2019-04-26T18:50:26.568+0400 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2019-04-26T18:50:26.568+0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-04-26T18:50:26.568+0400 I CONTROL [initandlisten] now exiting
2019-04-26T18:50:26.568+0400 I CONTROL [initandlisten] shutting down with code:100
Edit: I found a problem. MongoDB Server turns off automatically. Just change service startup type to Manual.
MongoDB Server Properties

My MongoDB isnt working when I type mongod in the terminal

I type in mongod to create a new db but I get this error, any idea what's going on here?
mongod
2018-08-28T18:06:36.824+0100 I CONTROL [initandlisten] MongoDB starting : pid=41812 port=27017 dbpath=/data/db 64-bit host=Ruairidhs-MacBook-Pro.local
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] db version v3.6.3
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] allocator: system
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] modules: none
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] build environment:
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] distarch: x86_64
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] options: {}
2018-08-28T18:06:36.825+0100 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] now exiting
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] shutting down with code:100
Open a new terminal window, and execute top, according to the error, you already have an instance of mongod running, so you need to find it and terminate it.

Mongod not finding the path of the data directory

I'm trying to build a simple CRUD app with a MEAN stack, here's my file tree so far:
-app
-node_modules
-server
-config
-db.js
-controllers
-user.api.js
-models
-user.js
-routes
-api.js
-web.js
-package.json
-server.js
When running mongod I got the following error:
2017-12-03T15:25:53.243-0500 I CONTROL [initandlisten] MongoDB starting : pid=57220 port=27017 dbpath=/data/db 64-bit host=Carloss-MacBook-Pro.local
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] db version v3.4.10
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2m 2 Nov 2017
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] allocator: system
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] modules: none
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] build environment:
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] distarch: x86_64
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] target_arch: x86_64
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] options: {}
2017-12-03T15:25:53.247-0500 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-12-03T15:25:53.247-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-12-03T15:25:53.247-0500 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-12-03T15:25:53.247-0500 I CONTROL [initandlisten] now exiting
2017-12-03T15:25:53.247-0500 I CONTROL [initandlisten] shutting down with code:100
So I tried to specify the path of my folder to /server/config/db but that still didn't work. Am I writing the path incorrectly?
This is what I have in my db file:
var mongoose = require('mongoose');
var connection = mongoose.connect('mongodb://localhost/mean_db');
module.exports = connection;

Unable to start mongdb

2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] MongoDB starting : pid=5716 port=27017 dbpath=/data/db/ 64-bit host=localhost
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] db version v3.2.0
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] modules: none
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] build environment:
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] distarch: x86_64
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db/" } }
2017-05-11T12:03:49.724+0530 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-05-11T12:03:49.724+0530 I - [initandlisten] Fatal Assertion 28578
2017-05-11T12:03:49.724+0530 I - [initandlisten]
***aborting after fassert() failure`enter code here`
I am not able to start Mongodb server i tried using service as well and using --dbpath as well i don't know what is the issue. i tried to delete journal files as well but that didn't work
Try to delete the file /tmp/mongodb-27017.sock manually and restart the process.
Have you tried starting it with Sudo from the terminal like so
sudo mongod
this will require your system username and password

Create admin user MongoDB not possible

When I am trying to follow the tutorial by typing
mongod --port 27017 --dbpath /data/db1
console responds with
C:\WINDOWS\system32>mongod --port 27017 --dbpath /data/db1
2017-03-03T14:43:54.019+0100 I CONTROL [initandlisten] MongoDB starting : pid=1776 port=27017 dbpath=/data/db1 64-bit host=Tim-V5
2017-03-03T14:43:54.020+0100 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-03-03T14:43:54.021+0100 I CONTROL [initandlisten] db version v3.4.2
2017-03-03T14:43:54.021+0100 I CONTROL [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
2017-03-03T14:43:54.022+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] allocator: tcmalloc
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] modules: none
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] build environment:
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-03-03T14:43:54.024+0100 I CONTROL [initandlisten] distarch: x86_64
2017-03-03T14:43:54.024+0100 I CONTROL [initandlisten] target_arch: x86_64
2017-03-03T14:43:54.025+0100 I CONTROL [initandlisten] options: { net: { port: 27017 }, storage: { dbPath: "/data/db1" } }
2017-03-03T14:43:54.025+0100 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db1 not found., terminating
2017-03-03T14:43:54.026+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-03-03T14:43:54.026+0100 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-03-03T14:43:54.027+0100 I CONTROL [initandlisten] now exiting
2017-03-03T14:43:54.027+0100 I CONTROL [initandlisten] shutting down with code:100
Even I already have created folder with
mkdir C:\data\db
and checked that it exists!
Following with
mongo --port 27017
It responds with
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017/
MongoDB server version: 3.4.2
Server has startup warnings:
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten]
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten]
I am using windows 10, how can I solve this? It's rather frustating