Difference between revisions of "Setting up osgeo vm"

From stgo
Jump to: navigation, search
(Further VMs that I am running)
(Further VMs that I am running)
Line 106: Line 106:
 
* check running VMs using: <code>VBoxManage list runningvms</code>
 
* check running VMs using: <code>VBoxManage list runningvms</code>
 
* existing VMs using: <code>VBoxManage list vms</code>
 
* existing VMs using: <code>VBoxManage list vms</code>
 +
* stopping an unresponsive VM: <code>VBoxManage controlvm VMNAME poweroff</code>

Revision as of 15:06, 7 May 2014

>> return Cedeus IDE


Setup of an OSGeo Virtual Machine with VirtualBox

Setting up a OSGeo VirtualBox-VM on Lautaro with SuseLinux - but using command line (because creating the VM via the graphical interface vboxgtk did not work properly). The general documentation was taken from here: http://stdioe.blogspot.com/2012/01/creating-virtual-machine-with.html

Steps:

  1. install virtualbox on server/computer (done by Daniel, needs admin rights of course)
  2. download the iso with the OS, for ubuntu (= not OSGeo live):
    curl -L -O  http://releases.ubuntu.com/12.04.3/ubuntu-12.04.3-server-i386.iso > ubuntu12043server.iso
  3. create a VM based on Ubuntu:
    VBoxManage createvm --name osgeo  --ostype Ubuntu --register
  4. check it is there:
    VBoxManage showvminfo osgeo
  5. set the memory/ram:
    VBoxManage modifyvm osgeo --memory 8192
    (which is 8GB)
  6. check the memory/ram:
    VBoxManage showvminfo osgeo | grep "Memory size"
  7. set the number of cpu's to use (here 4):
    VBoxManage modifyvm osgeo --cpus 4
  8. set the network connection/routing
    nat: like behind a firewall, access from host, e.g. PostgisVM - vs. - bridge: want to be visible from outside, using my own IP, e.g. GeoNodeVM
    VBoxManage modifyvm osgeo --nic1 nat
    Here we use 'nat'-ing instead of a bridge. For a bridge we have to use unstead: first this command: VBoxManage modifyvm osgeo --bridgeadapter1 eth0 and then, this command: VBoxManage modifyvm osgeo --nic1 bridged.
  9. create a harddisk of 100GB size:
    VBoxManage createhd --filename osgeo.vdi --size 100000
  10. define the VM's disk controller:
    VBoxManage storagectl osgeo --name "SATA Controller" --add sata --controller IntelAhci
  11. mount the disk:
    VBoxManage storageattach "osgeo" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium osgeo.vdi
  12. check if everything is there:
    VBoxManage showvminfo osgeo
  13. add DVD device:
    VBoxManage storagectl osgeo --name "IDE Controller" --add ide --controller PIIX4
  14. load the DVD device with the Ubuntu VM/osgeo iso file (check if the iso has proper rights, i.e. maybe do a chmod 775):
    VBoxManage storageattach osgeo --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium yyy/osgeolive7.iso 
  15. starting VM
    VBoxHeadless -s osgeo -n -m 7777 & 
    The -s is for start, 7777 defines the port for conecting with VNC, and the & is for keeping the VM running when I disconnect from the server. Headless actually means, that we have no monitor...
  16. don't forget to install VNC Viewer (e.g. RealVNC), and then connect via the defined port - to "146.155.xx.xxx:7777"
  17. ... do a real install of the osgeo VM, etc.
  18. install ssh server
    sudo apt-get install openssh-server
  19. how to do a mapping for ssh (& ftp), so that the guest VM can be reached from the host machine is described here: http://blogs.oracle.com/rmanus/entry/virtualbox_how_to_ftp_from
    In particular one has to do the following:
    VBoxManage modifyvm osgeo --natpf1 "ssh,tcp,,2222,,22"
    These entries are then added to osgeo.vbox xml file. For ftp the port would be 21 instead of 22. To enable Apache, do the same but use: config folder "apache", HostPort "8888", GuestPort "80", Protocol "TCP", e.g. (as one line):
     VBoxManage modifyvm osgeo --natpf1 "apache,tcp,,8888,,80"
    and for Tomcat:
     VBoxManage modifyvm osgeo --natpf1 "tomcat,tcp,,8889,,8080"
    • Note, if a "Error: failed to start machine. Error message: Configuration error: Failed to get the "MAC" value (VERR_CFGM_VALUE_NOT_FOUND)" appears, then it may be necessary to change the network adapter to PCnet-FAST III (Am79C973), according to this Blog entry
  20. check here on how to detach the medium use:
    VBoxManage storageattach osgeo --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium none
  21. shutting down the vm per vboxmanage :
    VBoxManage controlvm <uuid>|<name> pause|resume|reset|poweroff|savestate|acpipowerbutton|acpisleepbutton
  22. tomcat 6 can be found in /usr/share/tomcat6/bin. However, the start/stop command is simply:
    sudo service tomcat6 start
    Check out: Blog: How to instal Tomcat 6 on Ubuntu 12.04. Also, don't forget to create users for the manager interface (see this Blog post). Finally, the right amount of memory can be assigned in the file /etc/tomcat6/tomcat6.conf. However, I did not had this file. So I created a new file setenv.sh in /usr/share/tomcat6/bin via
    sudo touch setenv.sh
    and then edited it adding the following lines:
    #!/bin/sh 
    JAVA_OPTS="-Xms512m -Xmx4g -XX:MaxPermSize=270m -server -Djava.awt.headless=true -Djava.util.prefs.systemRoot=$CATALINA_HOME/content/thredds/javaUtilPrefs" 
    export JAVA_OPTS
    Then I stopped and re-started tomcat. The above method also worked with Tomcat7.
  23. displaying catalina output:
    cd /var/lib/tomcat6
    tail -f logs/catalina.out
  24. activate remote desktop for VBox:
    VBoxManage modifyvm osgeo --vrde on
    VBoxManage modifyvm osgeo --vrdemulticon on
    and define the port number
    VBoxManage modifyvm osgeo --vrdeport XXXX

Other Notes

Install & updates

When Installing Ubuntu server, I got actually problems with the update sever, and had to switch to main. For that I used:

sudo nano /etc/apt/sources.list

Then locate http://cl.archive.ubuntu.com/ubuntu and replace it with http://archive.ubuntu.com/ubuntu.
Afterwards, installing htop with sudo apt-get install htop worked as well, why it did not work before.

Installing a GUI

Installing a (optional) GUI for Ubuntu is described here: http://www.maketecheasier.com/use-a-gui-on-a-ubuntu-server/
See also my notes on the accessing server infra page.

Changing Vbox mac address

use
VBoxManage modifyvm osgeo --macaddress1 08002783b21e

After that my eth0 disappeared and stayed without internet connection! I got it back by deleting: /etc/udev/rules.d/70-persistent-net.rules and rebooting. This tip came from here.

Next I had to set the IP manually, using command line. How to do this via command line is described here

Changing the max upload size of wars for Tomcat 7

use
/usr/share/tomcat7-admin/manager/WEB-INF$ sudo nano web.xml

and change the max file setting. (Note, the tomcat7-admin package needs to be installed first).

More info on installing tomcat: http://help.ubuntu.com/13.04/serverguide/tomcat.html


Copying a VDI (Harddisk) file to attach it to another VM

If a vdi is copied and/or renamed, and then should be attached to a different VM one needs to assign a new UUID, otherwise the following message appears:

VBoxManage: error: Cannot register the hard disk '/home/sstein/backuppostgis.vdi' {60886f08-fedb-49dc-aec0-a1a9ae54a43b} because a hard disk '/home/sstein/backupgeonode.vdi' with UUID {60886f08-fedb-49dc-aec0-a1a9ae54a43b} already exists [...]

In my case I wanted to create a new VM (backuppostgis) without installing ubuntu again.

To assign a new UUID use: VBoxManage internalcommands sethduuid backuppostgis.vdi

Note, that re-using a harddisk/vdi with another/new VM means, that the network connection of the VM will not work, as we have a new network card. To solve this see above (comment out the now two network card adapters in /etc/udev/rules.d/70-persistent-net.rules and do a reboot).

The computers name can be change by editing /etc/hostname. Still, on "sudo" may appear: "unable to resolve host xxx". This indicates that the hostname should be changed as well in /etc/hosts.

Fast setup of VM from existing VM disk tarball

I have a tarball of a VM disk with a fresh Ubuntu Server install (the tar file is called "vmBackupGeoNodeDisk.tgz"). This can serve to setup fairly fast a new Ubuntu based VM.

  • untar the disk tarball with Ubuntu installed tar -C /home/sstein/untar -xvzf /home/sstein/vmbackup/vmBackupGeoNodeDisk.tgz
  • copy and rename VM disk file to folder with other disk files: mv untar/home/sstein/backupgeonode.vdi /home/sstein/wypwps.vdi
  • assign a new serial ID to the disk so it can be used by the new VM: VBoxManage internalcommands sethduuid wypwps.vdi
  • create new VM:
VBoxManage createvm --name wyp  --ostype Ubuntu --register
VBoxManage modifyvm wyp --memory 4096
VBoxManage modifyvm wyp --cpus 4
VBoxManage modifyvm wyp --nic1 nat
VBoxManage storagectl wyp --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach "wyp" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium wypwps.vdi
VBoxManage modifyvm wyp --natpf1 "ssh,tcp,,17022,,22"
VBoxManage modifyvm wyp --natpf1 "apache,tcp,,17080,,80"
VBoxManage modifyvm wyp --natpf1 "tomcat7,tcp,,17088,,8080"
  • start the VM: VBoxHeadless -s wyp -n -m 7773 &
  • login with usual name (ss-) and password (2*-*s)
  • note, the VM has a bit weird keyboard setting. So I haven't figured where / etc is - which makes navigation difficult. So, connecting via ssh, after solving the problem below, is best.
  • fix network connection problem by commenting out the two network card adapters in /etc/udev/rules.d/70-persistent-net.rules and do a reboots in

Further VMs that I am running

  • VBoxHeadless -s geonode -n -m 7779 & => bridged (with own IP)
  • VBoxHeadless -s postgis -n -m 7778 & => nat (9022, 9080)
  • VBoxHeadless -s backupgeonode -n -m 7776 & => nat (14022, 14080) : powered down
  • VBoxHeadless -s backuppostgis -n -m 7775 & => nat (15022, 15080) : powered down
  • VBoxHeadless -s tilestream -n -m 7774 & => nat (16022, 16080) : should be running - with TileStream PID 4672 on port 16088
  • VBoxHeadless -s wyp -n -m 7773 & => nat (17022, 17080) : should be running
  • osgeo VM should be powered down, as it was only for testing
  • check running VMs using: VBoxManage list runningvms
  • existing VMs using: VBoxManage list vms
  • stopping an unresponsive VM: VBoxManage controlvm VMNAME poweroff