0

I am currently having issues with setting up a replica set (as per the instructions on a mongoDB tutorial on creating a replica set) on my Mac (Sierra). I have downloaded the associated .sh file and when I run this code:

bash < create_replica_set__m101p_52b35df6e2d423678d3b9d48.19830756d7a7.sh

This is the script:

#!/usr/bin/env bash

mkdir -p /data/rs1 /data/rs2 /data/rs3
mongod --replSet m101 --logpath "1.log" --dbpath /data/rs1 --port 27017 --oplogSize 64 --fork --smallfiles
mongod --replSet m101 --logpath "2.log" --dbpath /data/rs2 --port 27018 --oplogSize 64 --smallfiles --fork
mongod --replSet m101 --logpath "3.log" --dbpath /data/rs3 --port 27019 --oplogSize 64 --smallfiles --fork

I get this error in my terminal:

mkdir: /data/rs1: Permission denied mkdir: /data/rs2: Permission denied mkdir: /data/rs3: Permission denied about to fork child process, waiting until server is ready for connections. forked process: 27998 ERROR: child process failed, exited with error number 100 about to fork child process, waiting until server is ready for connections. forked process: 28001 ERROR: child process failed, exited with error number 100 about to fork child process, waiting until server is ready for connections. forked process: 28004 ERROR: child process failed, exited with error number 100

I have attempted to do this with sudo and I get the same result.

I have attempted to run this both in my downloads folder and on my desktop. I have moved it into my home directory, and I get nothing logged out to the console, it just returns a new line.

What do I need to do here?

Thank you

bloppit
  • 621
  • 8
  • 22

1 Answers1

3

Try:

sudo mkdir /data
sudo chmod -R 755 /data && sudo chown -R `whoami` /data
# now run the script

It may not be necessary to run the first command, if /data exists already just run the second command.

The error codes are because MongoDB can't create the database files necessary because the directories don't exist.

tkbyte
  • 493
  • 1
  • 3
  • 8