oracle dba training | best oracle dba online training | oracle dba
Oracle Linux DBA Benefits
-
Upload
sendhilmca -
Category
Documents
-
view
220 -
download
0
Transcript of Oracle Linux DBA Benefits
-
8/6/2019 Oracle Linux DBA Benefits
1/14
-
8/6/2019 Oracle Linux DBA Benefits
2/14
watch Shows top server task details including server load average
ps Shows process-level details on resource consumption
These utilities are exceptional for monitoring Oracle databases and they can beplaced inside Linux shell scripts to take the output from the Linux commands and
store the information inside Oracle tables.
For example, here is a utility that will take the output from Linux vmstat utility and
insert the output into an Oracle table:
PATH=$ORACLE_HOME/bin:$PATH
export PATH
SERVER_NAME=`uname -a|awk '{print $2}'`
typeset -u SERVER_NAME
export SERVER_NAME
# sample every five minutes (300 seconds) . . . .
SAMPLE_TIME=300
while true
do
vmstat ${SAMPLE_TIME} 2 > /tmp/msg$$
# run vmstat and direct the output into the Oracle table . . .
cat /tmp/msg$$|sed 1,3d | awk '{ printf("%s %s %s %s %s %s\n", $1, $8, $9,
14, $15, $16) }' | while read RUNQUE PAGE_IN PAGE_OUT USER_CPU
SYSTEM_CPU
-
8/6/2019 Oracle Linux DBA Benefits
3/14
IDLE_CPU
do
$ORACLE_HOME/bin/sqlplus -s perfstat/perfstat@testsys1
-
8/6/2019 Oracle Linux DBA Benefits
4/14
We can use the same script technique with the Linux iostat utility and shell scripts
can be used to monitor disk I/O and place the details inside Oracle tables.
#!/bin/ksh
while true
do
iostat -x 300 1|\
sed 1,2d|\
awk '{ printf("%s %s %s\n", $1, $4, $5) }' |\
while read HDISK VMSTAT_IO_R VMSTAT_IO_W
do
if [ $VMSTAT_IO_R -gt 0 ] and [ $VMSTAT_IO_W -gt 0 ]
then
sqlplus -s perfstat/perfstat insert into
perfstat.stats\$iostat
values
(SYSDATE, 5, '$HDISK', $VMSTAT_IO_R,$VMSTAT_IO_W);
exit
!
fi
done
sleep 300
done
-
8/6/2019 Oracle Linux DBA Benefits
5/14
As we see, the easy-to-use Linux monitoring utilities open-up a whole new world to
the Oracle DBA. If you take the time to master the Linux command syntax and
utilities you will gain the ability to diagnose any Oracle problem and always know
the exact cause of any OS-related performance issue. Now lets take a look at someof the command-line utilities for Linux and see how they can simplify the tasks of
the Oracle DBA.
Command Utilities for Linux
As we have noted, Linux has powerful command-line utilities that provideexceptional monitoring for every aspects of Oracles interactions with the hardware
environment. But there is more to Linux than the commands. The Oracle
professional will also need to master shell scripting, task scheduling and specialized
functions:
The vi file editor The vi editor is an extremely powerful text editor that is far more
powerful and flexible than Windows-based editors such as notepad.
Utility commands Linux provides powerful system tools such as grep, sed and awk
that allow you to create comprehensive OS monitoring facilities.
Job scheduling - The Linux crontab utility allows for scheduling OS tasks at specific
time intervals.
Scripting - Shell environments such as Korn shell, C shell, Bourne shell and Bourne
Again shell (bash) allow you to create sophisticated Linux monitoring scripts.
Linux tools are very powerful and flexible, and like any powerful tool, they are
complex. It can take years for the staff to master Linux internals, using the powerful
vi editor, and learning to program with UNIX shell scripts. Lets take a quick look at
the types of scripts that a Linux DBA might employ for their Oracle environment.
-
8/6/2019 Oracle Linux DBA Benefits
6/14
There are many OS events that need to be monitored by the Oracle DBA and prior
to Oracle10g the DBA would want to be notified of any server-side event.
Operating System Events:
File system is filling rapidly
Server is paging RAM
High CPU enqueues
Messages in Linux syslog (I/O errors, bus errors)
Oracle OS events:
Alert log message
Core dump
Background dump
User dump created
For example, here is an example of an actual UNIX script for Oracle to detect a
almost-full filesystem:
#!/bin/ksh
for i in `df -k|grep /u0|awk '{ print $4 }'`
do
filesize=`expr i`
if [ $filesize -lt 100 ]
then
-
8/6/2019 Oracle Linux DBA Benefits
7/14
-
8/6/2019 Oracle Linux DBA Benefits
8/14
configured, causing multiple buffer access whereby data blocks travel onto the UNIX
Journaled File System (JFS) buffer cache, and then transferred into the Oracle data
buffers.
This additional I/O overhead is a major problem and one that is automatic in Linux.Linux systems support direct I/O on a per-filehandle basis (which is much more
flexible), and Oracle enables this O_DIRECT feature automatically. This is not true
for those using Sun, HP and Veritas I/O, and tricky utilities must be implemented to
enable direct I/O:
Solaris Uses the "forcedirectio" option. Oracle DBAs claim this option makes a
huge difference in I/O speed for Sun servers.
AIX - Uses the "dio" option.
Veritas VxFS - (including HP-UX, Solaris and AIX), uses the "convosync=direct". It is
also possible to enable direct I/O on a per-file basis using Veritas QIO; refer to the
"qiostat" command and corresponding man page for hints.
In sum, using Linux with a hardware vendor such as UNISYS ensures that the Linux
environment is optimized to run as quickly as possible. Now lets look at the issue of
migrating to Linux from Windows and proprietary UNIX.
Migrating to Linux from Proprietary UNIX
Migrating into Linux can be very easy or very difficult, depending on your existing
Oracle configuration. It is not uncommon to see small dialect differences between
implementations of UNIX, especially with respect to display output and command
arguments.
Those shops that find a migration difficult are those that have made extensive use
of operating system utilities for their Oracle functions:
-
8/6/2019 Oracle Linux DBA Benefits
9/14
External scheduling of Oracle tasks
Crontab
Windows at scheduling
Extensive use of OS shell scripts
Automated e-mail alerts (new dumps, alert log messages, Linux syslog
messages)
File system alerts
Server overload alerts
If you avoid the OS trap and use Oracle to schedule all Oracle tasks you can easily
port your database across OS platforms. This is especially true if you migrate to
Oracle10g where Oracle automatically collects OS metrics and has a built-in alert
and scheduling mechanism:
Migrate to Oracle10g
Schedule all Oracle tasks with dbms_scheduler
Use the Oracle dbms_alert package to replace OS scripting
Lets take a closer look at the syntax differences between proprietary UNIX and
Linux so that you can appreciate the challenge of migration.
Linux command syntax
Users of proprietary UNIX will immediately recognize many similarities between
Sun, HP, AIX and Linux commands. However, there are significant syntax issues,
especially with regard to command arguments and the output from Linux utilities:
-
8/6/2019 Oracle Linux DBA Benefits
10/14
Linux Command Syntax examples
Display the number of CPUs cat /proc/cpuinfo|grep processor|wc l
Show top CPU% ps aux|sort -n +2
Display top-10 CPU consumers ps aux|sort -rn +2|head -10
RAM memory display free
Shutdown server as root /sbin/shutdown -r now
Kill all xxx processes pkill [-9] xxx
Show swap paging space /sbin/swapon -s
Show Linux syslog errors tail /var/log/messages
Show swap disk details swapon -s
See held memory segments ipcs -m
Show Linux system parms sysctl -a
Linux command history files history|more
Migrating from Sun to Linux can be especially problematic because of the syntax
differences and the different output from the utilities such as vmstat and netstat.
This can cause considerable re-writing of shell scripts.
vmstat Linux:
>vmstat 2 5
procs memory swap io system cpu
r b w swpd free buff cache si bi bo in cs us sy id
1 0 0 140 90372 726988 26228 0 0 0 14 7 0 0 4
-
8/6/2019 Oracle Linux DBA Benefits
11/14
0 0 0 140 90372 726988 26228 0 0 2 103 11 0 0 100
vmstat Solaris:
>vmstat 2 5
procs memory page disk faults cpu
r b w swap free re mf pi po s6 -- -- in sy cs us sy id
0 0 0 2949744 988800 0 4 0 0 0 0 0 148 200 41 0 0 99
0 0 0 2874808 938960 27 247 0 1 0 0 0 196 434 64 1 2 98
Display number of CPUs:
Linux:
>cat /proc/cpuinfo|grep processor|wc -l
16
Solaris:
>psrinfo -v|grep "Status of processor"|wc -l
8
RAM Size in Linux:
-
8/6/2019 Oracle Linux DBA Benefits
12/14
>free
total used free shared buffers cached
Mem: 3728668 504688 3223980 41316 430072 29440
-/+ buffers/cache: 45176 3683492
Swap: 265032 608 264424
RAM Size in Solaris:
>prtconf|grep -i mem
Memory size: 2048 Megabytes
memory (driver not attached)
virtual-memory (driver not attached)
Netstat Differences
On any Sun and Linux server the netstat utility provides information about all
network traffic touching the server. However the output from the
Solaris netstat
>netstat
-
8/6/2019 Oracle Linux DBA Benefits
13/14
TCP: IPv4
Local Address Remote Address Swind Send-Q Rwind Recv-Q State
------------- ------------------- ----- ------ ----- ------ -----------
sting.32773 ting.1521 32768 0 32768 0 ESTABLISHED
sting.1521 ting.32773 32768 0 32768 0 ESTABLISHED
sting.32774 ting.1521 32768 0 32768 0 ESTABLISHED
Linux netstat
In Linux, we see that the output from netstat is quite different from Solaris:
>netstat
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 donsrv1.rov:netbios-ssn intranet.janet.com:1351 ESTABLISHED
tcp 0 0 donsrv1.janet.com:1120 sting.janet.com:ssh TIME_WAIT
tcp 0 40 donsrv1.janet.com:ssh h pop3-146.gloryroa:1096 ESTABLISHED
Ironically, the syntax differences between proprietary UNIX and Linux can hinder
your migration and shops that use SFU on Windows often have a far easier
migration. In sum, those Oracle shops that avoid OS utilities such as scheduling
(crontab) and shell scripts will find database migration very easy.
2. Linux commands for Oracle DBA
-
8/6/2019 Oracle Linux DBA Benefits
14/14
Posted by Kamran Agayev A. on February 22, 2009
Today I would like to introduce you some articles related to advanced Linuxcommands. These commands will be useful when working with Oracle Database
Therere 5 articles that I would like to introduce you