Specific VM name to target in a multi-VM environment - centos

I am creating two CentOS Boxes with a Vagrantfile, and using two unique host names for them, in their respectibe blocks
box1_config.vm.host_name = "Base1"
box1_config.vm.network:hostonly, "192.168.50.4"
box2_config.vm.host_name = "Base2"
box2_config.vm.network:hostonly, "192.168.50.5"
The OS starts without any issues, but I don't know what hostname to use to access them.
I tried following as argument to "vagrant ssh", but none worked and I get error: "This command requires a specific VM name to target in a multi-VM environment"
Tried with:
host_name
IP Address
The VM Name in VirtualBox
Any clues where I might be going wrong?

The argument for vagrant ssh is the symbol attached to the vm definition block. For example (from the vagrant docs):
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.box = "web"
web_config.vm.forward_port 80, 8080
end
config.vm.define :db do |db_config|
db_config.vm.box = "db"
db_config.vm.forward_port 3306, 3306
end
end
you would do
vagrant ssh web
or
vagrant ssh db
since those are the names of the box as defined in the config.
HTH.

Related

logging into a specific hpc node from jupyter notebook in VS code

I work on an HPC where we have a login node to login and then we can ask for a specific amount of computing resources which will then be allocated on compute node. We cannot run our programs in login node since it is shared. Currently, if we want to run jupyter on the compute node, we have to ssh into the compute node and forward the port.
Is there any way to ssh into compute node so that we can run the jupyter notebook from vs code itself? If I run it directly it will run in login node which is a problem.
You can ssh into a compute node that is accessible through a login node by setting up your VSCode ssh config file such that your login node is a ProxyJump and your compute node the host you want to ssh to.
If you would log in to your login node as ssh username#ip.of.login.node, and from the login node, you can ssh to the compute node as ssh ip.of.compute.node, then you can set up your config file as such:
Host loginnode
HostName ip.of.login.node
User meulemeester
Host computenode
HostName ip.of.compute.node
User meulemeester
ProxyCommand ssh -vv -W %h:%p <ip.of.login.node>
# -W flag is necessary to redirect stdin and stdout
# %h:%p is hostname and portname. Host refers to ProxyJump (i.e. loginnode), port is 22 by default
ProxyJump loginnode
Make sure that this config file is the file used when running ssh. Check the VSCode setting Remote.SSH: config file to see if it points to this config file. Instead of using the IPs fo the login node or compute node, you can also use the host names directly (i.e. anything you would put after the # when ssh'ing).
Depending on the authorisation methods, you may want to add additional parameters to the config file. The given setup works if the host has the public key of the local machine stored under ~/.ssh/authorized_keys.
The compute node should now be available as an option when you want to connect to a host in VSCode.

Move mongo database from vagrant outside of VM

Hello guys I'm trying to find a way to move my mongo database inside vagrant outside of it. I'm reading some posts in this forum but they're related to postgres and mysql.
When I run npm start this is the code I have in my package.json
"start": "MONGODB=mongodb://localhost:27017....
So the problem is that the databse will get saved in Virtual Machine localhost, so, by the time it runs it won't be accessible outside of VM. How can I change this localhost path to communicate outside?
It is not different wether it is vagrant or another server.
The db location files are specified in /etc/mongodb.conf. By default db are saved in /data/db
So the problem is that the databse will get saved in Virtual Machine localhost, so, by the time it runs it won't be accessible outside of VM. How can I change this localhost path to communicate outside?
If you want the db to be accessible from your host machine you need to replace localhost by the IP of the vagrant VM (if you specified a private IP) or better use the 0.0.0.0 so its accessible from all network interfaces
I did it, this link gave me the answer: Vagrant reverse port forwarding?
It seems that by default mongo will be located in 10.0.2.2 outside of vagrant, so if I run inside vagrant: mongo 10.0.2.2:27017 it connects to my databases outside of vagrant.
Therefore, this is what I need to put in my package.json to run npm start...
"start": "MONGODB=mongodb://10.0.2.2:27017/

run a distribution test with jmeter in Vm Centos

I'm trying to run a distribution test for learning purpose and i'm using a Virtual machine Centos 7 as a slave in my Windows 7 ( master running in window 7) but even if i configure the master with the IP of the slave ( VM ), modifying the file jmeter.properties, doesn't work, i try run Jmeter-server in the Centos machine but this problem appears.
Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:44341](lo
cal),objID:[4e68a212:14a8564a618:-7fff, 5760053273490727502]]]
Server failed to start: java.rmi.RemoteException: Cannot start. localhost.locald
omain is a loopback address.
An error occurred: Cannot start. localhost.localdomain is a loopback address.
Can somebody give me a direction where look or a explanation how can i do it?
Thanks!
Put the following line in system.properties file: java.rmi.server.hostname=xxx.xxx.xxx.xxx
Alternatively start JMeter providing above property as a command-line argument as:
jmeter (or jmeter-server) -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx
Double check your network configuration, i.e. make sure that your /etc/hosts file contains the following lines:
127.0.0.1 localhost localhost.localdomain
xxx.xxx.xxx.xxx your CentOS machine hostname
In all above cases xxx.xxx.xxx.xxx should be IP address of your CentOS machine and this IP address must be different from 127.0.0.1.
Also make sure that you select "Bridged" networking in your Virtual Machine, machines should be able to reach each other over the network, firewalls should be properly configured to allow communication, etc.
For more information on different JMeter Properties and ways of setting/overriding them see Apache JMeter Properties Customization Guide

Installation via Vagrant requires GUI

UPDATE (5 Feb, 2014) : This error comes up when machine is restarted without proper shutdown
I am trying to install EdX's open source Learning Management System, through their development vagrant box on a remote machine. However, I get an error related to virtual machine GUI. Is there anything that can be done via CLI/ssh ?
This is the exact error.
The guest machine entered an invalid state while waiting for it
to boot. Valid states are 'starting, running'. The machine is in the
'poweroff' state. Please verify everything is configured
properly and try again.
If the provider you're using has a GUI that comes with it,
it is often helpful to open that and watch the machine, since the
GUI often has more helpful error messages than Vagrant can retrieve.
For example, if you're using VirtualBox, run `vagrant up` while the
VirtualBox GUI is open.
Below are the contents of VagrantFile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :forwarded_port, guest: 8000, host: 9000
config.vm.network :forwarded_port, guest: 8001, host: 9001
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network :private_network, ip: "192.168.20.40"
nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/
config.vm.synced_folder ".", "/opt/edx/edx-platform", id: "vagrant-root", :nfs => nfs_setting
# Make it so that network access from the vagrant guest is able to
# use SSH private keys that are present on the host without copying
# them into the VM.
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |vb|
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "2048"]
# This setting makes it so that network access from inside the vagrant guest
# is able to resolve DNS using the hosts VPN connection.
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
config.vm.provision :shell, :path => "scripts/install-acceptance-req.sh"
config.vm.provision :shell, :path => "scripts/vagrant-provisioning.sh"
end
No, there's not much you can do/diagnose using CLI or Ssh at this stage, because the VM fails to initialize properly and is not in a "working" state.
You should follow the advice contained in the error message.
Destroy your current VM:
vagrant destroy
then open VirtualBox GUI, and restart the Vagrant setup with :
vagrant up
You can then watch in the VM Console/Window (from Virtualbox GUI) what fails and prevents the setup from running.
An alternative way to start the VM with a console GUI would be to modify your Vagrantfile:
# You will find this line in the Vagrantfile
Vagrant.configure("2") do |config|
#Add this directive
config.vm.provider "virtualbox" do |v|
v.gui = true
end
end
(destroy your existing and failing VM with vagrant destroyand then run vagrant up)
If the remote machine (where VirtualBox runs) is a Unix box accessed using SSH, you may be able to export the GUI to your local machine using the -Xoption when SSHing to it. See this answer for more details about ssh -X
This message occured with my environment because 2 things:
1 - If your VirtualBox Software GUI have is closed, just open it.
Ps.: Try vagrant destroy then vagrant up again
2 - If the problem persist, just update your VirtualBox GUI.
VirtualBox Downloads
Let me know if it's done.

How to connect with host PostgreSQL from vagrant virtualbox machine

I have a VirtualBox machine running Ubuntu 12.04 in a Mac OS X host machine. In my host machine (Mac OS X), I have PostgreSQL installed. I would like to connect to this PostgreSQL server from my Ubuntu virtual machine (I know normally it's the opposite way).
I guess I should configure some networking parameters in VirtualBox itself. All I get from Vagrant docs is I need to assign my vm a static IP to use a private network. But once created, how do I reach my host from my guest?
I didn't find anything like that in vagrant docs. So, there's probably a good reason for that. Does it make sense? I don't want to duplicate PostgreSQL installation. Just use my current existent one.
You can reach your host from your guest by using the default gateway on your VM.
See this answer for an explanation.
By running netstat -rn you can get the default gateway and then use that ip address in your config file of your application.
Running netstat -rn | grep "^0.0.0.0 " | cut -d " " -f10 should give you the correct ip address. (only tested this on my machine)
Easy way - simply use this "magic" IP from inside of vagrant without any additional configurations:
10.0.2.2
Don't know if it's always static, though for me works and it's very convenient - I can use laptop at home, from office - having assigned different IPs to me by routers, but my VMs know the "trusty name" of their master 🐶