virtual box creating a base oel image

27
VirtualBox: Creating a Base OEL Image 1 Instruction Guide November 4, 2010 VirtualBox: Creating a Base OEL Image Prepared by Jim Fisher

Upload: sefdeni

Post on 02-Dec-2014

147 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

1

Instruction Guide November 4, 2010

VirtualBox: Creating a Base OEL Image Prepared by Jim Fisher

Page 2: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

2

Contents Contents .................................................................................................................................... 2

Creating an OEL VM under VirtualBox ....................................................................................... 3

Prerequisites .......................................................................................................................... 3

Create the Virtual Disks ............................................................................................................. 4

Create the Virtual Machine ......................................................................................................... 6

Install OEL ................................................................................................................................. 9

Post-Installation Tasks ..............................................................................................................18

Set-up Network Connections .................................................................................................18

Add User to sudoers File .......................................................................................................20

Set-up the Internal Yum Server .............................................................................................20

Correcting the Video Resolution ............................................................................................21

Updating the Packages .........................................................................................................22

Optional Tasks ..........................................................................................................................23

Expanding the Partition Size ..................................................................................................23

Creating a New Disk and Partitions for ASM..........................................................................24

Installing VirtualBox Guest Additions .....................................................................................26

Installing Oracle 11gR2 Database and Grid Infrastructure .....................................................26

Additional References ...............................................................................................................27

Page 3: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

3

Creating an OEL VM under VirtualBox In this tutorial, I will describe how I created an Oracle Enterprise Linux (OEL) virtual machine under VirtualBox. The OEL virtual machine creation process will deviate from a default virtual machine create process in the following way:

1. The OEL virtual machine will use SATA instead of IDE drives. This will increase flexibility and performance.

2. We will use separate virtual disks instead of partitioning a single virtual disk. The separate disks will simplify maintenance and upgrades.

3. The virtual disk will be allocated as a very large dynamic disk. A partition will be created within the virtual disk that uses only a small part of the virtual disk. The virtual disk for example may be created to be a 200 Gb dynamic disk and then we allocate only 5 Gb as a partition, leaving the rest free. Because it is a dynamic disk, there is actually no wasted space. The free space can be used later to expand the partition.

Generally, here are the following steps.

1. Create the Virtual Disks 2. Create the Virtual Machine 3. Install OEL 4. Perform Post-installation Tasks 5. Perform Optional Tasks

You will have to go through the first 4 sections and then depending on what you are trying to do, you may want to execute some of the optional tasks. Finally, please note that version 3.2.8 is the version of VirtualBox that was used to create this tutorial, so there might be some differences depending on which version you use.

Prerequisites

• You must already have installed VirtualBox. VirtualBox is located here: http://www.oracle.com/us/technologies/virtualization/oraclevm/061976.html

• You must download Oracle Enterprise Linux. I recommend getting the DVD ISO download so you don’t have to manage multiple files. This can be found here: http://edelivery.oracle.com/linux

• You should also download a GParted Live ISO or another partition editor to manage your partitions if you plan to expand them at all. GParted can be found here: http://gparted.sourceforge.net

Page 4: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

4

Create the Virtual Disks 1. Launch VirtualBox

2. Select File->Virtual Media Manager.

3. Click New to bring up the “Create New Virtual Disk” wizard. Select dynamic disk on the first screen. On the second screen, enter the name of the your VM and append ”_root” at the end (e.g.: “OEL_root.vdi”). You can set the disk to a large size since it will grow dynamically and you can add partitions at a later point. I would set it to a high number like 200GB. It doesn’t take up much space and it gives you flexibility if you want to expand the partition later on.

Page 5: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

5

4. Repeat the previous step but for this disk, you can create a fixed sized disk. Create a disk named “OEL_swap”. This should be sized at 2X your intended RAM. The max RAM on a 32-bit VM is 1.5GB so I recommend just creating a 3GB disk. Since this is a fixed size disk, the initial file might take a while to create as a 2GB file is created.

5. We are finished with the Media Manager

Page 6: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

6

Create the Virtual Machine 1. In this step, we will create the Virtual Machine. From the home screen, go to Machine-

>New to bring up the “Create New Virtual Machine” wizard. 2. Enter the name of your VM like “OEL Base Image”, select “Linux” for the Operating

System and “Oracle” for the version.

3. On the next screen, you will set your memory requirements. I set mine at 1500MB since I wanted to use it to install the DB and Grid Infrastructure, which requires 1024MB and 1500MB, respectively

4. At the “Virtual Hard Disk” step, uncheck “Boot Hard Disk” and don’t select a hard disk. You will attach the disk later. You will be warned that you didn’t attach a hard disk. Ignore this by clicking “Continue” and click “Finish” on the next screen to complete the wizard.

Page 7: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

7

5. Select the machine you just created and click on “Settings” 6. Click on “Storage”

7. Click on the SATA Controller, then Click Add Hard Disk icon (the one on the right with the plus sign). If you have any other virtual disks that you are managing, they will show up first so click the Add Hard Disk button until your root and swap disks are added. Once they are added, remove the other disks.

Page 8: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

8

8. Click on the root disk and Select SATA port 0 for the Slot drop down. Click on the swap disk and select SATA port 1 for the swap disk.

9. Now you want to add the ISO of the OEL install DVD that you hopefully downloaded already. If you haven’t done that already, you can come back to this screen after it’s downloaded.

10. Click on the Empty text under the IDE controller in the Storage Tree. In the Attributes section, click on the folder icon to the right of th CD/DVD device dropdown box to open the Virtual Media Manager. From there you will be able to browse your file system to locate your ISO. Click on the Add button in the media manager and select the ISO for the Oracle Enterprise Linux. This will add the ISO to the list of available media. Click on the ISO you just added for Oracle Enterprise Linux and click the Select button.

11. At this point, you should have your ISO in the CD-ROM drive and your 2 disks attached to the SATA Controller. Click OK to finish the updates and get back to the main screen.

Page 9: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

9

Install OEL 1. Select the new virtual machine called OEL Base Image and click on the Start button. 2. Once the OEL title screen appears. Press Enter.

3. Click on the Skip test button, or press the right arrow key to highlight “Skip” and press Enter. You might see a popup message about mouse integration.

4. On the OEL splash screen, press Next. You might see a popup message about 24 vs 32 bit color modes, this is ok as we are in the installer.

Page 10: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

10

5. Select the appropriate language and press Next.

6. Select the appropriate keyboard and press Next.

7. You will be warned that sda is unreadable and ask if it can format and erase all of the data. Press Yes (since your new virtual disk has no data).

8. You will be warned that sdb is unreadable and ask if it can format and erase all of the data. Press Yes.

Page 11: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

11

9. On the partition screen, select Create custom layout from the dropdown and press Next.

10. Click on the New button. Set the mount point to “/”. Uncheck all Allowable Drives except sda. Set the size to what you think you will need, we chose 16384MB. Press OK. We are meant to use a small percentage of the virtual disk for the partition. The idea is if we need to a larger disk, we can use a partition program to extend it.

11. Click on the New button. Set the File System type to swap. Uncheck sda so sdb is the only drive checked. Set the size to fill to maximum allowable size since we want to use all of it for swap. Press OK.

Page 12: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

12

12. Press the Next button. 13. You will be prompted to ask if you want to install Grub. Press Next to select the default

option of installing Grub on /dev/sda

14. Press Next to use the active device of eth0 and DHCP.

15. Select the appropriate country and press Next. WARNING: If you plan to run a mix of a Linux VM (as we are in this case) and Windows host machine, make sure you uncheck “System Clock uses UTC”. Press Next.

Page 13: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

13

16. Enter the root password and press Next. Make sure you record this somewhere.

17. You will be prompted to select the software. The system will default to Gnome Desktop. Select the option “Customize Later” and press Next.

18. The installer will check for dependencies and then display a screen telling you to press Next to continue the installation. Press Next.

Page 14: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

14

19. Installation will continue for about half an hour depending on the speed of your environment, and then you are presented with an option to reboot. Click on the reboot button and boot from the hard drive instead of the CD.

20. After reboot, your configuration will continue on a welcome screen. Press Forward.

21. Press Forward to accept the License Agreement

Page 15: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

15

22. Press Forward to accept the default firewall configuration.

23. Set the SELinux setting to “Disabled” (Some Oracle Database issues are caused by having this enabled). Click Yes if you get a popup message about rebooting the system after the first boot is complete. Press Forward to accept.

24. Press Forward to accept the default setting on the Kdump screen.

Page 16: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

16

25. If necessary, change the date and time and press Forward to accept.

26. Enter the info for a user other than root. Since you’ll probably create an oracle user for an install, you should create that here.

27. Press Forward to accept the sound config.

Page 17: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

17

28. On the “Additional CDs” screen, click Finish.

29. The system will now reboot. When it comes back up, login with the user you created above.

Page 18: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

18

Post-Installation Tasks

Set-up Network Connections

• To set up the network proxy for external access while on the Oracle network, go to System->Preferences->Network Proxy and enter www-proxy.us.oracle.com with port 80 in the HTTP proxy line.

• To access the Internet when not on the Oracle network a. Make sure the VM image is using a NAT connection on the network interface b. Go to System->Preferences->Network Proxy and click on the “Direct Internet

Connection” option. c. Go to System->Administration->Network. When there, click on the DNS tab and

clear out the Primary DNS, Secondary DNS, Tertiary DNS, and DNS Search Path. After this is done, you may need to deactivate and then activate the network interface

• To access the Oracle network when connecting remotely, you will have to set up a VPN network from your guest VM image.

a. You will not be able to access the Internet if you connect via VPN with your host OS. Security policies disable this functionality.

Page 19: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

19

b. To set up VPN on your OEL VM, go to http://myaccess.oraclevpn.com and login with your VPN username/password (Note: I had some problems doing this while on the Oracle network so you may want to try when not on the network).

c. Your probably won’t be able to install the VPN client through the initial link so you will be presented with a link to “Linux i386”. That link seems to hang as well so if you right click on that link and choose “Save Link As” so you can save the script.

Page 20: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

20

d. After the script is downloaded, log in as root (su – root) and then run the script

from where it was downloaded (sh ./vpnsetup.sh). Once you get the VPN client installed, you will be able to access the network through the VPN client.

Add User to sudoers File 1. There are a lot of commands that you’ll want to run through “sudo”. To set that up,

switch to root (su – root). 2. We are going to now use vi to edit the file. 3. Open the sudoers file (vi /etc/sudoers) and add the “oracle” line below the root line to

give oracle sudo access. Save the file by going into command mode by pressing the esc key and then typing “:x!” to overwrite read-only permissions.

Set-up the Internal Yum Server 1. If you want to use an internal yum server, you can configure your VM to access. 2. If you are outside the Oracle network, you need to VPN to the network. To do this, go to

System->Internet->Cisco Anywhere VPN client and login with your VPN username/password.

3. Open up the web browser and go to http://kernel.us.oracle.com. Download the appropriate package, which will probably be el5 if you’re using the latest OEL version.

4. Install the downloaded package by running “sudo rpm –Uvh FILENAME” from the directory where it was downloaded

Page 21: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

21

Correcting the Video Resolution

1. On my laptop, the default resolution was set to 800x600. To change this, go to System->Administration->Display and then click on the Hardware tab.

2. Click on Configure… next to Monitor and select “Generic LCD Display” and then “LCD Panel 1280x800”. I choose this resolution as it’s bigger but does not require my whole laptop screen.

3. Edit the X11 config file through “sudo vi /etc/X11/xorg.conf”. In that file, you will need to update the resolution by changing the Modes value to “1280x800”.

4. You probably want to restart at this point to get the updated resolution.

Page 22: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

22

Updating the Packages

1. Go to Applications->System Tools->Unbreakable Linux Network. Click Forward twice to start the process of updating the packages. You may see a popup message regarding a GPG keyring, click Yes to install the key. (Note: You will have to be on the Oracle network for this, either connecting directly from an office or through the VPN on the VM image). You should not need a CSI for this. If you get a popup about this that you can’t get around, you may need to use the internal ULN as opposed to the public ULN.

2. You can then select the kernel package if you want the latest kernel update. On the next screen, check “Select all packages” to install the updates for all packages listed.

Page 23: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

23

Optional Tasks

Expanding the Partition Size

1. If you have followed my instructions, we have created a really large virtual disk, but we really only use a small percentage of the disk. To expand a partition size, you have to use a tool like GParted.

2. Download the GParted ISO from http://gparted.sourceforge.net/download.php 3. Once you have the file and have shut down your VM, set the GParted ISO as mounted

on your CD/DVD drive by clicking on settings in the main screen and going to the Storage Tab.

4. Restart your VM and if the boot sequence is set up correctly, you will be booted to the GParted UI. Select all the defaults during boot up until you get to the following screen.

5. Click on the partition that you want to resize and then click on the Resize/Move button.

Page 24: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

24

6. Once you have set the new size, click on the Apply button. After this is done, click on Exit to exit GParted and reboot your virtual image.

Creating a New Disk and Partitions for ASM

1. If you want to create partitions for use by ASM and you’re ok with using the same disk, close your VM and get back to the main VirtualBox screen.

2. Click on File->Virtual Media Manager. Click on New to add a new virtual disk of dynamically expanding storage. I name the disk “OEL ASM”

Page 25: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

25

3. Go back to the main screen and click on Settings and then Storage. Add the new ASM disk that you created and put it on SATA port 2.

4. You could use GParted for this but if you set up the disk already, you can do this through the terminal. Open a terminal window and switch to root (su – root). Run “fdisk /dev/sdc” or whatever the new device is. Go through the following commands for each ASM disk (I did this 4 times with each disk at 2GB)

5. After creating all the partitions use the “w” command to write the new partitions to disk.

Page 26: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

26

Installing VirtualBox Guest Additions 1. Make sure that you have updated the packages (including the kernel) to the latest

version 2. Install the packages using the following command:

a. sudo yum install binutils gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel

3. Go to Devices->Install Guest Additions. 4. Open up a terminal window and cd to /media. 5. Change directory to the VBOXADDITIONS folder. 6. Run the install program as root.

a. sudo sh ./VBoxLinuxAdditions-x86.run 7. Create the directory that will be used to access the host machine (e.g.:

/home/oracle/shared) 8. Go to Devices->Shared Folders in the VirtualBox window and add the directory on your

host machine that you want to expose to your Guest VM 9. Run the following command as root (where “Desktop” is the name of the directory on

your host and “/home/oracle/shared” is the name on your guest) a. mount –t vboxfs Desktop /home/oracle/shared

Installing Oracle 11gR2 Database and Grid Infrastructure

There are good Oracle by Example instructions to follow to install 11gR2 database and the grid infrastructure. You can find them at the URLs below:

• Grid Infrastructure - http://www.oracle.com/technology/obe/11gr2_db_prod/install/gridinstss/gridinstss.htm

• Oracle Database 11gR2 - http://www.oracle.com/technology/obe/11gr2_db_prod/install/dbinstr2/dbinst.htm

Page 27: Virtual Box Creating a Base OEL Image

VirtualBox: Creating a Base OEL Image

27

Additional References I used some of the following sites to get a lot of my information that I pieced together in this HOWTO:

• Linux Partition HOWTO - http://www.faqs.org/docs/Linux-mini/Partition.html

• Setup Oracle 11gR2 on a centOS 5.4 - http://planetvm.net/blog/?p=1353

• Oracle Enterprise Linux 5 Installation - http://www.oracle-base.com/articles/linux/OracleEnterpriseLinux5Installation.php

• Creating a CentOS virtual machine under Virtualbox - http://paulsiu.wordpress.com/2008/09/08/creating-and-managing-centos-virtual-machine-under-virtualbox/