Practice 2 Creating a CDB Pa ge |1
Practice 2: Creating a CDB
Practice Overview
This practice guides through creating two databases in the appliances that you created in the previous
practice.
In this practice you will perform the following:
• You will create a CDB in the appliance srv1.
• You will create a non-CDB database in the appliance srv2.
• Perform the following configuration settings:
o Enable the automatic database startup and shutdown
o Getting the Enterprise Manager Database Express working in the VM appliance
o Run and test the SQL Developer
Practice Environment Architecture Overview
The following figure is an overview of the appliances that you are going to create in this practice.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |2
Creating CDB Procedure
A. Download the Oracle Database Installation Files and copy it to srv1
1. Download from Oracle site the Oracle Database 12c Release 2 for Linux x86-64 installation files. At
the time of this writing, the installation file size is 3.4 GB and the download link is as the following:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
2. In Oracle VirtualBox, startup srv1
3. In srv1, login as oracle user and open a terminal window.
4. Create a directory to copy the installation files in it:
mkdir ~/source
5. In srv1, using WinScp utility, copy the installation file to the source directory.
6. Unzip the installation file.
7. (optional) Delete the zip file (just to save the disk storage)
8. (optional) In Oracle VirtualBox, create a snapshot of the machine. You will use this snapshot to roll
back the state of the appliance to its initial state, in case the installation was not successful. To create
the snapshot, perform the following:
a. Machine -> Take Snapshot. “Take Snapshot of Virtual Machine” window pops up.
b. In the Snapshot Name field, type "Before Oracle installation"
c. Click on OK
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |3
B. Install the Oracle Database software on srv1
9. Open a Putty session window and connect to srv1 as oracle user.
10. Edit the .bash_profile file and make it as follows. source the file after you make the
modifications on it so that the environment variables got created in the current session.
You may consider taking a backup copy of the existing file.
The last line creates a soft link to the CDB alertlog file.
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_SID=CDB1
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
export TNS_ADMIN=/u01/app/oracle/product/12.2.0.1/db_1/network/admin
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_DATE_FORMAT=dd/mm/yyyy:hh24:mi:ss
ln -sf /u01/app/oracle/diag/rdbms/cdb1/CDB1/trace/alert_CDB1.log alert
11. In the VirtualBox window of srv1, start the installer. You need to source the bash file before you
run the installer so that the OS variables that you defined in the bash file will take effect.
cd
source .bash_profile
cd /home/oracle/source/database
./runInstaller
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |4
12. Respond to the Installer windows as follows:
Window Response
Configure Security Updates • Unmark "I wish to receive security updates.." checkbox.
• Click on Next
• Confirmation Window pops up
• Click on Yes
Installation Option • Select “Install Database Software only”
Database Installation Options • Select “Single instance database installation”
Database Edition • Select “Enterprise Edition”
Installation Location • Keep it to the default
Oracle base: /u01/app/oracle
Oracle Home: /u01/app/oracle/product/12.2.0.1/db_1
Operating System Groups • Set the groups to dba
Install Product • Install
• When prompted, run script as root
• When prompted, Install Oracle Trace File Analyzer
Finish • Click on Close button
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |5
C. Create an Oracle CDB Database in srv1
In this section, you will first configure the listener then create a CDB database.
13. In srv1, start the Oracle Net Configuration Assistant and create a default listener
netca
Listener Configuraiotn -> Add -> LISTENER -> Next -> Next -> No -> Next -> Finish
14. In srv1, as oracle, start the dbca
15. Respond to the Installer windows as follows:
Window Response
Database Operation • Create Database
Creation Mode • Advanced Configuration
Deployment Type • General Purpose or Transaction processing
Database Identification • Global Database Name: CDB1.localdomain
• Sid: CDB1
• Mark “Create as Database Container”
• Mark “Use Local Undo tablespaces for PDBs”
• Create an empty Container database
Storage Option • Select "Use following for the storage attributes"
• Database files storage type: File System
• Database files location:
{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}
• Mark "Use Oracle-Managed Files (OMF)"
Fast Recovery Option • Mark "Specify the Fast Recovery Area"
• Set the "Fast Recovery Area" to:
{ORACLE_BASE}/fra/{DB_UNIQUE_NAME}
• Fast Recovery Area size (approx): 20480 MB
• Unmark "Enable Archiving"
Network Configuration • Make sure the LISTENER is selected
Data Vault Option • Make sure the check boxes are unmarked
Configuration Options • Memory:
• Select "Use Automatic Shared Memory Management"
• SG size: 1653
• PGA size: 552
Sizing:
• Processes: 500
Character sets:
• select "Use Unicode AL32UTF8"
Connection mode:
• Make sure the "Dedicated server mode" is selected
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |6
Management Options • Make sure "Configure Enterprise Manager (EM) database express" is
marked.
Use Credentials • Select "User the same adminstrative password for all accounts"
• Set the password (it has been set to “oracle” in my demonstrations)
Creation Option • Make sure "Create database" is selected.
• Click on the "All Initialization Parameters" button
• Mark "Show advanced parameters"
• Scroll down to nearly the bottom of the parameter list
• Look for the parameter "db_files"
• Set its value to 1000
Summary • click on Finish
16. Test the created CDB by connecting to it using sqlplus:
sqlplus system/oracle@CDB1
17. If all the steps above were implemented successfully, in VirtualBox, delete the VM snapshot of srv1.
Logout from the Putty session then follow the steps as shown in the diagram below.
This step may take five minutes to finish. Meanwhile, you can go to the next step.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |7
Creating a non-CDB Database Procedure
In the following steps you will create a non-CDB database in srv2 machine.
D. Copy Oracle Database Installation files to srv2
18. In Oracle VirtualBox, make sure srv2 appliance is running. Start it up, if it was shutdown.
19. In srv2, login as oracle user and open a terminal window.
20. Create a directory to copy the installation files in it:
mkdir ~/source
21. Using WinScp utility, copy the installation file to the directory
22. Unzip the installation file.
23. (optional) Delete the zip file (just to save the disk storage)
24. (optional) In Oracle VirtualBox, create a snapshot of the machine. You will use this snapshot to roll
back the state of the appliance to its initial state, in case the installation was not successful. To create
the snapshot, perform the following:
a. Machine -> Take Snapshot. “Take Snapshot of Virtual Machine” window pops up.
b. In the Snapshot Name field, type "Before Oracle installation"
c. Click on OK
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |8
E. Install the Oracle Database software on srv1
25. Open a Putty session window and connect to srv2 as oracle user on it.
26. Edit the .bash_profile file and make it as follows.
You may consider taking a backup copy of the existing file.
The last line creates a soft link to the database alertlog file.
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_SID=ORADB
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
export TNS_ADMIN=/u01/app/oracle/product/12.2.0.1/db_1/network/admin
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_DATE_FORMAT=dd/mm/yyyy:hh24:mi:ss
ln -sf /u01/app/oracle/diag/rdbms/oradb/ORADB/trace/alert_ORADB.log alert
27. In the VirtualBox appliance window of srv2, start the installer
cd
source .bash_profile
cd /home/oracle/source/database
./runInstaller
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB Pa ge |9
28. Respond to the Installer windows as follows:
Window Response
Configure Security Updates • Unmark "I wish to receive security updates.." checkbox.
• Click on Next
• Confirmation Window pops up
• Click on Yes
Installation Option • Select “Install Database Software only”
Database Installation Options • Select “Single instance database installation”
Database Edition • Select “Enterprise Edition”
Installation Location • Keep it to the default
Oracle base: /u01/app/oracle
Oracle Home: /u01/app/oracle/product/12.2.0.1/db_1
Operating System Groups • Set the groups to dba
Install Product • Install
• When prompted, run script as root
• When prompted, Install Oracle Trace File Analyzer
Finish • Click on Close button
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 10
F. Create an Oracle non-CDB Database in srv2
In this section, you will first configure the listener then create a non-CDB database.
29. In srv2, start the Oracle Net Configuration Assistant and create a default listener
netca
Listener Configuraiotn -> Add -> LISTENER -> Next -> Next -> No -> Next -> Finish
30. In srv2, as oracle, start the dbca
31. Respond to the Installer windows as follows:
Window Response
Database Operation • Create Database
Creation Mode • Advanced Configuration
Deployment Type • General Purpose or Transaction processing
Database Identification • Global Database Name: ORADB.localdomain
• Sid: ORADB
• UnMark “Create as Database Container”
Storage Option • Select "Use following for the storage attributes"
• Database files storage type: File System
• Database files location:
{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}
• Mark "Use Oracle-Managed Files (OMF)"
Fast Recovery Option • Mark "Specify the Fast Recovery Area"
• Set the "Fast Recovery Area" to:
{ORACLE_BASE}/fra/{DB_UNIQUE_NAME}
• Fast Recovery Area size (approx): 8016 MB
• Unmark "Enable Archiving"
Network Configuration • Make sure the LISTENER is selected
Data Vault Option • Make sure the check boxes are unmarked
Configuration Options • Memory:
• Select "Use Automatic Shared Memory Management"
• SG size: 1653
• PGA size: 552
Sizing:
• Processes: 300
Character sets:
• select "Use Unicode AL32UTF8"
Connection mode:
• Make sure the "Dedicated server mode" is selected
Sample Schemas
• Mark “Add sample schemas to the database”
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 11
Management Options • Unmake "Configure Enterprise Manager (EM) database express"
Use Credentials • Select "User the same adminstrative password for all accounts"
• Set the password (it has been set to “oracle” in my demonstrations)
Creation Option • Make sure "Create database" is selected.
Summary • click on Finish
32. Test the created non-CDB by connecting to it using sqlplus:
sqlplus system/oracle@oradb
33. If all the steps above were implemented successfully, in VirtualBox, logout from the Putty session and
delete the VM snapshot of srv2. This step may take five minutes to finish.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 12
G. Set the tns Naming configuration
34. In both appliances, enable the tnsnaming and easy connect methods in the sqlnet.ora file.
vi /u01/app/oracle/product/12.2.0.1/db_1/network/admin/sqlnet.ora
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
35. Edit the tnsnames.ora file in each system so that they can connect to each database.
Do not copy paste from the PDB file. Either copy from the downloadable tnsnames.ora file, or from
the Putty session window itself.
vi $TNS_ADMIN/tnsnames.ora
CDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = srv1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = CDB1.localdomain)
)
)
ORADB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = srv2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORADB.localdomain)
)
)
36. Test the configuration
sqlplus system/oracle@cdb1
sqlplus system/oracle@oradb
37. (optional) In both appliances, add the following sqlplus variable setting to its auto login script.
vi $ORACLE_HOME/sqlplus/admin/glogin.sql
set timing on
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 13
H. Automating Database Startup and Shutdown (optional)
In the following steps you will configure the appliances so that their databases are automatically
started up when you start the appliance and automatically shut 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.
38. Login as root to srv1
39. Edit the oratab file
vi /etc/oratab
40. Change the last field for the database line to Y
CDB1:/u01/app/oracle/product/12.2.0.1/db_1:Y
41. 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.1/db_1
ORA_OWNER=oracle
case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
# 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:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME" &
rm -f /var/lock/subsys/dbora
;;
esac
42. Change the group of the dbora file to dba, and set the permissions to 750
chgrp dba /etc/init.d/dbora
chmod 750 /etc/init.d/dbora
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 14
43. 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
44. Restart the appliances to test the configuration.
45. Verify that the database is up and running automatically after restarting the appliance:
sqlplus system/oracle
46. In srv2, repeat all the steps in this section.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 15
I. Getting the Enterprise Manager Database Express Working in the VM
You configured the Enterprise Manager Database Express when created the CDB. However,
the Mozilla Firefox browser that is pre-installed in the VM machine does not have the Adobe
Flash plug-in that is needed to display the EM Database Express. In this section of the practice,
you will install the Adobe Flash plug-in in the browser and then open the EM Database Express.
47. In the VirtualBox window of srv1, login as oracle user.
48. Open the Mozilla Firefox browser and try opening the EM Database Express page using the
following URL address:
https://srv1:5500/em/login
49. You will receive a warning message about trusting the URL source, as follows:
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 16
50. Click on the “Add Exception” button. You will see the following message popping up:
51. Click on the “Confirm Security Exception” button.
52. You will see the following message in the browser:
53. If your VM appliance has access to the Internet, go to next step. If you VM appliance does
not have a connection to the Internet, you can install the Flash plug-in manually by
performing the following steps:
a. Download the file “flash_player_npapi_linux.x86_64.tar.gz” from the lecture
downloadable resources.
b. Copy the file flash_player_npapi_linux.x86_64.tar.gz to the directory
/home/oracle/source
c. Connect via Putty to the machine srv1 as root
d. Extract the file
tar -xvzf flash_player_npapi_linux.x86_64.tar.gz
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 17
e. Copy the extracted so file to the plug-ins directory
cp /home/oracle/source/libflashplayer.so /usr/lib64/mozilla/plugins
f. Change the permissions of the file as follows:
chmod 775 libflashplayer.so /usr/lib64/mozilla/plugins/libflashplayer.so
54. In the following steps you will download and install the Flash plug-in in the FireFox browser
in srv1 machine. Those steps assume that the machine has a connection to the Internet:
a. In the message that appeared to you, click on “GetFlash” link
b. The page that follows appears in the browser. Select “.rpm for Linux” option from the
drop list then click on Download button.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 18
c. The following message appears to you. Click on OK button.
d. The following message appears to you. Click on Install button.
e. The following message appears to you. Enter the root password then click on
Authenticate button
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 19
55. After the Flash plugin got installed, you should be able to see the EM Database Express
page as follows. Enter the sys username, its password, leave the container name blank,
mark the “as sysdba” option then click on Login button.
56. You should see the EM Database Express opening and displaying a page similar to the following:
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 20
J. Running and Testing the SQL Developer
SQL Developer is a GUI interface to the database that is automatically installed with the Oracle
database software. In this section of the practice you will created a shortcut of the utility on the
desktop, run the utility, and test it to connect to the CDB.
57. Login to the VM appliance srv1 in VirtualBox as oracle.
58. Double click on the “Computer” icon.
59. Navigate all the way to the following path:
/u01/app/oracle/product/12.2.0.1/db_1/sqldeveloper/
60. In the window of the “sqldeveloper”, double-click on the “sqldeveloper.sh” file, as shown in
the following screenshot:
61. Double click on the icon.
62. You should see a message like the following. Click on Run button. The SQL Developer should start
up.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 21
63. Right click on the Connections node and select “New Connection”, as shown in the screenshot
below:
64. Fill in the form as shown in the following screenshot. Click on Test then Save buttons.
65. Click on Connect button.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 22
66. In the Query builder windows, write the query as shown in the following screenshot. Execute it by
pressing on F9 key.
67. Create another connection to CDB1 in the DBA panel, as shown in the following screenshot.
If the DBA panel is not displaying, click on View menu then select DBA menu item.
68. You should see the following message. Click on OK button. You should see the connection added
under the connections node.
69. Close the SQL Developer
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka
Practice 2 Creating a CDB P a g e | 23
Summary
By end of this practice, you should have two Linux-based Oracle VirtualBox appliances:
• srv1 which has an Oracle 12.2 CDB database named CDB1 created in it. This appliance will be
mainly used throughout the course practices.
• srv2 which has an Oracle 12.2 non-CDB database named ORADB created in it.
You also have configured both appliances to automatically start up their databases when their
appliances are rebooted.
Oracle 12c Multitenant Architecture Administration, a course by Ahmed Baraka