Installation vm

  • Published on
    11-May-2015

  • View
    663

  • Download
    2

Embed Size (px)

Transcript

<ul><li>1.How to install a virtualmachinemartes 17 de agosto de 2010 </li></ul><p>2. Introduction Install JDK Install RPM packages How to create a virtual machine host martes 17 de agosto de 2010 3. Introduction docs: http://en.wikipedia.org/wiki/Virtual_machine To check if KVM has successfully been installed,run virsh -c qemu:///system list acces to root, need the key: su It should display something like this: installation virtual machine yum install virt-managervirsh -c qemu:///system list Id NameState ---------------------------------- installation libraries yum install kvm qemu libvirt python- virtinst martes 17 de agosto de 2010 4. Install JDK Browse to http://download.java.net/jdk6/ and I have to also set JAVA_HOME to point to the jdk so I select the relevant link. In this case .I wanted a .bin le look for the .batch_prole le and edit it. And add for fedora 12 so I selected it under the Linux headingthe entry export JAVA_HOME=/usr/java/jdk1.6.0_21. Save and then logout and then login. Got the url path (right-click select properties) and in the terminal I entered the command sudo wget ensure that the path is correct by running This then download the .bin le to the directory I wasecho $JAVA_HOME in. and it returns the correct location. Then launch JBoss without any errors!!!! I then changed the permissions on the le using chmod a+x to make it executable. I the ran the le and it installed to a java folder I had created in /usr/bin/. When I do an ls it shows me the JDK folder. martes 17 de agosto de 2010 5. Install RPM packages docs: http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29Installation de LVM in the Virtual machine like rootsudo yum install system-cong-lvmRestart the virtual machine, and connect again ( -X option is for see the window with the information about the partitions)rebootssh test@tst01 -XWhen you have this, you can see the window with all the information about the LVM volumes, using this commandsudo system-cong-lvm martes 17 de agosto de 2010 6. How to create a virtualmachine hostPrerequisites: To check if KVM has successfully been installed,runvirshYou need kvm up and running It should display something like this: virsh # net-list --all If you don't want to run as root, the user you want to useneeds to have rw access to /dev/kvm If it displays an error instead, then something wentwrong.If you want to be able to access the internet or a local Next we need to set up a network bridge on ournetwork, your host system must be able to access theserver so that our virtual machines can beinternet or the local network accessed from other hosts as if they were physicalsystems in the network. To install KVM and virtinst (a tool to create virtual To do this, we install the package bridge-utils...yum install bridge-utilsmachines), we runyum install kvm qemu libvirt python-virtinst qemu-kvm ... and congure a bridge.Then start the libvirtdaemon:/etc/init.d/libvirtd start martes 17 de agosto de 2010 7. Starting to testVM, JBoss, Harmony, Apache martes 17 de agosto de 2010 8. Introduction Expanding the disk capacity Creating the load balancer and the nodes Run JBoss with Harmonymartes 17 de agosto de 2010 9. Introduction docs: software testing http://en.wikipedia.org/ Go to the other server were I have the interface that I wiki/Software_testingneed use. And copy the les. We have a server, where we installation the S.O. In this ssh test@test02 case I install ubuntu. A when I have installed i do the less /etc/network/interfaces following (my host machine called test02): sudo -i ls -al ifcong | less shutdown To see the directory where I stay pwdsudo /etc/init.d/networking restart Go inside like a root user sudo -i ls -al martes 17 de agosto de 2010 10. Expanding the diskcapacity Device Boot Start End Blocks Id System /dev/sdb11 9726 78124063+ 5 Extended /dev/sdb5112 96327 83 Linux We have two hard Drives, when we have the les, we /dev/sdb6 135594393746 82 Linux swap / need put together and start the other hard drive.Solaris /dev/sdb7560 972673633896 83 Linux To see the disk on your computer root@test02:~# fdisk -lYou can verify this situation with the df -k command's output,which also shows that the other partitions are too full to acceptany more data. Disk /dev/sda: 80.0 GB, 80000000000 bytesroot@test02:~# df -k 255 heads, 63 sectors/track, 9726 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Filesystem 1K-blocks Used Available Use% Mounted on Disk identier: 0x00000080 /dev/mapper/test02-root73444600 1147652 68566108 2% / Device Boot StartEndBlocks Id System tmpfs 20326400 2032640 0% /lib/init/rw /dev/sda1 *19695 77875056 8e Linux LVM varrun2032640 112 2032528 1% /var/run /dev/sda2 9696 9726 249007+ 5 Extended varlock 20326400 2032640 0% /var/lock /dev/sda5 9696 9726 248976 83 Linuxudev2032640160 2032480 1% /devtmpfs 20326400 2032640 0% /dev/shm Disk /dev/sdb: 80.0 GB, 80000000000 byteslrm20326402760 2029880 1% 255 heads, 63 sectors/track, 9726 cylinders /lib/modules/2.6.28-11-server/volatile Units = cylinders of 16065 * 512 = 8225280 bytes /dev/sda5 233335 14320 206567 7% /boot Disk identier: 0x00000080 martes 17 de agosto de 2010 11. Linux stores the names of all known disk partitions in the /proc/partitions le. The entire hard disk is represented by an entry with a minor number of 0, and The rst Linux step in adding a new disk is to partition it in all the partitions on the drive are sequentially preparation of adding a lesystem to it. Type the fdisk command numbered after that. followed by the name of the disk.You want to run fdisk on the /dev/sdb disk, so the command is: root@test02:~# fdisk /dev/sdb root@test02:~# cat /proc/partitions The number of cylinders for this disk is set to 9726. major minor #blocks name There is nothing wrong with that, but this is larger than 1024, 8078125000 sda and could in certain setups cause problems with: 8177875056 sda1 82 1 sda2 1) software that runs at boot time (e.g., old versions of LILO) 85 248976 sda5 2) booting and partitioning software from other OSs 8 1678125000 sdb 8 17 1 sdb1 (e.g., DOS FDISK, OS/2 FDISK) 8 21 96327 sdb5 8 22 4393746 sdb6 8 2373633896 sdb7 252074616832 dm-0 2521 3211264 dm-1 martes 17 de agosto de 2010 12. Just to make sure you're on the correct device, issuethe p command to print all the known partitions onthe disk. In this case, there are none which is good.Command (m for help): p The fdisk m command prints a small help manual of validcommands.You will see that n is the command to add a newpartition. Add a new primary partition, number 1, and use thedefaults to make the partition occupy the entire disk. Command (m for help): p Disk /dev/sdb: 80.0 GB, 80000000000 bytes Command (m for help): n Command (m for help): n255 heads, 63 sectors/track, 9726 cylinders Command action l logical (5 or over)Units = cylinders of 16065 * 512 = 8225280 bytes p primary partition (1-4) pDisk identier: 0x00000080 Partition number (1-4): 1 Partition 1 is already dened. Delete it before re-adding it.Device BootStart EndBlocks Id System/dev/sdb1 19726 78124063+ 5 Extended/dev/sdb5 112 96327 83 Linux/dev/sdb6 13559 4393746 82 Linuxdev/sdb75609726 73633896 83 Linux martes 17 de agosto de 2010 13. Run the print (p) command to conrm that you successfully created the partition partition. root@test02:/# pvcreate /dev/sdb1 Command (m for help): p Physical volume "/dev/sdb1" successfully created root@test02:/# vgextend test02 /dev/sdb1 Volume group "test02" successfully extended To save the changes. Command (m for help): w root@test02:/# vgdisplayThe partition table has been altered! --- Volume group ---Calling ioctl() to re-read partition table. VG Nametest02Syncing disks. System ID Formatlvm2 Metadata Areas2 Metadata Sequence No 4 You can take a look at the /proc/partitions le or use the VG Accessread/write fdisk -l command to see the changes to the disk VG Status resizable partition structure of your system: MAX LV0 Cur LV2 root@test02:~# cat /proc/partitions Open LV2 Max PV 0 Cur PV2 Act PV 2 You now need to format the partition, giving it a new VG Size148.77 GB directory structure by using the mkfs command. The Fedora installation procedure defaults to an ext3 type, PE Size4.00 MB which is what you should use here. Total PE 38085 Alloc PE / Size19001 / 74.22 GB root@test02:~# mkfs -t ext3 /dev/sdb1 Free PE / Size 19084 / 74.55 GB VG UUID 9nQQaX-dvOr-1xuf-KkFr-A5jz-Fg0h- martes 17 de agosto de 2010 14. Creating the load balancer and the nodes Create LVM volume for boot partition Mount vm-sharesudo lvcreate -L 1GM -n jboss_boot sudo mount build:/nfs/vm-share /mnt/test02(where test02 is your volume group vm-share (maybe already mounted)name) Create LVM volume for root partitionsudo lvcreate -L 11GM -n jboss_ctrltest02 (where test02 is your volume groupname) Create Swapsudo lvcreate -L 1GM -n jboss_ctrl_swaptest02 (where test02 is your volume groupname) martes 17 de agosto de 2010 15. jboss_ctrljboss_ctrl028d695160-06e3-6af1-03b7-05d368c54aa8uuid&gt; Copy boot system10485764104857610485764104857622 sudo dd if=/mnt/vm-share/images/ hvmhvm fedora-12-dev/fedora-boot.img of=/ dev/test02/jboss_boot Copy root systemdestroydestroyrestart sudo dd if=/mnt/vm-share/images/restartrestartrestart jboss/jboss_ctrl_root.img of=/dev//usr/bin/kvm/usr/bin/kvm test02/jboss_ctrl Copy the node xml le sudo cp /mnt/vm-share/images/jboss/ jboss_ctrl.xml /etc/libvirt/qemu/ jboss_ctrl.xml Edit jboss-ctrl.xml and change the name and update the drive locations to the lvm volumes Also change the network source to point at the new network create above ( in mnt/vm-share/images/ jboss and in /etc/libvirt/qemu), change the name for the le too,and delete the uuid.(the machine generate another one new for each node. martes 17 de agosto de 2010 16. Dene the VM, with the new name ( you should be change before) root@test02:/etc/libvirt/qemu# sudo virsh dene jboss_ctrl02.xml Start the VM root@test02:/etc/libvirt/qemu# sudo virsh start jboss_ctrl02Get the IP address root@test02:~# sudo virsh console jboss_ctrl02 Connecting to uri: qemu:///system Fedora release 12 (Constantine) Kernel 2.6.31.6-162.fc12.x86_64 on an x86_64 (/dev/ttyS0) jboss_ctrl login: Password: Last login: Thu Jun 17 13:38:23 on ttyS0 [test@jboss_ctrl ~]$ ifcong martes 17 de agosto de 2010 17. jboss_ctrl02jboss_node18d695160-06e3-6af1-03b7-05d368c54aa8 Creating theuuid&gt;10485764104857641048576104857622hvmhvm nodesdestroydestroyrestartrestartrestartrestart/usr/bin/kvm/usr/bin/kvm Create new swap partition test02@test02:/$ sudo lvcreate -L 1GM -n jboss_swap1 test02 (where test02 is your volume group name) Create a snapshot of the jboss1's root partition test02@test02:/$ sudo lvcreate -L592M -s -n jboss_node11 /dev/test02/jboss_node1 Use can use the current boot partition Copy the cong le root@test02:~# sudo cp /mnt/vm-share/ images/jboss/jboss_node1.xml /etc/libvirt/ qemu/jboss_node2.xml Edit jboss_node1.xml and change it's name martes 17 de agosto de 2010 18. Dene the VM root@test02:/etc/libvirt/qemu# sudo virsh dene jboss_node1.xml Start the VM root@test02:/etc/libvirt/qemu# virsh start jboss_node1 TO go inside the node1 machine to install harmony root@test02:~# sudo virsh console jboss_node1 login with test/test Get the IP address ifcong and note the ip address Observations, If you want copy in one of the nodes a image, you can use the same commands that we use for the load balancer, butwe need create the space for this image. For the nodes: sudo lvcreate -L 11GM -n jboss_node1 test02 sudo dd if=/mnt/vm-share/images/jboss/jboss_node_rootv1.img of=/dev/test02/jboss_node1 martes 17 de agosto de 2010 19. Run JBoss with Harmony http://en.wikipedia.org/wiki/ tar -zxvf http://apache.mirrors.esat.net/harmony/ JBoss_application_servermilestones/5.0/M14/apache- harmony-5.0-jre-r946978- linux-x86_64-snapshot.tar.gz http://www.jboss.org/ tar -zxvf harmony5 Login as the node user Go to /home/test Jboss is listed here. Then edit the run.conf le in the bin and set JAVA_HOME =$ save and exit (make sure to remove # from JAVA) Download harmony, in the directory /home/test/ wget http://apache.mirrors.esat.net/harmony/milestones/ From the command line execute run.sh in the directory: 5.0/M14/apache-harmony-5.0-jre- r946978-linux- jboss-4.2.3/bin x86_64-snapshot.tar.gz We can change the name of the le, is very large: mv apache................. harmony5 Unzip martes 17 de agosto de 2010 20. When we have Harmony and # The load balancer is the main entry that goes into the child entries worker.list=loadbalancer JBoss running properly: # The load balancer is the main entry that goes# Node1into the child entries worker.jboss1.port=8009worker.list=loadbalancer worker.jboss1.host=192.168.122.104 worker.jboss1.type=ajp13# Node1worker.jboss1.lbfactor=1worker.jboss1.port=8009Go to the directory /etc/httpd and editworker.jboss1.host=192.168.122.184worker.jboss1.type=ajp13 # Node2 worker.jboss2.port=8009workers.propertiesworker.jboss1.lbfactor=1 worker.jboss2.host= 192.168.122.114 worker.jboss2.type=ajp13# Node2worker.jboss2.lbfactor=1worker.jboss2.port=8009worker.jboss2.host=jboss2worker.jboss2.type=ajp3# Node3worker.jboss2.lbfactor=1 worker.jboss3.port=8009 [test@jboss_ctrl ~]$ cd /etc/httpd/ worker.jboss3.host= 192.168.122.72 [test@jboss_ctrl httpd]$ ls# Load balancing behaviourworker.loadbalancer.type=lb worker.jboss3.type=ajp13 worker.jboss3.lbfactor=1 conf conf.d logs modules run workers.propertiesworker.loadbalancer.balance_workers=jboss1 [test@jboss_ctrl httpd]$ nano workers.properties# Load balancing behaviour worker.loadbalancer.type=lb# set sticky to zero so that we are able to test alternation worker.loadbalancer.balance_workers=jboss1worker.loadbalancer.sticky_session=0 worker.loadbalancer.balance_workers=jboss2 worker.loadbalancer.balance_workers=jboss3 # set sticky to zero so that we are able to test alternationMake the following changes in the leworker.loadbalancer.sticky_session=0 martes 17 de agosto de 2010 21. Now you need copy the le testservlet.war from To see if the le is inside, go to the console for the the local machine to host machine node and use to swich off the rewall, make in a off state permanently sudo /etc/init.d/iptables stop [workstation09@workstation09 Desktop]$ scp testservlet.war test@10.2.0.62: To check the conguration of the rewall: sudo /etc/init.d/iptables status The authenticity of host '10.2.0.62 (10.2.0.62)' can't be established. RSA key ngerprint is e9:d2:89:ae:7c:ab:cd:c6:d4:df: Go to the hosts le 3b:ed:42:ab:21:1c.sudo vim /etc/hosts Are you sure you want to continue connecting (yes/ no)? yes Warning: Permanently added '10.2.0.62' (RSA) to the list of known hosts. Insert this line in the le127.0.0.1 test@10.2.0.62's password:localhost.localdomain localhost test02 testservlet.war jboss_ctrl Then from the load balancing machine to each Restart the Apache service node. We should be change...</p>