commandline installation of virtual machine in oracle virtual box - virtualbox

Looking for command line installation of centos7 virtual machine in a host machine(centos7).
Followed several options but once the vm is created, its not able to get ip and cant access the guest machine from the host server
followed below methods
1. VBoxManage createvm --name centos-server --ostype Linux --register
Virtual machine 'centos-server' is created and registered.
UUID: 6eb514b4-a1f3-4454-9d76-2be9d0f76cb3
Settings file: '/root/VirtualBox VMs/centos-server/centos-server.vbox'
2. VBoxManage modifyvm centos-server --bridgeadapter1 vmnet1
3.
VBoxManage modifyvm centos-server --memory 2048
4
VBoxManage createhd --filename VirtualBox\ VMs/centos-server/centos-server.vdi --size 10000 --format VDI
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: adae09bb-d01b-42ee-9383-69ef59b2cbf6
===== /root/VirtualBox VMs/VirtualBox VMs/centos-server/centos-server.vdi
VBoxManage storagectl centos-server --name "SATA Controller" --add sata --controller IntelAhci
6.
VBoxManage storageattach centos-server --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium VirtualBox\ VMs/centos-server/centos-server.vdi
if not working
VBoxManage storageattach centos-server --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "/root/VirtualBox VMs/VirtualBox VMs/centos-server/centos-server.vdi"
7.
VBoxManage storagectl centos-server --name "IDE Controller" --add ide --controller PIIX4
8.
VBoxManage storageattach centos-server --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /opt/CentOS-7-x86_64-DVD-1908.iso
9.
VBoxManage startvm centos-server --type headless
getting error as below
Waiting for VM "centos-server" to power on...
VBoxManage: error: VT-x is not available (VERR_VMX_NO_VMX)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

Related

Layer 2 connection between VMs in GCP?

I have two machines in the same VPC (under same subnet range) in GCP. I want to ping MAC address from one instance to another (ie. layer 2 connection). Is this supported in GCP?
If not, is GRE tunnel supported between the two VMs in the above configuration or any other tunneling?
My mail goal is to establish a layer 2 connection.
Andromeda (Google's Network) is a Software Defined Networking (SDN). Andromeda's goal is to expose the raw performance of the underlying network while simultaneously exposing network function virtualization.
Hence, Andromeda itself is not a Cloud Platform networking product; rather, it is the basis for delivering Cloud Platform networking services with high performance, availability, isolation, and security. For example, Cloud Platform firewalls, routing, and forwarding rules all leverage the underlying internal Andromeda APIs and infrastructure.
Also, By default, the instances are configured with a 255.255.255.255 mask (to prevent instance ARP table exhaustion), and when a new connection is initiated, the packet will be sent to the subnet’s gateway MAC address, regardless if the destination IP is outside or within the subnet range. Thus, the instance might need to make an ARP request to resolve the gateway’s MAC address first.
Unfortunately Google doesn't allow GRE traffic[1].
So, my recommendation is to run some test like iperf or MTR between them in order to validate layer 2.
You can not have L2 connectivity this out of the box. However, you can setup a VXLAN or other kind of tunnels between VMs if you really need L2 connectivity for some odd reason. I've written a blog about how to do this: https://samos-it.com/posts/gce-vm-vxlan-l2-connectivity.html (Copy pasting the main pieces below)
Create the VMs
In this section you will create 2 Ubuntu 20.04 VMs
Let's start by creating vm-1
gcloud compute instances create vm-1 \
--image-family=ubuntu-2004-lts --image-project=ubuntu-os-cloud \
--zone=us-central1-a \
--boot-disk-size 20G \
--boot-disk-type pd-ssd \
--can-ip-forward \
--network default \
--machine-type n1-standard-2
Repeat the same command creating vm-2 this time:
gcloud compute instances create vm-2 \
--image-family=ubuntu-2004-lts --image-project=ubuntu-os-cloud \
--zone=us-central1-a \
--boot-disk-size 20G \
--boot-disk-type pd-ssd \
--can-ip-forward \
--network default \
--machine-type n1-standard-2
Verify that SSH to both VMs is available and up. You might need o be patient.
gcloud compute ssh root#vm-1 --zone us-central1-a --command "echo 'SSH to vm-1 succeeded'"
gcloud compute ssh root#vm-2 --zone us-central1-a --command "echo 'SSH to vm-2 succeeded'"
Setup VXLAN mesh between the VMs
In this section, you will be creating the VXLAN mesh between vm-1 and vm-2 that you just created.
Create bash variables that will be used for setting up the VXLAN mesh
VM1_VPC_IP=$(gcloud compute instances describe vm-1 \
--format='get(networkInterfaces[0].networkIP)')
VM2_VPC_IP=$(gcloud compute instances describe vm-2 \
--format='get(networkInterfaces[0].networkIP)')
echo $VM1_VPC_IP
echo $VM2_VPC_IP
Create the VXLAN device and mesh on vm-1
gcloud compute ssh root#vm-1 --zone us-central1-a << EOF
set -x
ip link add vxlan0 type vxlan id 42 dev ens4 dstport 0
bridge fdb append to 00:00:00:00:00:00 dst $VM2_VPC_IP dev vxlan0
ip addr add 10.200.0.2/24 dev vxlan0
ip link set up dev vxlan0
EOF
Create the VXLAN device and mesh on vm-2
gcloud compute ssh root#vm-2 --zone us-central1-a << EOF
set -x
ip link add vxlan0 type vxlan id 42 dev ens4 dstport 0
bridge fdb append to 00:00:00:00:00:00 dst $VM1_VPC_IP dev vxlan0
ip addr add 10.200.0.3/24 dev vxlan0
ip link set up dev vxlan0
EOF
Start a tcpdump on vm-1
gcloud compute ssh root#vm-1 --zone us-central1-a
tcpdump -i vxlan0 -n
In another session ping vm-2 from vm-1 and take a look at tcpdump output. Notice the arp.
gcloud compute ssh root#vm-1 --zone us-central1-a
ping 10.200.0.3

Accessing Two containers on from browser

I have launch EC2 ubuntu instance and security group for this is instance allows 22,80,443 ports from 0.0.0.0/0.
Now i have installed docker on this EC2 instance.Then i have created an apache2 container and also mapped the port to access from browser using below command
sudo docker run -p 80:80 -t -i ubuntu /bin/bash
Then i create an lampstack conatiner and tried to map port using below command
sudo docker run -p 443:443 -t -i linode/lamp /bin/bash
Now docker ps gives me below
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS Name
d0751e67fd69 linode/lamp "/bin/bash" 4 min Up 4 0.0.0.0:443>443/tcp
affectionate_hamilton
0fb4e13a272a ubuntu "/bin/bash" 11 minutes 0.0.0.0:80->80/tcp
vigorous_robinson
When i take the public ip of my EC2 machine and put in browser i can see the apache page but how can i assess my Lampstack page ?
Please correct me if i have done port mapping incorrectly
You only need the LAMP container and in that one you should map the port 80:
sudo docker run -d --name lamp -t -p 80:80 linode/lamp top
Check that the container is up and running:
sudo docker ps --filter name=lamp
Now start the services:
sudo docker exec -ti lamp service apache2 start
sudo docker exec -ti lamp service mysql start
Test your setup from host:
curl http://localhost
If you want to test a connection from a different container you can start a separate ubuntu container that links to your original container "lamp":
docker run -ti --rm --link lamp --name ubuntu-box ubuntu bash
Inside the container install curl and test your connection:
apt update && apt-get install curl -y
curl http://lamp

Permission denied to Docker on Ubuntu

Docker is installed on AWS EC2 Ubuntu 16.04 instance as follows:
docker info raises a permission denied error:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/info: dial unix /var/run/docker.sock: connect: permission denied
docker -v shows:
Docker version 18.09.4, build d14af54
uname -a displays:
4.4.0-1072-aws #82-Ubuntu SMP
sudo snap start docker cannot find 'docker'.
What's wrong here?
You need to add the ubuntu user to the docker group:
sudo usermod -aG docker ubuntu

Cloudera manager Page isn't opening

I Followed these steps :
First i took a server(Cent OS 6) from Google Cloud in Asia South reagion.
and Executed these commands :
sudo -i
chkconfig iptables off
service iptables stop
setenforce 0
vi /etc/selinux/config (SELINUX=disabled)
init 6
wget http://archive.cloudera.com/cm5/installer/latest/cloudera-manager-installer.bin
chmod u+x cloudera-manager-installer.bin
sudo ./cloudera-manager-installer.bin
Done! Cloudera manager installed Successfully.
But when I am trying to access http://my_public_ip:7180/ then getting timed out error.
ALso i waited for 1 hour after installing cloudera(for startup settings). but again same response.
I have opened the port 7180 on EC2 Instance Firewall but not on EC2 Security Group. By adding Port 7180 on EC2 Security Group now Cloudera manager working.

Running iPython Notebook in Docker container on Amazon EC2 instance

How do I run and access iPython Notebook (in Docker on EC2) from the browser?
This is what I tried:
From EC2 Quick Start menu, selected Amazon Linux AMI 2015.03 on t2.micro instance.
Everything left as default, except 3 rules created for "Configure Security Group":
Type: "SSH"; Protocol: "TCP"; Port Range: "22"; Source: "Anywhere";
Type: "HTTPS"; Protocol: "TCP"; Port Range: "443"; Source: "Anywhere";
Type: "Custom TCP Rule"; Protocol: "TCP"; Port Range: "8888"; Source: "Anywhere";
After SSH'ing to instance:
$ sudo yum install -y docker ; sudo service docker start
$ sudo docker pull continuumio/miniconda # Anaconda includes iPython Notebook
$ sudo docker run -it -p 8888:8888 continuumio/miniconda ipython notebook
Then launching browser to https://ec2-xx-x-x-xxx.compute-1.amazonaws.com:8888 didn't work.
I wouldn't be too comfortable opening 443 and 8888 on the Internet for my EC2 instances. My common setup is Anaconda on an Ubuntu box.
I usually ssh port forward my ipython notebook sessions to my localhost on my macbook with this ssh command:
ssh -i myPrivateSSHKey.pem ubuntu#54.1.2.3 -L 8888:localhost:8888
Then I open Chrome and request URL:
http://127.0.0.1:8888