Help in initiating Vagrant for M312

I have installed Vagrant version 2.2.19 and VirtualBox version 6.1.32 on my Mac machine (MacOS Monterey version 12.3.1

The install was successful and now I need to initiate my Vagrant environment

I started by using ‘vagrant init’ as my first command
and then when I use ‘vagrant up’, I run into this error below. Please help:

vikas.saini@M-FVFZF2ZRLYWH ~ % vagrant up

Bringing machine ‘default’ up with ‘virtualbox’ provider…

==> default: Box ‘base’ could not be found. Attempting to find and install…

default: Box Provider: virtualbox

default: Box Version: >= 0

==> default: Box file was not detected as metadata. Adding it directly…

==> default: Adding box ‘base’ (v0) for provider: virtualbox

default: Downloading: base

An error occurred while downloading the remote file. The error

message, if any, is reproduced below. Please fix this error and try

again.

Couldn’t open file /Users/vikas.saini/base

Are you running the command from vagrant-env directory?
I don’t think vagrant init is required

Hi @Ramachandra_Tummala How do i figure my vagrant-env directory?

Check your download directory or where you unzipped the file
May be under /users/xyz/M312

I ran the vagrant up command from my vagrant-env directory, but am getting an error on IP addresses
Reproduced below:

vikas.saini@M-FVFZF2ZRLYWH ~ % cd /Users/vikas.saini/Documents/MDBU/m312-vagrant-env

vikas.saini@M-FVFZF2ZRLYWH m312-vagrant-env % vagrant up

Bringing machine ‘m312’ up with ‘virtualbox’ provider…

==> m312: Box ‘ubuntu/trusty64’ could not be found. Attempting to find and install…

m312: Box Provider: virtualbox

m312: Box Version: >= 0

==> m312: Loading metadata for box 'ubuntu/trusty64’

m312: URL: https://vagrantcloud.com/ubuntu/trusty64

==> m312: Adding box ‘ubuntu/trusty64’ (v20190514.0.0) for provider: virtualbox

m312: Downloading: https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20190514.0.0/providers/virtualbox.box

Download redirected to host: cloud-images.ubuntu.com

==> m312: Successfully added box ‘ubuntu/trusty64’ (v20190514.0.0) for ‘virtualbox’!

==> m312: Importing base box ‘ubuntu/trusty64’…

==> m312: Matching MAC address for NAT networking…

==> m312: Setting the name of the VM: m312

==> m312: Clearing any previously set forwarded ports…

Vagrant is currently configured to create VirtualBox synced folders with

the SharedFoldersEnableSymlinksCreate option enabled. If the Vagrant

guest is not trusted, you may want to disable this option. For more

information on this option, please refer to the VirtualBox manual:

https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

config.vm.synced_folder ‘/host/path’, ‘/guest/path’, SharedFoldersEnableSymlinksCreate: false

==> m312: Clearing any previously set network interfaces…

The IP address configured for the host-only network is not within the

allowed ranges. Please update the address used to be within the allowed

ranges and run the command again.

Address: 192.168.14.100

Ranges: 192.168.56.0/21

Valid ranges can be modified in the /etc/vbox/networks.conf file. For

more information including valid format see:

https://www.virtualbox.org/manual/ch06.html#network_hostonly

Where do I update my IP address?

I think you can do it from vxbox GUI network settings
or edit your vagrant file to change IP
Check our forum threads

Did it and launched the RS successfully using the command:

vagrant@m312:~$ mlaunch init --replicaset --name m312RS --wiredTigerCacheSizeGB 0.3 --port 30000 --host localhost

and then

vagrant@m312:~$ mongo --port 30000

But when I try to log in again to launch the Replica set, I get an error:

vagrant@m312:~$ mlaunch init --replicaset --name m312RS --wiredTigerCacheSizeGB 0.3 --port 30000 --host localhost
A different environment already exists at /home/vagrant/data.

and when trying to connect to Port 30000, I again get an error:

vagrant@m312:~$ mongo --port 30000

MongoDB shell version v3.4.2

connecting to: mongodb://127.0.0.1:30000/

2022-06-10T11:19:23.540+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:30000, in(checking socket for error after poll), reason: Connection refused

2022-06-10T11:19:23.553+0000 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:30000, connection attempt failed :

connect@src/mongo/shell/mongo.js:237:13

@(connect):1:6

exception: connect failed

This was all working perfectly till 2 days back. Is is because I had opened up 3 CLI interfaces?

Hi, @Ramachandra_Tummala
This got solved. thanks

vagrant destroy and then again vagrant up

Hi @Ramachandra_Tummala

I am unable to run the function insertDocs(), for currentOp and killOp hands on practice (under chapter 2 - Tooling Overview)

I keep on putting the function against m312 PRIMARY and nothing happens

Did I not execute the m312/currentOpKillOp.js properly?

I am not familiar with this task or the script
May be you have to reset your VM and try again

Hi @Ramachandra_Tummala

In M312, chapter 2, current op & kill op, as per the lecture notes, I am unable to run the function:

MongoDB Enterprise m312RS:PRIMARY> function insertDocs() {
… db.getSisterDB(“m312”);
… db.things.drop();
… var bigString = Array(10000).join(“Padding”); // 80 kb string
… var docCount = 0;
… var docsPerBatch = 100;
… while (true) {
… print(“About to insert docs, so far, I have inserted " + docCount + " documents.”);
… docs = [];
… for (i=1; i<=docsPerBatch; i++) {
… docs.push( { docNumber : (docCount + i), filler : bigString } );
… };
… db.things.insertMany( docs );
… docCount += docsPerBatch;
… print(" …done.");
… };
… };

Any idea where I am getting it wrong?

What error you getting?
I think you are suppose to run .sh scripts in vagrant environment
Check this link