0% found this document useful (0 votes)
17 views

Practice - Creating Oracle Database with ASM

This document outlines the steps to create an Oracle Database 19c using Automatic Storage Management (ASM) within an Oracle VirtualBox environment. Key tasks include downloading necessary software, configuring a virtual machine, setting up environment variables, installing ASM packages, and creating ASM disk volumes. The practice emphasizes the importance of memory allocation and proper configuration of user accounts for successful installation and operation of the database system.

Uploaded by

石泽森
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Practice - Creating Oracle Database with ASM

This document outlines the steps to create an Oracle Database 19c using Automatic Storage Management (ASM) within an Oracle VirtualBox environment. Key tasks include downloading necessary software, configuring a virtual machine, setting up environment variables, installing ASM packages, and creating ASM disk volumes. The practice emphasizes the importance of memory allocation and proper configuration of user accounts for successful installation and operation of the database system.

Uploaded by

石泽森
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Practice: Creating Oracle Database with ASM P a g e |1

Practice

Creating Oracle Database with ASM

Practice Target
In this practice you will create an Oracle database 19c with ASM.

Practice Overview
In high level, in this practice, you will perform the following tasks:

• Download Oracle Grid Infrastructure 19c software


• Create and configure an Oracle VirtualBox appliance
• Create virtual hardisks for ASM
• Setup the required environment variables for OS Accounts: grid and oracle
• Install the required ASM packages and create ASM disk volumes
• Change the required Kernel parameter values
• Install Oracle Grid Infrastructure software
• Create an ASM Disk Group
• Install Oracle database software and create an ASM-based database
• Check on Oracle Restart components and functionality
• Retrieve information about ASM
• Get started with asmcmd
• Create a tablespace in ASM

Note: In this practice, you will not use srv1 machine that we used across the course practices. You
will create a new vm (still its host name will be srv1) from the seed vm and use it for creating an
ASM-based database.
Note: Because the machine will have two instances running in it, it requires more memory in it. You
will configure the vm with a memory size 8G. This means the memory in your PC should be at least
12G.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |2

Installation Architecture
In this practice, you will build a system the same as the following architecture diagram:

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |3

Downloading Oracle Grid Infrastructure 19c Software

1. Download Oracle Grid Infrastructure 19c (19.3) installation file for Linux x86-64 from this link. It
is a 2.8 GB file. Copy or move the file to the sharing folder.

Alternatively, download the installation file from Oracle website. Just make sure you download
Oracle Grid Infrastructure 19.3 for Linux x86-64.

The file name is LINUX.X64_193000_grid_home.zip

2. We assume you already have Oracle database 19c (19.3) software installation files that you used
to install Oracle database software in the other course practices so far. If not, download it from
this link. It is a 3G compressed file. Copy or move the file to the sharing folder.

The file name is LINUX.X64_193000_db_home.zip

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |4

Creating and Configuring an Oracle VirtualBox Appliance


In the following steps, you will create an Oracle VirtualBox Linux appliance by cloning the seed vm.

3. In Oracle VirtualBox, make sure that the vm “Linux7-seed” is added and turned off. If not, add it
to Oracle VirtualBox Manager.
“Linux7-seed” is a vm that you imported into VirtualBox in the first course practice. In that
practice, the Guest Additions were updated in that vm and its network was configured.

4. Right click on the vm and select Clone command (shortcut [Ctrl]+[o])

5. Change the Name to srv1-asm then click on Next.


Note: This is not the hostname.

6. Click on Clone button.

7. After the cloning is finished, open the settings of the cloned mv

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |5

8. Change its allocated memory size to 8 GB, as follows:

9. Click on OK button then start the vm

10. Login to the vm as root

11. Open the network settings of the VM. Obtain the IP address assigned to the VM. Make it a static
IP address.

Click on Applications > System Tools > Settings > Network > under the Wired section
click on the Gear button > highlight the IP address from the under the Details tab > right-click
on the highlighted IP and select Copy command

> click on IPv4 tab > IPv4 Method to Manual > Paste the IP address into the Address field >
set the Netmask to 255.255.255.0 > and the Gateway to 192.168.1.1

> click on Apply button

Note: Under the Wired section, you might not see any Network Profile configured. Simply, click
on the plus button beside the "Wired" label, select the MAC address from the dropdown list,
then click on Add button, as shown in the following screenshot:

12. Turn off the network adapter then turn it on again, then close the Settings window.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |6

13. In the hosting PC, open the command prompt and ping the vm IP address to make sure it is seen
by the PC.

14. In srv1, open a terminal window then open the hosts file with vi editor.
vi /etc/hosts

15. Insert into it the following line. Replace the <ip address> with the IP address of srv1
<ip address> srv1 srv1.localdomain

16. Ping srv1 to make sure the changes take effect.


ping -c 3 srv1

17. Configure a connection to srv1-asm in Putty.

srv1-asm is the vm name in VirtualBox. srv1 is its hostname.

Tip: In Putty, instead of creating a connection configuration for the vm from scratch, load the
settings of srv1, change its configured IP address to match the IP address of the new vm, give
the changed configuration the name "srv1-asm" and save it.

18. Open the connection and test it by connecting to srv1 as root

19. If everything goes fine, shutdown the vm.


shutdown -h now

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |7

Creating Virtual Hardisks for ASM


In OracleVirtualBox manager window, perform the following steps on srv1 to create two ASM disks:
OCRDISK1 (12 GB) and DATADISK1 (12GB)

20. Open the settings of srv1

21. Click on Storage then Add “hard disk“ button

22. Click on Create button as follows:

23. Select VDI option

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |8

24. Select Dynamically allocated

25. Set the OCR disk file name and its size.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e |9

26. Select the OCRDISK1.vdi and click on Add button to attach the disk to the vm.

27. Perform the same steps again to create the DATA disk, of size 12G. You should end up with
having two disks as follows:

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 10

28. Optionally, set a description for the appliance, then click on OK button

29. Start the vm and connect to it via Putty as root

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 11

Setting up Environment Variables for OS Accounts: grid and oracle


In the following steps, you will configure the OS variables for the software owner accounts. oracle is
the software owner of the database software and grid is the software owner of the Grid Infrastructure
software.

30. In the Putty session, switch current user to oracle and make a backup copy of the current bash
profile file:
Note: If you are working in a system where oracle user is not there, you need to create oracle
user and oinstall and dba groups. oinstall is the login group for oracle.
su - oracle
mv ~/.bash_profile ~/.bash_profile_bkp

31. Open the .bash_profile file with the vi editor


vi ~/.bash_profile

32. Add the following lines to it.


# .bash_profile

# OS User: oracle
# Application: Oracle Database Software Owner
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE


ORACLE_SID=oradb; export ORACLE_SID
ORACLE_HOME=$ORACLE_BASE/product/19.0.0/db_1; export ORACLE_HOME

NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"; export NLS_DATE_FORMAT


TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN

PATH=$PATH:$HOME/.local/bin:$HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
PATH=.:${PATH}:$ORACLE_HOME/bin
export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
export TEMP=/tmp
export TMPDIR=/tmp
export EDITOR=vi
umask 022

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 12

33. Switch the current user back to root then run the following code to create required groups, grid
user and modify the accounts as follows. Enter the password for grid user when you are
prompted to do so.
exit

groupadd asmadmin
groupadd asmdba
usermod -a -G asmdba oracle
useradd -u 54323 -g oinstall -G asmadmin,asmdba grid
passwd grid

34. Add oracle and grid accounts to vboxsf group.


The vboxsf group was created by VirtualBox Guest Additions and it allows its members to access
the shared folder (staging folder) in the hosting machine.
usermod -a -G vboxsf oracle
usermod -a -G vboxsf grid

35. Create Oracle Database and Clusterware base and home directories:
Oracle Clusterware is the core software for Oracle Grid Infrastructure.
mkdir -p /u01/app/oracle/product/19.0.0/db_1
mkdir -p /u01/app/grid
mkdir -p /u01/app/19.0.0/grid
chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01

36. Switch to grid user and modify its bash profile as follows:
su - grid
mv ~/.bash_profile ~/.bash_profile_bkp

vi ~/.bash_profile

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
ORACLE_SID=+ASM; export ORACLE_SID
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
# the home must not be under the ORACLE_BASE
ORACLE_HOME=/u01/app/19.0.0/grid; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/local/bin
export PATH
export TEMP=/tmp
export TMPDIR=/tmp
umask 022

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 13

Installing ASM Packages and Creating ASM Disk Volumes

In the following steps, you will install ASM packages then create ASM disk volumes.

37. Exit from the current user so that the current user becomes the root
exit

38. Install Oracle ASMLib package


yum install oracleasm-support

# the following command will take a few minutes to finish:


yum install kmod-oracleasm

39. Configure and load the ASM kernel module. Respond to the command as illustrated by the code
in red color.
oracleasm configure -i

Configuring the Oracle ASM library driver.


This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid
Default group to own the driver interface []: oinstall
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done

40. Load the oracleasm kernel module:


/usr/sbin/oracleasm init

41. List the disks as seen by the OS. You should see the disks created in the VirtualBox and attached
to the appliance.
fdisk -l | grep "Disk /dev/sd"

42. Use fdisk to create partitions in the disk.


Do the following for the disks sdb and sdc
fdisk <device file>
then press: n, p, 1, ENTER, ENTER, w – to apply changes

Following is the output done on sdb:


[root@srv1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xd2973f79.
Changes will remain in memory only, until you decide to write them.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 14

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to


switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): n


Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261

Command (m for help): w


The partition table has been altered!

Calling ioctl() to re-read partition table.


Syncing disks.

43. Verify that the partitions are created.


fdisk -l | grep "/dev/s"

44. Create the ASM disks


oracleasm createdisk OCRDISK1 /dev/sdb1
oracleasm createdisk DATADISK1 /dev/sdc1
oracleasm listdisks

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 15

Changing the Required Kernel Parameter Values

In the following step, you will change the kernel parameter values to the values recommended by
Oracle.

45. Create the following file then add the code that follows to it.
vi /etc/sysctl.d/97-oracle-database-sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

46. Apply the current values of the kernel parameters:


/sbin/sysctl --system

47. Run the following code to install further packages required by Oracle software.
yum install ksh
yum install libaio-devel.x86_64

48. Reboot the vm


reboot

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 16

Installing Oracle Grid Infrastructure Software

In the following steps, you will install Oracle Grid Infrastructure software in the vm. The installation
procedure automatically creates and start the Clusterware services.

Note: When Oracle Grid Infrastructure is configured with a non-RAC database, the configuration is
called Oracle Restart.

49. Make sure the Oracle Grid Infrastructure software installation file
(LINUX.X64_193000_grid_home.zip) is copied to the staging folder.

50. As grid, extract the installation file into the Oracle Grid Infrastructure software home directory
su - grid
unzip /media/sf_staging/LINUX.X64_193000_grid_home.zip -d $ORACLE_HOME

51. Install the cvuqdisk in srv1 as root


The package cvuqdisk is shipped with Oracle Grid software files and must be installed before
installing the Clusterware software.
# exit to return back to the root shell:
exit

cd /u01/app/19.0.0/grid/cv/rpm/
CVUQDISK_GRP=oinstall; export CVUQDISK_GRP
rpm -iv cvuqdisk-1.0.10-1.rpm

52. Login to the VirtualBox window of srv1 as grid.

53. Open a terminal window, change the current directory to the Grid Infrastructure software home
directory and run the gridSetup.sh script.
cd $ORACLE_HOME
./gridSetup.sh

54. Respond to the Installer windows as follows:

Window Action

Configuration Option
Select the following option:

“Configure Oracle Grid Infrastructure for a Standalone


Server (Oracle Restart)”

Create ASM Disk Group 1. Click on Change Discovery Path button

2. Enter the Discovery Path as follows:


/dev/oracleasm/disks/*

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 17

3. Fill in the fields as follows:


Disk Group Name: OCRDISK
Redundancy: External
Select Disks: OCRDISK1
This disk group will be used by Clusterware for OCR repository

ASM Password Select the option "Use the same password for these accounts"
Enter the password ABcd##1234

Management Option Make sure the Checkbox is unselected

Operating System Make sure the following are the selected values:
Groups
OSASM: asmadmin
OSDBA: asmdba

Installation Location Oracle Base and Oracle Grid Home should automatically point to
the values of their corresponding variables.
Note: Observe the grid home is not under the Oracle grid base
home.

Create Inventory It should automatically point to /u01/app/oraInventory

Root Script Execution Mark the checkbox “Automatically run configuration scripts”
and enter the root password

Prerequisite Checks All the Prerequisite Checks should pass except the memory. It
complains the available memory is 7.5. We can ignore this
warning.
Select Ignore All checkbox then click on Next button.
Click Yes on the confirmation dialog box.
Note: If you see other warnings, you have to resolve them
before you proceed.

Install Product When the installation reaches to nearly 11%, it will display a
confirmation message. Click on Yes button.

Wait till the installation is finished.

click on Close button

55. After the installation is finished, you can check CRS services status:
crsctl status resource -t

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 18

Creating ASM Disk Groups

In the following steps, you will create the disk group that will be used by Oracle database to store its
datafiles.

Note: In real life scenario, we might create more than one disk group. For example, one for the data
files and one for the FRA.

56. In the VirtualBox window, initiate ASM Configuration Assistant


asmca

57. Create the disk group DATADISK by responding to the Assistant as follows:

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 19

58. Click on Yes when you see the confirmation message to close the window.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 20

Installing Oracle Database Software and Creating an ASM-based Database

In the following steps, you will install Oracle database software in srv1 and then use dbca to create an
ASM-based database.

59. Make sure a copy of the Oracle database software installation file
(LINUX.X64_193000_db_home.zip) is there in the staging folder.

60. In the Putty session, change the current user to oracle then extract the installation file into the
Oracle database software home directory
su - oracle
unzip /media/sf_staging/LINUX.X64_193000_db_home.zip -d $ORACLE_HOME

61. Logout from the VirtualBox window and login to it again as oracle

62. In Oracle VirtualBox, create a snapshot for the vm. This snapshot will be used to restore vm in
case the database installation fails for any reason.

63. Open a terminal window, change the current directory to the Oracle database home directory and
run the runInstaller script.
cd $ORACLE_HOME
./runInstaller

64. Respond to the Installer windows as follows:

Window Action

Configuration Option Select the option: “Setup software only”

Database Installation Select the option: “Single instance database installation”


Options

Database Edition Select the option: “Enterprise Edition”

Installation Location Keep the default value

Operating System Select the OS groups as follows:


Groups

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 21

Root Script Execution Mark the checkbox “Automatically run configuration scripts”
and enter the root password

Prerequisite Checks All the Prerequisite Checks should pass.

Summary Click on Install button

Install Product When the installation reaches to nearly 63%, if will display a
confirmation message. Click on Yes button.

Finish click on Close button

65. Run the dbca and respond to the utility windows as follows:

Database Operation Create a database

Creation Mode Advance Configuration

Deployment Type Custom Database

Database Identification Global Database Name: oradb.localdomain


Oracle SID: oradb
Pluggable Database Name: pdb1

Storage Option Select the option: "Use following for the database storage
attributes"
Make sure the "Database files storage type" is automatically set
to "ASM" and
"Database files location" is set to
"+DATA/{DB_UNIQUE_NAME}"

Fast Recovery Option Mark the option "Specify Fast Recovery Area"
click on "Browse" button and select "DATA" disk group.
Fast Recovery Size: 5000 MB.
You will be prompted for the message [DBT-06801], click on
"Yes" button
Note: In real life scenario, you should set the FRA to a size large
enough to accommodate its contents.

Network Configuration Click on "Next" button.


Note: You do not see a Listener in the list because the running
Listener is owned by grid. The database will still be registered
in the running Listener.

Database Options Deselect all the options except the Oracle JVM.
We keep the OJVM option because it is included in most
installations.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 22

Configuration Options Keep everything in its default values.

Management Options Make sure the checkbox is not marked.

User Credantial Select the option "Use the same administrative password
for all accounts"
Set the password to ABcd##1234

Creation Option click on "Next" button


You will be prompted for the message [DBT-06801], click on
"Yes" button

Summary click on Finish button

Finish click on Close button

66. If there is no one, open a Putty session to the vm as oracle

67. After the installation and database creation are finished, verify the database is up and running by
logging to it as sys
sqlplus / as sysdba
exit

68. Using srvctl utility, check the status of the database (can be run as grid as well)
srvctl status database -d $ORACLE_SID

69. Check if a connection entry to oradb is added to the tnsnames.ora file


The tnsnames.ora file was not even created.
ls $TNS_ADMIN/tnsnames.ora

70. Add a connection descriptor to PDB1 in the tnsnames.ora file:


cat > $TNS_ADMIN/tnsnames.ora << EOF
PDB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = srv1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pdb1.localdomain)
)
)
EOF

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 23

71. Make a testing connection to PDB1 name:


sqlplus system/ABcd##1234@pdb1

72. Exit from SQL*Plus and from oracle session.


quit
exit

You finished creating an Oracle database with Oracle Restart. In the next sections, you will explore
this system.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 24

Checking on Oracle Restart Components and Functionality

In this section of the practice, you will explore the ASM components and examine its auto-restart
functionality.

73. Chang the current user to grid


grid is the owner of the Grid Infrastructure. We normally login as grid to manage the Oracle
Restart components and configuration.
su - grid

74. Check the status of the Oracle High Availability Services


Oracle Restart makes use of the Oracle High Availability Services (HAS) to start and stop the
configured components. If the HAS services are not running, Oracle Restart (including the ASM
instance) will not work.
HAS services can be stopped/started using the command crsctl stop | start has
# verify the crsctl command is running from the grid home1
which crsctl
# check the HAS status:
crsctl check has

75. Verify that autostart the HAS is enabled.


crsctl config has

76. Check the status of the resources in the Oracle Restart stack
crsctl stat res -t

77. Check the status of the Oracle Local Registry (OLR)


OLR is used by Grid to save its configuration information.
ocrcheck -local

78. Display the help information of using srvctl utility


srvctl -help

79. Display the configuration parameters of the database.


srvctl config database -d oradb

80. Run the following commands to stop and then start up the database.
Because the database is registered in the Clusterware, grid is able to start, stop, and configure
the database resource.
srvctl stop database -d oradb -o immediate
srvctl status database -d oradb
srvctl start database -d oradb
srvctl status database -d oradb

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 25

Any resource registered in the Clusterware can be managed by the Clusterware. Let's try managing
the Listener.

81. Issue the following statements to shutdown the Listener and start it up again.
srvctl stop listener
srvctl status listener
srvctl start listener
srvctl status listener

One of the advantages of using Oracle Restart is that it has the functionality to check on the running
processes from Grid and database homes and automatically restart them if they unexpectedly go
down. Let's test this functionality.

82. Exit from grid session so that the current session becomes root

83. Retrieve the process ID of the pmon process of the database instance.
ps -ef|grep ora_pmon

84. Kill the process.


Substitute the pid with the PID of pmon process retrieved by the preceding command.
kill -9 <pid>

85. Keep running the following command a few times to check if the process is respawned.
The process must be respawning by the Clusterware.
ps -ef | grep ora_pmon

86. As oracle, check the status of the database.


If you run the command quickly enough, you might see the database is not running due to the
process failure. Wait for a few seconds then check its status again. Oracle Restart should manage
to recover the database from the process failure automatically and without our intervention.
su - oracle
srvctl status database -d $ORACLE_SID

Let's examine the Oracle Clusterware diagnostic files.

87. Examine the directory structure of the directory $ORACLE_BASE/diag/crs/srv1/crs


The Clusterware diagnostic files and alertlog file are saved in the directory
$ORACLE_BASE/diag/crs/<hostname>/crs. This directory is called ADR Directory (ADR stands
for Automatic Diagnostic Repository).
cd /u01/app/grid/diag/crs/srv1/crs/
ls

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 26

88. Check the alert log file of the Clusterware.


The alert log file contains logging data that could be useful in troubleshooting scenarios.
The alert log is also written as an XML file in the alert subdirectory of the ADR home.
cd trace
cat alert.log

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 27

Retrieving Information about ASM

In this section of the practice, you will obtain information about the ASM instance.

89. Change the current user to grid then check the status of the ASM instance.
su - grid
srvctl status asm -verbose

90. Check out the instance name.


The ASM instance always equals to "+ASM"
echo $ORACLE_SID

91. Login to the ASM instance using SQL*Plus


sqlplus / as sysasm

92. List the disk groups discovered in ASM.


col NAME for a15
SELECT NAME, STATE, TOTAL_MB, FREE_MB FROM V$ASM_DISKGROUP;

93. List the disks discovered by the ASM.


SELECT GROUP_NUMBER, NAME, MOUNT_STATUS, STATE, REDUNDANCY, TOTAL_MB, FREE_MB
FROM V$ASM_DISK;

94. List the files saved in ASM.


col TYPE for a15
SELECT GROUP_NUMBER, FILE_NUMBER, BYTES, TYPE, STRIPED
FROM V$ASM_FILE;

95. List the database instances connected to the ASM.


col INSTANCE_NAME for a8
col SOFTWARE_VERSION for a15
SELECT INSTANCE_NAME, DB_NAME, STATUS, SOFTWARE_VERSION
FROM V$ASM_CLIENT ;

96. Retrieve the SPFILE filename


The SPFILE of the ASM is saved in the OCRDISK disk group.
show parameter SPFILE

97. Convert the SPFILE into PFILE and display its contents.
CREATE PFILE='/tmp/asmpfile.ora' FROM SPFILE;
host cat /tmp/asmpfile.ora

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 28

Getting Started with asmcmd

In this section of the practice, you will get familiar with using asmcmd to explore the ASM contents.

98. Exit from SQL*Plus


exit

99. List the ASM disk groups in non-interactive mode.


By passing a command to the asmcmd utility in the command line, the utility runs the command,
sends its output to the standard output, and then exit.
asmcmd lsdg

100. Invoke the asmcmd utility in an interactive mode.

101. In this mode, we submit the command to the asmcmd command prompt interface.

asmcd

102. Issue the help command to see list of the supported commands

help

103. Display help detail on using ls command

help ls
ls -?

104. Issue the following commands to a navigate the directories and files.

Observe the directory names passed to the command are case-insensitive, whereas the
commands themselves are case-sensitive. Observe the database file types stored in ASM.
The full name of a file or a directory always starts with a disk group name, which in turn starts
with a plus '+' sign.
ls
cd DATA
pwd
du

105. List the discovered disk groups and disks.

lsdg
lsdsk

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 29

106. Go to any directory and copy any file to /tmp

cp command allows us to get a file out of the ASM disks to the file system accessible by the OS.
cp <file> /tmp

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 30

Creating Tablespaces in ASM

In this section of the practice, you will examine create a tablespace in ASM.

107. Exit from asmcmd then change the current user to oracle

quit
exit
su - oracle

108. Invoke SQL*Plus and login to the database as sys. Start PDB1.

sqlplus / as sysdba
ALTER PLUGGABLE DATABASE PDB1 OPEN;

109. Verify the OMF is enabled.

By default, the database creates the tablespace datafiles in the DATA disk group.
show parameter db_create_file_dest

110. Create a tablespace in PDB1 without specifying the datafile.

ALTER SESSION SET CONTAINER = PDB1;


show parameter DB_CREATE_FILE_DEST
CREATE TABLESPACE mytbs;

111. Retrieve the datafile created for the tablespace.

SELECT FILE_NAME
FROM DBA_DATA_FILES
WHERE TABLESPACE_NAME='MYTBS';

112. Exit from SQL*Plus and invoke RMAN with connecting PDB1 as target database

exit
rman target sys/ABcd##1234@pdb1

113. Make a copy of the MYTBS datafile to the sharing folder.

RMAN allows use to take copy of the database datafiles from ASM to the normal file system.
ALTER TABLESPACE MYTBS OFFLINE;
BACKUP AS COPY TABLESPACE MYTBS FORMAT '/media/sf_staging/mytbs.bak';
ALTER TABLESPACE MYTBS ONLINE;

114. Exit from RMAN

exit

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 31

115. Shutdown srv1 and delete the snapshot taken for it.

Caution: Do not delete this vm. You will still use it for a the next practice.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka


Practice: Creating Oracle Database with ASM P a g e | 32

Summary

• To configure Oracle Restart, we must install Oracle Grid Infrastructure in the system

• When is connected to an ASM instance, an Oracle database can save a variety of data types in
the ASM disk groups, like data files, control files, online redo log files, parameter file, backup files
and others.

• When an Oracle database process is abnormally turned down, Oracle restart automatically
respawns the process. This feature provides more high availability than when working without
ASM.

• We can obtain information about the ASM disk group and disks using SQL statements and
asmcmd utility commands.

• When OMF points to an ASM disk group, by default, the data files of the newly create tablespaces
are automatically saved into the OMF disk group. The full path of the datafile is automatically
defined.

• Normal OS commands cannot directly access the files saved in the ASM. We can make copies of
the ASM files to the traditional file systems using asmcmd. For database files, we can use SQL,
asmcmd, or RMAN.

Oracle Database Administration from Zero to Hero, a course by Ahmed Baraka

You might also like