Practice 1 - Preparing Practice Environment
Practice 1 - Preparing Practice Environment
Practice 1
Practice Target
This practice guides you to prepare the environment that you will use in the course practices. The
practices in the course were designed using Oracle VirtualBox appliances (virtual machine). You will
build the following virtual machine:
• Linux-based appliance
This machine is a Linux 6.7 x64-bit based with Oracle database 12c R2 database installed
on it.
Note: this practice assumes that you have the knowledge to perform the basic tasks on Oracle
VirtualBox.
Practice Overview
In high level, in this practice, you will perform the following tasks:
• Install Oracle database software (12.2) in srv1 and create an Oracle Database (named ORADB) in
it
What if you already have srv1 virtual machine with ORADB database?
If you already have the virtual machine srv1 with the database ORADB (probably from other courses),
you can use it for this course. You only have to perform the steps in the following sections:
• Set up Order Entry Schema (soe)
• Install Swingbench in the hosting PC
• Installing stress RPM
Oracle VirtualBox, software Software to create virtual machines (called virtual appliances)
release 5.1.x Note: You can use Oracle VirtualBox release 5.2.x. But there
will be difference between it and the screenshots used in the
course practice documents.
Swingbench 2.5 software Download Swingbench from one of the following sources:
• Course downloadable resources section
OR
• Dominic Giles portal
Java Runtime for software Java runtime JRE 1.8 should be installed on your hosting PC. It
Windows will be used by the Swingbench software
(optional)
Can be downloaded from this link.
In the following steps, you will create an Oracle VirtualBox Linux appliance.
2. Create a Linux-based VirtualBox appliance with the specifications as shown in the table below.
• You can download pre-built appliance from my website at this link (its size is 3.3 GB). This is
an Oracle VirtualBox appliance which has a fresh installation of Oracle Linux 6.7 installed on it.
Please read the readme file on my web site to obtain details about the appliance including
the root password.
OR
• You can create the VirtualBox appliance from scratch. The procedure to create it from scratch
is documented here, or you can watch it in my channel at YouTube here.
Item Value
Hostname srv1
Memory 4 GB
Operating system Oracle Linux 6.7
3. If you use the pre-built VirtualBox appliance, make sure to disable the Linux Automatic Update by
performing the following: login as root -> System -> Preferences -> Software updates:
Check for updates: Never, Automatically install: Nothing
Linux Automatic Update makes an update on the virtual machine that conflicts with downloaded
Oracle software release.
Note: Implement this action twice. Once after logging on as root and another time after logging
on as oracle.
4. If you are using a pre-built copy of the virtual machine (like the one available in my web site),
make sure the Guest Additions version is upgraded to the version of the VirtualBox you are using.
The pre-built virtual machine that is available in my site was created using version 5.1.12. If you
are using a later version of Oracle VirtualBox, you should update its VirtualBox Guest Additions.
To Update the VirtualBox Guest Additions in the virtual machine, perform the following steps:
a. In the VirtualBox window, login as root and click on Devices menu | Insert Guest Additions
CD image.
e. Right click on the VirtualBox Additions CD icon and select Eject option.
5. Shutdown srv1 and click on Settings -> click on "Network" link from the left hand side pane ->
click on "Adapter 1" tab -> set "Attached to" to "Bridged Adapter".
b. Disable the audio card using "Audio" link (optional). Then press "OK" button.
7. If you have a firewall software installed into your hosting PC, configure it to allow the traffic to go
to and come from Oracle VirtualBox application or disable it.
9. Make sure the firewall is disabled: Linux Main menu | System | Administration | Firewall. Click
on Disable icon, then on Apply button.
b. Click on eth0, Edit button, make sure the "Connect automatically" check box is marked,
Change its “Connection Name” to eth0.
c. Click on IPv4 Settings tab, make sure the method is set to "Automatic (DHCP)". This
adapter will take its IP address from your network and it should get the connection to the
Internet through this connection.
e. Open a terminal window and obtain the IP address assigned to eth0 and take a note of it.
ifconfig
f. Make sure that the VM machine is connected to the Internet, ping google.com
ping -c 3 google.com
11. In srv1 appliance, configure the /etc/hosts file as follows. Replace the IP addresses in the code
with the IP address of your environment.
vi /etc/hosts
12. In the hosting PC, make sure srv1 replies to the ping command.
ping 192.168.1.133
C. Configure Putty
In the following steps you will create a staging directory in the hosting PC. This directory will be
accessed by the VirtualBox appliance srv1. It will be used to exchange files between the VM appliance
and the hosting PC.
18. In your hosting machine, under the disk drive letter that has the most free disk space, create a
staging directory.
The code examples in the practice document assumes that the staging directory is as follows.
Whenever you see in the practice steps a reference to this directory, replace it with the one that
you created in your PC.
D:\staging\Linux
19. In VirtualBox Manager, open the "Settings" of srv1, click on "Shared Folders" link in the
right-hand pane. Add shared folder by pressing "plus" icon. Then select path to
D:\staging\Linux, and mark the "Auto-mount" box. Change the "Folder Name" to "extdisk"
20. Start srv1 and add oracle to vboxsf group. This group has privilege to access the shared folder.
a. In the VirtualBox window, login as root
b. Open a terminal window and execute the following command to make sure the shared folder
is seen by the appliance:
ls -ld /media/sf_extdisk/
Note: In all the course practices, the directory that you created in this section is referred to as the
staging directory.
22. Change the oracle password. If you know oracle user password, there is no need to execute this
step.
passwd oracle
mv ~/.bash_profile ~/.bash_profile_bk
vi ~/.bash_profile
# .bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
25. Extract the installation file into the Linux staging directory D:\staging\Linux
27. Make sure to disable the Linux Automatic Update by performing the following: System ->
Preferences -> Software updates: Check for updates: Never, Automatically install: Nothing
Note: This step has been implemented for root and it is implemented again in this step for
oracle user.
28. Open a terminal window, change the current directory to the staging directory, and start the
installer. If you are already logged on as oracle source the bash file before you run the installer.
cd
source .bash_profile
cd /media/sf_extdisk/12.2/database
./runInstaller
In the following steps you will create a database (named ORADB) in srv1.
30. Start the Oracle Net Configuration Assistant and create a default listener
netca
Listener Configuraiotn -> Add -> LISTENER -> Next -> Next -> No -> Next -> Finish
Window Response
Data Vault Option Make sure the check boxes are unmarked
Use Credentials Select "User the same administrative password for all
accounts"
Set the password (it has been set to "oracle" in my
demonstrations)
In the following steps you will configure srv1 so that the database automatically starts up when you
start the appliance and automatically shuts down when you shut down the appliance.
Note: this procedure is applicable in our case because the Oracle Restart has not been configured. If
the Oracle Restart was configured, you would have followed different procedure.
37. Create the file /etc/init.d/dbora and add the following code in it:
#! /bin/sh
# description: Oracle auto start-stop script.
ORA_HOME=/u01/app/oracle/product/12.2.0/db_1
ORA_OWNER=oracle
case "$1" in
'start')
# Start the Oracle databases:
# Remove "&" if you don't want startup as a background process.
su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME" &
touch /var/lock/subsys/dbora
;;
'stop')
# Stop the Oracle databases:
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" &
rm -f /var/lock/subsys/dbora
;;
esac
38. Change the group of the dbora file to dba, and set its permissions to 750
chgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbora
39. Create symbolic links to the dbora script in the appropriate run-level script directories
ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
40. Restart srv1 and wait for a few minutes to allow the database to automatically start up.
41. Login as oracle to srv1 and verify that the database has automatically started.
ps -ef | grep pmon
sqlplus / as sysdba
Note: If you successfully reached to this point of the practice, I recommend taking a snapshot of the
virtual appliance at this stage. It helps you to recover back in case you faced any issue in the
upcoming steps. If you do not know how to create a snapshot in Oracle VirtualBox, do not worry. You
will learn about it soon in this practice.
42. In srv1, enable the tnsnaming and easy connect methods in the sqlnet.ora file.
vi $ORACLE_HOME/network/admin/sqlnet.ora
44. In your hosting PC, configure the connection to ORADB in the tnsnames.ora file. Replace the IP
address below with the IP address in your environment.
Do not copy the configuration from the PDF file. Copy it from the attached tnsnames.ora file.
Observe that it uses the IP address for defining the hostname. We have to use the IP address
because srv1 hostname is not defined in the hosting PC.
notepad D:\oracle\product\12.1.0\client_1\network\admin\tnsnames.ora
You will download a data pump dump file that contains the soe schema and import it into ORADB.
Caution: If you already have soe schema in your database, the script below will drop it and replace it
with the new schema.
46. Download the script create_soe.sql from the downloadable resources section of the lecture.
The script creates a tablespace (SOETBS), the user (soe), and the schema objects.
51. Download the data pump dump file (its size is 88 MB) from any of the following links. The file is
compressed in zip format the it requires Oracle database release 12.2
Download Link1 - Download Link2 - The Downloadable Resources section of this
lecture
Note: If your database is of release 12.1, please obtain the dump file from the following download
link. The 12.1 dump file is not available in the “Downloadable Resources’ section of this lecture. The
password to extract the file is Ahmed@Baraka
12.1 Download Link
54. Move the dump file to the default data pump directory
host mv /media/sf_extdisk/soe.dmp /u01/app/oracle/admin/ORADB/dpdump/
55. Import the data pump dump file into soe schema.
host impdp soe/soe directory=DATA_PUMP_DIR dumpfile=soe.dmp
56. If the import succeeds, delete the dump file and the script file.
host rm /u01/app/oracle/admin/ORADB/dpdump/soe.dmp
host rm /media/sf_extdisk/create_soe.sql
57. Verify the schema and its objects were successfully created. 49 Objects should be imported.
conn soe/soe
SELECT COUNT(*), SUM(BYTES/1024/1024) MB FROM USER_SEGMENTS;
Note: the ERD diagram of the soe schema is available in the downloadable resources section.
Install Swingbench
In this section of the practice, you will install Swingbench 2.5. You will configure the program to
connect to soe schema that you created earlier. You will also create two Swingbench configuration
files and save them. They will be used in the course future practices.
Note: At the time of this writing, the latest version of Swingbench is 2.6. Personally, I faced issues
with it and therefore prefer to use the stable version 2.5 in the course practices.
Installing Swingbench
58. In your hosting PC, copy the software zip file to the disk drive where you want to install the
software. In my case, I copied it to the D: drive.
59. Extract the zip file. The files will be automatically extracted to the following path. This folder will
be referred to as $SWINGHOME folder.
<disk drive letter>:\swingbench
60. In the hosting PC, open a command prompt window and change the directory to
$SWINGHOME\winbin
cd D:\swingbench\winbin
Caution: Do not start the “Order Entry Wizard” (oewizard). The soe schema has already be setup in
the preceding section.
62. Under the User Details tab, you define the connection details to the database. Set its fields to
the values as in the following screenshot:
63. Click on "Test Connection" button to test the database connection settings. You should see a
message indicating that the connection is successful.
64. Under the Load tab, change the Number of Users to 10. This value sets the number of sessions
that the utility will create when you start the benchmark run.
66. Observe that the "Transactions Per Minute" chart is increasing by time and it eventually gets
saturated.
67. Observe the Response Time chart and its average value. This represents in general the overall
application performance. The higher the response time, the worse.
In the following steps, you will create two Swingbench configuration files. One represents the normal
OLTP workload and the other represents the normal warehouse processing workload.
69. Set the load ratios in the operations under the Transactions tab as follows. The OLTP operations
are selected.
Note: In my testing case, when I enter the numbers directly in the ratio fields, the numbers
change automatically to its old value once the cursor leaves the field. It is better to change the
field value by clicking on the up and down arrows of the field.
71. Save the Benchmark settings as oltp.xml file by clicking on File menu | Save BenchMark As.
This file will be used whenever we want to start an OLTP benchmark stress sessions from
Swingbench.
72. Set the load ratios in the operations under the Transactions tab as follows. The warehouse
operations are selected.
73. Save the Benchmark settings as warehouse.xml file by clicking on File menu | Save BenchMark
As. This file will be used whenever we want to start an warehouse benchmark stress sessions
from Swingbench.
su -
rpm -ivh /media/sf_extdisk/stress-1.0.4-6.1.x86_64.rpm
a. Machine -> Take Snapshot. “Take Snapshot of Virtual Machine” window pops up.
b. In the Snapshot Name field, type any description like "Before Oracle installation"
c. Click on OK
81. If implementing the practice was successful, you can delete the snapshot. Perform the
steps illustrated in the following screenshot:
82. If you face an issue that cannot be resolved, you can restore the appliance to the
snapshot state. Perform the steps illustrated in the following screenshot:
Note: If the snapshot was taken when the machine was on, and if you then restore the
machine from that snapshot, the machine resumes its operation using the date and
time at which the snapshot was taken.
Summary
By the end of this practice, you should have a VirtualBox appliance with the following specifications:
Hostname……………….………: srv1