Professional Documents
Culture Documents
Linux Workshop
1/63
Content
1 Linux Introduction ................................................................................................................................................... 4
2 Linux basics .............................................................................................................................................................. 5
2.1 Get some information some the Linux ............................................................................................................... 6
2.2 Setting Up locatedb ............................................................................................................................................ 10
3 Linux preparation .................................................................................................................................................. 11
3.1 Installing Linux Packages .................................................................................................................................... 12
3.2 Validating Kernel Parameters ............................................................................................................................ 14
3.3 Setting Up the Host Name ................................................................................................................................. 15
4 Managing Storage on Linux .................................................................................................................................. 16
4.1 Monitoring Free Space ....................................................................................................................................... 17
4.2 Monitoring Disk Usage ....................................................................................................................................... 18
4.3 Working with Logical Volume Manager ............................................................................................................ 19
4.4 Partitioning a Disk .............................................................................................................................................. 24
5 Linux Booting and Cron ......................................................................................................................................... 28
5.1 Configuring Automatic Startup and Shutdown of the Database ..................................................................... 29
Linux Workshop
2/63
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface elements
associated with an action or terms defined in text or the
glossary.
italic Italic type indicates emphasis, or placeholder variables for
which you supply particular values.
monospace Monospace type indicates commands within a paragraph,
URLs, code in examples, text that appears on the screen, or
text that you enter.
monospace + boldface Input commands
Italic + boldface Emphasis in a result from an action like an input command or a
user interface action.
Linux Workshop
3/63
Linux Introduction
Get some information some the Linux
1 Linux Introduction
No practice for this lesson.
Linux Workshop
4/63
Linux basics
Get some information some the Linux
2 Linux basics
Get information about the Linux basics.
Linux Workshop
5/63
Linux basics
Get some information some the Linux
The primary group is root because it is listed as gid=, and not just in the groups=
list.
2) Which other users are in the dba group?
a) Enter the following at the OS prompt:
[root@dbse ~]# grep dba: /etc/group
dba:x:54322:oracle,grid
asmdba:x:54323:oracle,grid
There are two users in the dba group: oracle and grid
There is a difference between the primary and supplementary groups. The primary
group is the main one shown in /etc/passwd, that a user is in upon login. For a user
to be in a supplementary group, their user name is added to the group entry in
/etc/group. If you use id <user>, it will show the primary and the supplementary
groups. The supplementary groups give access to resources, but any new files are
created with primary group.
3) Change your prompt string to include the full directory path instead of just the last
subdirectory name. Test your change by navigating to the /home/oracle directory.
Question: Why does the prompt still end with a hash sign when you have specified it
to be a dollar sign? You may need to check the bash man page to answer this.
Note: Your prompt will look different from those shown here because of the specific
machine name being shown.
a) Enter the following at the OS prompt to see the current setting:
[root@dbse ~]# echo $PS1
[\u@\h \W]\$
b) Note that the directory specifier is \W, which represents the last subdirectory of
the current directory. Change it to \w to represent the entire current directory
path name. Note that to make the last character a hash sign, you must enter two
backslashes before the dollar ($) sign. The two backslashes are reduced to one
resulting in the final string having \$, which means display the dollar sign, unless
the user is root, in which case display the hash sign. Make this change by
entering the following:
Linux Workshop
6/63
Linux basics
Get some information some the Linux
d) To answer the question, enter the following on the command line to see the
bash man page:
[root@dbse /home/oracle]# man bash
e) When the man page appears, search for the PS1 string by entering the following:
/PS1
f) When the string is found, enter [N] repeatedly until you see the following:
PS1 The value of this parameter is expanded (see PROMPTING below) and used as
the primary prompt string. The default value is ``\s-\v\$ ''.
g) Note that you are directed to see the section on PROMPTING. So, enter the
following to find that section (case is important):
/PROMPTING
i) Enter [j] repeatedly to scroll down to the section that describes the \$ string.
Note that the description for the \$ string states that it causes a dollar sign to be
displayed unless the user ID is 0 (root), in which case, the hash sign is displayed.
\! the history number of this command
\# the command number of this command
\$ if the effective UID is 0, a #, otherwise a $
\nnn the character corresponding to the octal number nnn
Answer: The prompt still ends with a hash sign because the \$ string indicates
that hash is to be used if the user is root.
j) Enter [q] to quit the man page.
4) Write a shell script called showargs.sh that displays each space-delimited parameter
Linux Workshop
7/63
Linux basics
Get some information some the Linux
b) Note that none of the execute permissions are enabled for this file. Enable them,
and then verify by entering the following commands:
[root@dbse /tmp]# chmod +x showargs.sh
[root@dbse /tmp]# ls -l showargs.sh
-rwxr-xr-x. 1 root root 38 Jul 12 23:21 showargs.sh
6) Determine how long the system has been up by using the virtual file system.
Compare your result with the value returned by the uptime command.
a) At the OS prompt, enter the following to display the /proc/uptime contents. Your
results will vary from those shown.
[root@dbse tmp]# cat /proc/uptime
5257.85 5046.93
Linux Workshop
8/63
Linux basics
Get some information some the Linux
Linux Workshop
9/63
Linux basics
Setting Up locatedb
b) Note that the locate command is not able to perform the search because the
locate DB cannot be initialized. Initialize it by entering the following command.
This takes about two minutes to run.
[root@dbse ~]# updatedb
Linux Workshop
10/63
Linux preparation
Setting Up locatedb
3 Linux preparation
Prepare the Linux for install Oracle Database
Linux Workshop
11/63
Linux preparation
Installing Linux Packages
4) Using the /proc file system, display the list of partitions. Enter the following at the
OS prompt:
[root@dbse ~]# cat /proc/partitions
major minor #blocks name
8 0 1073741824 sda
8 1 2097152 sda1
8 2 104861696 sda2
8 3 83890176 sda3
8 4 1 sda4
8 5 41947136 sda5
8 6 31461376 sda6
8 7 16781312 sda7
8 8 251662336 sda8
8 9 541034496 sda9
11 0 1048575 sr0
249 0 41943040 dm-0
249 1 16777216 dm-1
249 2 41943040 dm-2
...
Note: Depending on your system, you may see different output from what is shown.
5) Install all the required packages and configure the operating system using the yum
command to install the oracle-rdbms-server*. This takes a few minutes. Answer “y”
when prompted to download missing packages.
[root@db11gse ~]# yum list oracle-rdbms-server-*
Loaded plugins: langpacks, ulninfo
Installed Packages
Linux Workshop
12/63
Linux preparation
Installing Linux Packages
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Reinstalling:
oracle-rdbms-server-11gR2-preinstall x86_64 1.0-6.el7 ol7_latest 22 k
Transaction Summary
================================================================================
Reinstall 1 Package
Installed:
oracle-rdbms-server-11gR2-preinstall.x86_64 0:1.0-6.el7
Complete!
Linux Workshop
13/63
Linux preparation
Validating Kernel Parameters
d) Validate that the oracle user is created. Look for the Creating oracle user
passed line at the beginning of the orakernel.log file.
...
Creating oracle user passed
e) Validate that the kernel parameters are set correctly. Look for the Verifying &
setting of kernel parameters passed line in the file:
...
Check /etc/sysctl.d for backups
Verifying & setting of kernel parameters passed
f) Verify that the user limits are set correctly by looking for the Verifying &
setting of user limits passed line in the file:
g) Verify that the boot parameters are set correctly by looking for the “Verifying &
setting of boot parameters passed” line in the file.
h) If all the steps have been completed successfully, exit the editor.
Linux Workshop
14/63
Linux preparation
Setting Up the Host Name
Note that there is a files entry, which means that host names are resolved only
through the /etc/hosts file.
2) Verify that the host name is set correctly. If it does not include the domain name
a) You can verify this by entering the hostname command as follows:
[root@dbse ~]# hostname
linuxdb.zfs.com
Note: The host name is not fully qualified. The hostname can be changed for
example using the command hostnamectl set-hostname linuxdb.zfs.com
b) Verify that the host name is corrected by entering the hostname command
again:
[root@db11gse ~]# cat /proc/sys/kernel/hostname
linuxdbse.zfs.com
Linux Workshop
15/63
Managing Storage on Linux
Setting Up the Host Name
Linux Workshop
16/63
Managing Storage on Linux
Monitoring Free Space
The root partition is always mounted on /. The available space on this system is
approximately 36 GB.
Note: Depending on your system, you may see different output from what is shown.
Linux Workshop
17/63
Managing Storage on Linux
Monitoring Disk Usage
Linux Workshop
18/63
Managing Storage on Linux
Working with Logical Volume Manager
2) The df command stand for disk filesystem, it is used to get full summary of
available and used disk space usage of file system on Linux system
[root@dbse ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 351M 1.6G 18% /dev/shm
tmpfs 2.0G 9.7M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/so-root 40G 4.6G 36G 12% /
/dev/sda1 2.0G 331M 1.7G 17% /boot
/dev/mapper/ra-srv_oracle_db 240G 33M 240G 1% /srv/oracle/db
/dev/mapper/sw-u01 40G 8.8G 32G 22% /u01
/dev/mapper/so-home 40G 6.2G 34G 16% /home
/dev/mapper/so-var 20G 708M 20G 4% /var
/dev/mapper/ar-srv_oracle_arc1 40G 33M 40G 1% /srv/oracle/arc1
/dev/mapper/ar-srv_oracle_arc2 40G 33M 40G 1% /srv/oracle/arc2
/dev/mapper/rl-srv_oracle_srl 10G 33M 10G 1% /srv/oracle/srl
/dev/mapper/rl-srv_oracle_orl2 10G 33M 10G 1% /srv/oracle/orl2
Linux Workshop
19/63
Managing Storage on Linux
Working with Logical Volume Manager
Linux Workshop
20/63
Managing Storage on Linux
Working with Logical Volume Manager
Linux Workshop
21/63
Managing Storage on Linux
Working with Logical Volume Manager
Linux Workshop
22/63
Managing Storage on Linux
Working with Logical Volume Manager
#
# /etc/fstab
# Created by anaconda on Wed Sep 5 19:02:26 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/so-root / xfs defaults 0 0
UUID=92dca5fa-4fa8-4911-9951-287fdc65b2ea /boot xfs defaults 0
0
/dev/mapper/so-home /home xfs defaults 0 0
/dev/mapper/ar-srv_oracle_arc1 /srv/oracle/arc1 xfs defaults 0 0
/dev/mapper/ar-srv_oracle_arc2 /srv/oracle/arc2 xfs defaults 0 0
/dev/mapper/ra-srv_oracle_db /srv/oracle/db xfs defaults 0 0
/dev/mapper/rl-srv_oracle_orl1 /srv/oracle/orl1 xfs defaults 0 0
/dev/mapper/rl-srv_oracle_orl2 /srv/oracle/orl2 xfs defaults 0 0
# /dev/mapper/rl-srv_oracle_srl /srv/oracle/srl xfs defaults 0 0
/dev/mapper/sw-u01 /u01 xfs defaults 0 0
/dev/mapper/so-var /var xfs defaults 0 0
/dev/mapper/sp-swap swap swap defaults 0 0
Linux Workshop
23/63
Managing Storage on Linux
Partitioning a Disk
3) Now the first step is to give the new disk a label name with:
(parted) mklabel gpt
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
4) Now create the new partition with mkpart. The listed units are in megabytes (MB).
We will create a 10 GB partition starting from 1 to 10000:
(parted) mkpart
Partition name? []? one
File system type? [ext2]? ext4
Start? 1
End? 10000
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Linux Workshop
24/63
Managing Storage on Linux
Partitioning a Disk
(parted)
5) Resize Linux Disk Partition. You will be asked for the number of the partition that you
will resize. Enter it’s number. After that, you will be asked to set the new ending
point for this partition. Remember that by default the units are in MB. In our
example, we have set the new partition size to 11 GB, and exit from parted:
(parted) resizepart
Partition number? 1
End? [10.0GB]? 11000
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
(parted) q
(parted) mkpart
Partition name? []? two
File system type? [ext2]? ext4
Start? 11.0GB
End? 11.2GB
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
(parted) mkpart
Partition name? []? three
Linux Workshop
25/63
Managing Storage on Linux
Partitioning a Disk
(parted)
7) Delete Linux Partition (if a partition already have data the number partition is
reassigned to other number).
(parted) rm 2
(parted) p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 12.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
(parted)
Linux Workshop
26/63
Managing Storage on Linux
Partitioning a Disk
(parted) quit
Information: You may need to update /etc/fstab.
[root@db11gse ~]#
Linux Workshop
27/63
Linux Booting and Cron
Partitioning a Disk
Linux Workshop
28/63
Linux Booting and Cron
Configuring Automatic Startup and Shutdown of the Database
2) By editing the /etc/oratab file, configure the ASM and bankdb instances to be
automatically started and stopped when the operating system is started and
stopped.
As the oracle user, edit the /etc/oratab file by changing the third field, which is
delimited by a colon, from N to Y. The resulting lines should appear as follows:
+ASM:/u01/app/11.2.0/grid:Y
bankdb:/u01/app/oracle/product/11.2.0/dbhome_1:Y
#
case $1 in
'start')
su - oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" &
;;
'stop')
su - oracle -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" &
;;
Linux Workshop
29/63
Linux Booting and Cron
Configuring Automatic Startup and Shutdown of the Database
*)
echo "usage: $0 {start|stop}"
exit
;;
esac
#
exit
4) Copy the dbora script from the /home/oracle/labs directory to a directory such that
it is invoked during startup and shutdown of the system.
As the root user, enter the following command at the OS prompt:
[root@dbse ~]# cp /home/oracle/labs/dbora /etc/rc.d/init.d
5) Set the permissions for the dbora script to 750 and set the group to dba.
As root, enter the following command at the OS prompt:
[root@db11gse ~]# chmod 750 /etc/rc.d/init.d/dbora
[root@db11gse ~]# chgrp dba /etc/rc.d/init.d/dbora
6) Establish links in the dbora script such that it is invoked during the OS startup and
shutdown in runlevels 3 and 5. The shutdown, or kill scripts, should be executed
first and the startup scripts should be executed last.
As root, enter the following commands:
[root@dbse ~]# ln -s /etc/rc.d/init.d/dbora /etc/rc3.d/S99dbora
[root@dbse ~]# ln -s /etc/rc.d/init.d/dbora /etc/rc3.d/K01dbora
[root@dbse ~]# ln -s /etc/rc.d/init.d/dbora /etc/rc5.d/S99dbora
[root@dbse ~]# ln -s /etc/rc.d/init.d/dbora /etc/rc5.d/K01dbora
[root@dbse ~]# ls -l /etc/rc3.d/*dbora*
lrwxrwxrwx. 1 root root 22 Jul 16 09:46 /etc/rc3.d/K01dbora -> /etc/rc.d/init.d/dbora
lrwxrwxrwx. 1 root root 22 Jul 16 09:46 /etc/rc3.d/S99dbora -> /etc/rc.d/init.d/dbora
[root@dbse ~]# ls -l /etc/rc5.d/*dbora*
lrwxrwxrwx. 1 root root 22 Jul 16 09:47 /etc/rc5.d/K01dbora -> /etc/rc.d/init.d/dbora
lrwxrwxrwx. 1 root root 22 Jul 16 09:47 /etc/rc5.d/S99dbora -> /etc/rc.d/init.d/dbora
Note that the startup scripts start with S99 forcing them to run last. The kill scripts
start with K01 forcing them to run first.
7) Test starting the ASM and dbora database
a) Run the dbstart script by entering the following as root:
[root@dbse ~]# /etc/rc.d/init.d/dbora start
b) Check that the instance is running by issuing the ps commands that are used in
the previous step:
[root@dbse ~]# ps -ef | grep pmon_bankdb
oracle 22597 1 0 13:07 ? 00:00:00 ora_pmon_bankdb
root 22986 21163 0 13:10 pts/0 00:00:00 grep --color=auto pmon_bankdb
Linux Workshop
30/63
Linux Booting and Cron
Configuring Automatic Startup and Shutdown of the Database
Note that shutdown is in progress even though the dbora command returns
immediately. This is because, within the script, dbshut is called with an ampersand
following it, causing it to run in the background.
9) While the databases are being shut down, check whether the instances are still
running. Check for the pmon_bankdb processes.
Run the following command until the only result returned is the grep command
itself.
[root@dbse ~]# ps -ef | grep pmon_bankdb
oracle 21706 1 0 13:01 ? 00:00:00 ora_pmon_bankdb
root 21934 21163 0 13:03 pts/0 00:00:00 grep --color=auto pmon_bankdb
[root@dbse ~]# ps -ef | grep pmon_bankdb
root 22278 21163 0 13:05 pts/0 00:00:00 grep --color=auto pmon_bankdb
The system reboots. As the system reinitializes, check for the pmon processes by using
the ps commands used earlier.
Linux Workshop
31/63