Tuesday, April 19, 2011

Installing a Guest Operating System on a Virtual Machine

Virtualization has been widely accepted as a technique to conserve resources. Virtualization is the process of running a guest operating system on a virtual machine, which is created in a virtualizer running on the host operating system. Large companies do not have to install 100 different host computers for its employees as they may create 100 different virtual machines running different guest operating systems on a single host computer.
VMware is one of the main vendors of Linux virtualization solutions. VMware Player may be used to run 32-bit and 64-bit Linux operating systems including openSUSE, RHEL 5, and Ubuntu. VMware also offers Virtual Appliances, which are prebuilt software solutions comprising of virtual machine/s. Virtual Appliances are available for Ubuntu, Red Hat and openSUSE, though an appliance for the latest versions may not be available. For the latest version of openSuse, 11.2, it is recommended to install the openSUSE directly onto the VMware Player. In this article we shall install Oracle database XE in openSuse 11.2 as a guest operating system running in a virtual machine (VM) on a Windows host operating system.
Using Oracle database XE with openSuse 11.2 in VMPlayer requires the following:
  1. Install VMPlayer
  2. Create a virtual machine and install openSUSE 11.2 on the VM
  3. Install Oracle database in openSUSE 11.2
  4. Add user to dba group
  5. Create initialization initXE.ora file
  6. Grant write access to intiXE.ora
  7. Start database instance in NOMOUNT
  8. Modify DB_NAME parameter
  9. Restart database instance in NOMOUNT
  10. Create database
  11. Create database table
  12. Create data dictionary views
Installing VMware Player
Create three folders - openSuse, vmplayer and VMs - for installing openSuse ISO, VMPlayer, and an openSuse virtual machine. First, we need to download the latest version of VMPlayer to the vmplayer folder. The VMPlayer is just an .exe file. Double-click on the .exe file and the VMware Player Setup Wizard gets started.
Click on Next in the Welcome window. Specify the Destination Folder (C:\vmplayer for example) to install the VMware Player. Click on Next. In the Ready to Perform the Requested Operations window click on Continue. The VMware installation gets started. When the installation is completed, the Setup Wizard prompts for restarting the system to complete the installation. Click on Restart Now. After the system has been restarted, the VMware Player installation is completed.
Creating a Virtual Machine
Next, download the openSUSE 11.2 Live KDE ISO (openSUSE-11.2-KDE4-LiveCD-i686.iso) to the openSuse folder. Open the VMware Player. Click on Create a New Virtual Machine to create an openSUSE 11.2 virtual machine as shown in Figure 1.
The New Virtual Machine Wizard gets started. Select the Installer disc image file (iso) radio button and select the openSUSE 11.2 KDE ISO file as shown in Figure 2. Click on Next.
Select a guest operating system as Linux and a version as OpenSUSE as in Figure 3. Click on Next.
Specify a name for the virtual machine and specify the Location of the VM as the VMs directory. Click on Next. Specify the disk size as 40.0 GB and select Split virtual disk into 2GB files as in Figure 4. Click on Next.
Select the memory allocated to the VM. By default one processor is configured. Configure the Network Adapter as Bridged with Replicate physical network connection state as in Figure 5.
Click on Finish to create the openSUSE 11.2 VM and start the installation.
Installing openSUSE 11.2 in the Virtual Machine
After the virtual machine gets created, select Installation in the OpenSUSE Installer boot screen as in Figure 6.
In the Welcome window the license agreement is displayed. Click on Next. Select Time Zone and click on Next. In the Suggested Partitioning window Partition Based is selected by default. Click on Edit Partition Setup. In the Expert Partitioner the Available Storage on Linux gets listed for the different partitions of the VMware type /dev/sda hard disk as in Figure 7. Click on Accept.
Click on Next as in Figure 8.
In the User Settings, create a new user with the Create New User wizard. Click Next. In Installation Settings, review the installation summary and click Install. In the Confirm Installation window click Install. The installation gets started.
After the installation is completed, the system needs to reboot as shown in Figure 9.
The initial booting of openSUSE 11.2 gets completed. Next, the automatic configuration of openSUSE 11.2 gets performed. The openSUSE 11.2 VM gets created and installed as shown in Figure 10.
Installing Oracle Database XE in openSUSE 11.2
Next, we install the Oracle database XE in the openSUSE 11.2 VM. To start the openSUSE 11.2 VM click on Play virtual machine. Select VM > Install VMWare Tools to install VMware Tools. In the openSUSE login window specify the Username and Password.
The VMPlayer Desktop is displayed, as shown in Figure 11.
 Download the Oracle database XE for Linux. Start the Dolphin file manager. Select the Download folder. Right-click on the oracle-xe rpm and select Open with Install Software. Specify a password for the root user and click on OK. The Software Manager will start. Oracle Database 10g XE will be installed.
Adding a User to the dba Group
Next, we test the newly installed database by starting the database. First, start the application launcher. In the application launcher search for Oracle and start the database with Start Database. An error will be generated, "Operation failed. dvohra11 is not a member of ‘dba' group. We need to add the user dvohra11 to the ‘dba' group. In the application launcher select the command line Terminal Konsole. The openSUSE terminal will start the Bash shell. Log in to the openSUSE 11.2 with root privileges with the su command. Add user dvohra11 to the ‘dba' group with the following command as shown in Figure 12.
usermod  -G dba dvohra11
Start the SQL Command line. Having added the user to the ‘dba' group, you will be able to connect as sys to an idle instance.
Creating an Initialization File initXE.ora
Before we create a database and a table, we need to create an initialization file from which the initialization parameters are read. For an ‘XE' SID we need an initXE.ora initialization file. We'll create the initXE.ora file by making a copy of the init.ora file in the directory /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/dbs. In the bash shell cd to the //dbs directory. Create the initXE.ora file with the following command as shown in Figure 13.
cp init.ora initXE.ora

Next, grant write permissions to initXE.ora with the following command.
chmod g+w initXE.ora
Starting Database Instance in NOMOUNT
To create a database and a table start the database instance with the STARTUP command. Because control files are not yet available, an error will be generated indicating we need to start the instance in NOMOUNT. Start up the instance with the following command:
STARTUP NOMOUNT
The Oracle instance gets started.
Modifying DB_NAME Parameter
Next, we will create a database with the CREATE DATABASE command:
CREATE DATABASE ORAXE
An error is generated:
CREATE DATABASE failed
database name ‘ORAXE' does not match parameter db_name ‘DEFAULT'
We need to modify the static initialization parameter DB_NAME to the database name we want to create. Static parameters are modified with the ALTER SYSTEM command with scope set to ‘SPFILE'. Start the database in NOMOUNT and set the db_name parameter with the following command:
ALTER SYSTEM SET db_name='ORCLXE' scope=spfile
Static parameters require an instance restart when modified for the modification to take effect. Shut down the instance with the SHUTDOWN command as shown in Figure 14.
Restart the instance in NOMOUNT and verify that the DB_NAME parameter has been modified with the SHOW PARAMETER command.
Creating a Database
Having set the DB_NAME parameter to ORCLXE, create a database with the following command.
CREATE DATABASE ORCLEXE
The database gets created and mounted and opened as shown in Figure 15.
Creating a Database Table
Next, create a database table with the CREATE TABLE command. Shut down the instance with the SHUTDOWN command.
Creating Data Dictionary Views
We also need to create the data dictionary views with the following commands:
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
A VM may be shut down by selecting VM > Power > Power Off. As a best practice, don't shut down the VMPlayer without shutting down the VM. Similarly, multiple virtual machines may be added to the VMPlayer.

No comments:

Post a Comment