The "ls" command lists all files and directories in the specified directory. If no location is defined it acts on the current directory. The "-a" flag lists hidden "." files. The "-l" flag lists file details.pwd
/u01/app/oracle/product/9.2.0.1.0
More Examples:ls
ls /u01
ls -al
The "touch" command is used to create a new empty file with the default permissions:cd /u01/app/oracle
The "rm" command is used to delete files and directories. The "-R" flag tells the command to recurse through subdirectories.touch my.log
The "mv" command is used to move or rename files and directories. The "." represents the current directoryrm my.log
rm -R /archive
The "cp" command is used to copy files and directories:mv [from] [to]
mv my.log my1.log
mv * /archive
mv /archive/* .
The "mkdir" command is used to create new directories:cp [from] [to]
cp my.log my1.log
cp * /archive
cp /archive/* .
The "rmdir" command is used to delete directories:mkdir archive
The "grep" command performs a search for a specified string or pattern.rmdir archive
Display only the lines in /etc/oratab where the lines do not (-v option; negation) start with # character (^ is a special character indicating beginning of line, similarly $ is end of line).find / -name dbmspool.sql
find / -print | grep dbmspool.sql Search everywhere for the specified file
find . -exec grep "DISPLAY" {} \; -print | pg Search all files for the text string "DISPLAY" - takes a while to run !
grep -v '^#' /etc/oratabTip for Oracle Users
The "PS1"changes your prompt.oracle> which sqlplus
PS1="Diego_Master:> "You can also place special symbols in the variable to show special values. For instance the symbol \u shows the username who logged in and \h shows the hostname, finally the \w shows in which directory you are located . If we use these symbols, the prompt can be customized to show who logged in and where:
Diego_Master:>
Here are some other symbols you can use in PS1 shell variable:
\! |
The command number in the history (more on this later) |
\d |
The date in Weekday Month Date format |
\H |
The host name with the domain name. \h is the hostname without the domain |
\T |
The same as \@ but displaying seconds as well. |
\A |
The time in hour:minutes as in \@ format but 24 hours |
\t |
The same as \A but with the seconds as well; |
wc -l README.txtThe "more" or "cat" commands lets you display the contents of a file:
85 README.txt
gzip
command results in a compressed copy of the original
file with a ".gz" extension. The gunzip
command reverses
this process. The compress
command results in a
compressed copy of the original
file with a ".Z" extension. The uncompress
command
reverses this process:
gzip myfile
gunzip myfile.gz
compress myfile
uncompress myfile
The umask value is subtracted from the default permissions (666) to give the final permission:umask 022
The "chmod" command is used to alter file permissions after the file has been created:666 : Default permission
022 : - umask value
644 : final permission
Character eqivalents can be used in the chmod command:chmod 777 *.log
Owner Group World Permission
========= ========= ========= ======================
7 (u+rwx) 7 (g+rwx) 7 (o+rwx) read + write + execute
6 (u+wx) 6 (g+wx) 6 (o+wx) write + execute
5 (u+Rx) 5 (g+Rx) 5 (o+Rx) read + execute
4 (u+r) 4 (g+r) 4 (o+r) read only
2 (u+w) 2 (g+w) 2 (o+w) write only
1 (u+x) 1 (g+x) 1 (o+x) execute only
The "chown" command is used to change the ownership of files after creation. The "-R" flag causes the command ro recurse through any subdirectories.chmod o+rwx *.log
chmod g+r *.log
chmod -Rx *.log
Finally the "chgrp" command is used to change the group to a file:chown -R oinstall.dba *
chgrp <directory> groupThe following example changes the ownership on every single file in current directory and lower directories to oracle (useful if someone has done an install erroneously as root.)
useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user
The "userdel" command is used to delete existing users. The "-r" flag removes the default directory.usermod -s /bin/csh my_user
The "passwd" command is used to set, or reset, the users login password:userdel -r my_user
passwd my_user
who
who | head -5
who | tail -5
who | grep -i ora
who | wc -l
ps
ps -ef | grep -i ora
Let’s see what happens when we want to kill the session of the user SH.kill -9 12345
uname -a
Linux HPLINUX 2.4.21-20.ELsmp #1 SMP Wed Aug 18 20:46:40 EDT 2004 i686 i686 i386 GNU/Linux
uname -a | awk '{ print $2 }'
HPLINUX
hostname
HPLINUX
#!/bin/ksh
su - oracle <<EOF
ORACLE_SID=LIN1; export ORACLE_SID
rman catalog=rman/rman@w2k1 target=/ cmdfile=my_cmdfile log=my_logfile append
EOF
OS |
patchlevel |
memory |
I/O Info |
CPU Info |
CPU / Memory |
Sun Solaris |
showrev -p |
sysinfo |
sar -d |
/opt/RICHPse/bin/se |
/opt/RICHPse/bin/se |
Linux |
grep MemTotal
/proc/meminfo free |
vmstat 3 5 |
grep "model name" /proc/cpuinfo cat /proc/cpuinfo sar -u 2 5 sar -b |
top sar -W 5 5 |
|
HP-UX |
swlist |
sam |
|
|
vmstat -n 2 200 |
AIX/RS-6000 |
instfix -ivqk |
smit or sar |
|
|
|
mount | column -t
List mounted filesystems on the
system (and align output)
free -m (in MB)
Check Swap Activity (Metalink Note 225451.1)
/sbin/swapon -s
free -t
cat /proc/swaps
The recommended SWap size is two to three times the amount of Physical
Memory for Swap space (unless the system exceeds 1 GB of Physical
Memory, where two times the amount of Physical Memory for Swap space is
sufficient)
Swap space in Linux is used when the amount of physical memory (RAM) is
full.If the system needs more memory resources and the physical memory
is full, inactive pages in memory are moved to the swap space. While
swap space can help machines with a small amount of RAM, it should not
be considered a replacement for more RAM. Swap space is located on hard
drives, which have a slower access time than physical memory.
Swapping is one of the Unix mechanisms to accommodate the size
limitation of memory by moving entire processes to disk to reclaim
memory.
Paging is another Unix machanism to manage the limitations of memory.
Unlike swapping, where entire processes are moved in and out of memory,
paging moves only individual pages of processes to disk. Paging is not
as serious a problem as swapping, as the entire program does not have
to reside in memory to run. A small amount of paging may not noticeably
affect the performance of a system. However, the performance of a
system may degraderapidly as paging activity increases.
Swap space can have a dedicated swap partition (recommended), a swap
file, or a combination of swap partitions and swap files.
When analyzing your UNIX machine, make sure that the machine is not
swapping at all and at worst paging lightly. This indicates a system
with a healthy amount of memory available.
How can I enable Swap in
LINUX ?
First check is Swap is enabled:
/sbin/swapon -s
Filename
Type
Size
Used Priority
/dev/sda3
partition
2040244 453180 -1
To enable swap, check for swap entries in your /etc/fstab
grep swap /etc/fstab
/dev/sda3
swap
swap
defaults
0 0
And use the '/sbin/swapon -a'
command to enable all Swap partitions
listed in /etc/fstab.
How to add a swapfile?
Determine the size of the new swap file and multiple by 1024 to
determine the block size. For example, the block size of a 64 MB swap
file is 65536.
At a shell prompt as root, type the following command with count being
equal to the desired block size:
dd if=/dev/zero
of=/data2/swapfile1 bs=1024 count=65536
Setup the swap file with the command:
/sbin/mkswap /data2/swapfile1
To enable the swap file immediately but not automatically at boot time:
/sbin/swapon /data2/swapfile
To enable it at boot time, edit /etc/fstab to include:
/data2/swapfile swap swap
defaults 0 0
The next time the system boots, it will enable the new swap file.
Check Services Running and
stop them if not used
Services that should be removed: r* (shell or rsh, login
or rlogin,
exec or rexec, rcp), telnet, ftp, sendmail, exim, postfix, printer,
qmail, http, portmap, SMBD (Samba)
chkconfig --list
-->
Show
services running and its level
chkconfig --del servicename
--> Stop
that service
chkconfig --level 345 servicename
off -->
Stop that service for level 3,4,5
Also it could be necessary to check the file /etc/inetd.conf
because it has references to some services, if any service that I want
to stop is there, comment that line and reboot the server or run:
/etc/init.d/inetd restart
Enable FTP
and TELNET Services
cd to /etc/xinetd.d
vi wu-ftpd
Change the disable field from "yes" to "no" and save changes.
vi telnet
Change the disable field from "yes" to "no" and save changes.
Network
Information
Display
network
interface configuration
parameters
Address
resolution
display and control
Check Routes:
Change
network, change it's ip, mask, bcast and gateway.
The easiest way is to execute sys-unconfig.
After the process finishes power down the box and move it to the new
network.
When you boot the box it will ask the appropriate questions about the
network configuration
Important
Network LINUX files:
Making the following gross assumptions:
Your IP
is:
192.168.0.1
Your Gateway
is: 192.168.0.254
Your netmask
is: 255.255.255.0
Your nameservers are:
192.168.0.2, 192.168.0.3, and 192.168.0.4
/etc/sysconfig/network File
NETWORKING=yes
HOSTNAME=your_machine_name.saa.senate.gov
GATEWAY=192.168.0.254
/etc/hosts File
127.0.0.1
localhost.localdomain
localhost
192.168.0.1
your_machine_name.company.com
your_machine_name
192.168.0.254
your_gateway.company.com
your_gateway
(You don't absolutely *need* your gateway in the hosts file, but I feel
it does sometimes speed up some operations)
/etc/sysconfig/network-scripts/ifcfg-eth0
File
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
/etc/resolv.conf File
search gateway compay_gateway
nameserver 192.168.0.2
nameserver 192.168.0.3
nameserver 192.168.0.4
(The 'search' line is optional. You can have up to 3 'nameserver'
lines,and they don't need to be inside your network)
/etc/resolv.conf File
domain
domain_name
nameserver
192.168.0.1
search
domain_name
Get
OS
File System Block Size 64 bit or 32 bit
On Linux
$uname -a
64 Bits
Linux gaylord.stata.com 2.6.11-1.27_FC3 #1 Tue May 17 20:24:57 EDT 2005
x86_64 x86_64 x86_64 GNU/Linux
64 Bits
Linux caddo.stata.com 2.6.9-5.0.5.EL #1 SMP Fri Apr 8 14:20:58 EDT 2005
ia64 ia64 ia64 GNU/Linux
32 Bits
Linux tango.stata.com 2.6.10-1.771_FC2smp #1 SMP Mon Mar 28 01:10:51
EST 2005 i686 i686 i386
GNU/Linux
$uname
-m
It seems like the uname -m actually gives
* x86_64 when it is an kernel 64 bits
* i686 for 32 bits kernel
$getconf LONG_BIT
which returns either 32 or 64
On Solaris
isainfo -b -v
/usr/bin/isainfo -kv
On AIX
$ getconf -a | grep KERN
$ file /usr/lib/boot/unix*
On HP-UX
/usr/bin/ getconf KERNEL_BITS
/usr/bin/file /stand/vmunix
The free command let you identify the amoung of memory
used by all the apps on the box. If the amount of memory used is
bigger than the available RAM, then the box starts to swap.
If you use this command with the -m
option, it will show the numbers in MB.
# free -m
total
used
free
shared buffers cached
Mem:
1772
1654
117
0
18 618
-/+
buffers/cache:
1017 754
Swap:
1983
1065
918
Here we can see that the box has 1772
MB of RAM, currently using 1654
MB, and only 117 MB of
free memory.
The next line shows the changes on the size of the cache and buffers in
the memory.
Finally the third one shows the amount of swap memory that is being
used.
The –t options shows you the totals at the end of the output (adds
physical memory plus swap memory):
# free -m -t
total
used
free
shared buffers cached
Mem:
1772
1644
127
0
16
613
-/+
buffers/cache:
1014 757
Swap:
1983
1065
918
Total:
3756
2709
1046
Some tips
Shows the percentage of used memory:
# free -m | grep Mem | awk
'{print ($3 / $2)*100}'
98.7077
Shows the percentage of swap memory:
free -m | grep -i Swap | awk
'{print ($3 / $2)*100}'
The top command is probably the most
useful one for an Oracle DBA managing a database on Linux.
Note that unlike other commands, top does not produce an
output and sits still. It refreshes the screen to display new
information. So, if you just issue top and leave the screen
up, the most current information is always up. To stop and exit to
shell, you can press Control-C.
$ top
18:46:13 up 11 days, 21:50, 5 users, load average: 0.11, 0.19, 0.18
151 processes: 147 sleeping, 4 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 12.5% 0.0% 6.7% 0.0% 0.0% 5.3% 75.2%
Mem: 1026912k av, 999548k used, 27364k free, 0k shrd, 116104k buff
758312k actv, 145904k in_d, 16192k in_c
Swap: 2041192k av, 122224k used, 1918968k free 590140k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
451 oracle 15 0 6044 4928 4216 S 0.1 0.4 0:20 0 tnslsnr
8991 oracle 15 0 1248 1248 896 R 0.1 0.1 0:00 0 top
1 root 19 0 440 400 372 S 0.0 0.0 0:04 0 init
2 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 keventd
3 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 kapmd
4 root 34 19 0 0 0 SWN 0.0 0.0 0:00 0 ksoftirqd/0
7 root 15 0 0 0 0 SW 0.0 0.0 0:01 0 bdflush
5 root 15 0 0 0 0 SW 0.0 0.0 0:33 0 kswapd
6 root 15 0 0 0 0 SW 0.0 0.0 0:14 0 kscand
8 root 15 0 0 0 0 SW 0.0 0.0 0:00 0 kupdated
9 root 25 0 0 0 0 SW 0.0 0.0 0:00 0 mdrecoveryd
... output snipped ...
Let's examine the different types of information produced.
The first line: 18:46:13 up 11 days, 21:50, 5 users, load
average: 0.11, 0.19, 0.18
shows the current time (18:46:13), that system has
been up for 11 days; that the system has been working for 21 hours 50
seconds. The load average of the system is shown (0.11, 0.19, 0.18) for
the last 1, 5 and 15 minutes respectively. (By the way, you can also
get this information by issuing the uptime command.)
If
the load average is not required, press the letter "l" (lowercase L);
it will turn it off. To turn it back on press l again. Ideally
Load average should be less than 1, otherwise the processes are fully
burdened
The second line: 151 processes: 147 sleeping, 4 running, 0
zombie, 0 stopped
shows the number of processes, running, sleeping, etc.
The third and fourth lines:
CPU states: cpu user nice system irq softirq iowait idle
total 12.5% 0.0% 6.7% 0.0% 0.0% 5.3% 75.2%
show the CPU utilization details. The above line shows
that user processes consume 12.5% and system consumes 6.7%. The user
processes include the Oracle processes. Press "t" to turn these three
lines off and on. If there are more than one CPU, you will see one line
per CPU.
The next two lines:
Mem: 1026912k av, 1000688k used, 26224k free, 0k shrd, 113624k buff
758668k actv, 146872k in_d, 14460k in_c
Swap: 2041192k av, 122476k used, 1918716k free 591776k cached
show the memory available and utilized. Total memory is "1026912k av", approximately 1GB, of which only 26224k or 26MB is free. The swap space is 2GB; but it's almost not used. To turn it off and on, press "m".
The rest of the display shows the processes in a tabular format. Here is the explanation of the columns:
Column | Description |
PID | The process ID of the process |
USER | The user running the process |
PRI | The priority of the process |
NI | The nice value: The higher the value, the lower the priority of the task |
SIZE | Memory used by this process (code+data+stack) |
RSS | The physical memory used by this process |
SHARE | The shared memory used by this process |
STAT |
The status of this process, shown in code. Some major status
codes are: W – Swapped out process N – positive nice value |
%CPU | The percentage of CPU used by this process |
%MEM | The percentage of memory used by this process |
TIME | The total CPU time used by this process |
CPU | If this is a multi-processor system, this column indicates the ID of the CPU this process is running on. |
COMMAND | The command issued by this process |
While the top is being displayed, you can press a few keys to format the display as you like. Pressing the uppercase M key sorts the output by memory usage. (Note that using lowercase m will turn the memory summary lines on or off at the top of the display.) This is very useful when you want to find out who is consuming the memory. Here is sample output:
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
31903 oracle 15 0 75760 72M 72508 S 0.0 7.2 0:01 0 ora_smon_PRODB2
31909 oracle 15 0 68944 66M 64572 S 0.0 6.6 0:03 0 ora_mmon_PRODB2
31897 oracle 15 0 53788 49M 48652 S 0.0 4.9 0:00 0 ora_dbw0_PRODB2
Now that you learned how to interpret the output, let's see how to use command line parameters.
The most useful is -d, which indicates the delay between the screen refreshes. To refresh every second, use top -d 1.
The other useful option is -p. If you want to monitor only a few processes, not all, you can specify only those after the -p option. To monitor processes 13609, 13608 and 13554, issue:
top -p 13609 -p 13608 -p 13554
This will show results in the same format as the top command, but only those specific processes.
It's probably needless to say that the top utility comes in very handy for analyzing the performance of database servers. Here is a partial top output.
20:51:14 up 11 days, 23:55, 4 users, load average: 0.88, 0.39, 0.27
113 processes: 110 sleeping, 2 running, 1 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 1.0% 0.0% 5.6% 2.2% 0.0% 91.2% 0.0%
Mem: 1026912k av, 1008832k used, 18080k free, 0k shrd, 30064k buff
771512k actv, 141348k in_d, 13308k in_c
Swap: 2041192k av, 66776k used, 1974416k free 812652k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
16143 oracle 15 0 39280 32M 26608 D 4.0 3.2 0:02 0 oraclePRODB2...
5 root 15 0 0 0 0 SW 1.6 0.0 0:33 0 kswapd
... output snipped ...
Let's analyze the output carefully. The first thing
you should notice is the "idle" column under CPU states; it's
0.0%—meaning, the CPU is completely occupied doing something.
The
question is, doing what?
Move your attention to the column "system",
just
slightly left; it shows 5.6%. So the system itself is not
doing
much.
Go even more left to the column marked "user", which shows 1.0%.
Since user processes include Oracle as well, Oracle is not consuming
the CPU cycles.
So, what's eating up all the CPU?
The
answer lies in the same line, just to the right under the column
"iowait", which indicates 91.2%.
This
explains it all: the CPU is
waiting for IO 91.2% of the time.
So why so much IO wait? The answer lies in the display. Note the PID of the highest consuming process: 16143. You can use the following query to determine what the process is doing:
select s.sid, s.username, s.program
from v$session s, v$process p
where spid = &server_process_id
and p.addr = s.paddr
/
SID USERNAME PROGRAM
------------------- -----------------------------
159 SYS rman@prolin2 (TNS V1-V3)
The rman process is taking up the IO waits related CPU cycles. This information helps you determine the next course of action.
From the previous discussion you learned how to identify a CPU consuming resource. What if you find that a process is consuming a lot of CPU and memory, but you don't want to kill it? Consider the top output below:
$ top -c -p 16514
23:00:44 up 12 days, 2:04, 4 users, load average: 0.47, 0.35, 0.31
1 processes: 1 sleeping, 0 running, 0 zombie, 0 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 0.0% 0.6% 8.7% 2.2% 0.0% 88.3% 0.0%
Mem: 1026912k av, 1010476k used, 16436k free, 0k shrd, 52128k buff
766724k actv, 143128k in_d, 14264k in_c
Swap: 2041192k av, 83160k used, 1958032k free 799432k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
16514 oracle 19 4 28796 26M 20252 D N 7.0 2.5 0:03 0 oraclePRODB2...
Now that you confirmed the process 16514 is consuming a lot of memory, you can "freeze" it—but not kill it—using the skill command.
$ skill -STOP 1
After this, check the top output:
23:01:11 up 12 days, 2:05, 4 users, load average: 1.20, 0.54, 0.38
1 processes: 0 sleeping, 0 running, 0 zombie, 1 stopped
CPU states: cpu user nice system irq softirq iowait idle
total 2.3% 0.0% 0.3% 0.0% 0.0% 2.3% 94.8%
Mem: 1026912k av, 1008756k used, 18156k free, 0k shrd, 3976k buff
770024k actv, 143496k in_d, 12876k in_c
Swap: 2041192k av, 83152k used, 1958040k free 851200k cached
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
16514 oracle 19 4 28796 26M 20252 T N 0.0 2.5 0:04 0 oraclePRODB2...
The CPU is now 94% idle from 0%. The process is effectively frozen. After some time, you may want to revive the process from coma:
$ skill -CONT 16514
This approach is immensely useful for temporarily freezing processes to make room for more important processes to complete.
The command is very versatile. If you want to stop all processes of the user "oracle", only one command does it all:
$ skill -STOP oracle
You can use a user, a PID, a command or terminal id as argument. The following stops all rman commands.
$ skill -STOP rman
As you can see, skill decides that argument you entered—a process ID, userid, or command—and acts appropriately. This may cause an issue in some cases, where you may have a user and a command in the same name. The best example is the "oracle" process, which is typically run by the user "oracle". So, when you want to stop the process called "oracle" and you issue:
$ skill -STOP oracle
all the processes of user "oracle" stop, including the session you may be on. To be completely unambiguous you can optionally give a new parameter to specify the type of the parameter. To stop a command called oracle, you can give:
$ skill -STOP -c oracle
The command snice is similar. Instead of stopping a process it makes its priority a lower one. First, check the top output:
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
3 root 15 0 0 0 0 RW 0.0 0.0 0:00 0 kapmd
13680 oracle 15 0 11336 10M 8820 T 0.0 1.0 0:00 0 oracle
13683 oracle 15 0 9972 9608 7788 T 0.0 0.9 0:00 0 oracle
13686 oracle 15 0 9860 9496 7676 T 0.0 0.9 0:00 0 oracle
13689 oracle 15 0 10004 9640 7820 T 0.0 0.9 0:00 0 oracle
13695 oracle 15 0 9984 9620 7800 T 0.0 0.9 0:00 0 oracle
13698 oracle 15 0 10064 9700 7884 T 0.0 0.9 0:00 0 oracle
13701 oracle 15 0 22204 21M 16940 T 0.0 2.1 0:00 0 oracle
Now, drop the priority of the processes of "oracle" by four points. Note that the higher the number, the lower the priority.
$ snice +4 -u oracle
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND
16894 oracle 20 4 38904 32M 26248 D N 5.5 3.2 0:01 0 oracle
Note how the NI column (for nice values) is now 4 and
the priority is now set to 20, instead of 15. This is quite useful in
reducing priorities.
Let’s see how to interpret these values. The first line of the output is an average of all the metrics since the system was restarted. So, ignore that line since it does not show the current status. The other lines show the metrics in real time.
Ideally, the number of processes waiting or blocking (under the “ procs” heading) should be 0 or close to 0. If they are high, then the system either does not have enough resources like CPU, memory, or I/O. This information comes useful while diagnosing performance issues.
The data under “swap” indicates if excessive swapping is going on. If that is the case, then you may have inadequate physical memory. You should either reduce the memory demand or increase the physical RAM.
The data under “ io” indicates the flow of data to and from the disks. This shows how much disk activity is going on, which does not necessarily indicate some problem. If you see some large number under “ proc” and then “ b” column (processes being blocked) and high I/O, the issue could be a severe I/O contention.
The most useful information comes under the “ cpu” heading. The “ id” column shows idle CPU. If you subtract that number from 100, you get how much percent the CPU is busy. Remember the top command described in another installment of this series? That also shows a CPU free% number. The difference is: top shows that free% for each CPU whereas vmstat shows the consolidated view for all CPUs.
The vmstat command also shows the breakdown of CPU usage: how much is used by the Linux system, how much by a user process, and how much on waiting for I/O. From this breakdown you can determine what is contributing to CPU consumption. If system CPU load is high, could there be some root process such as backup running?
The
system load should be consistent over a period of time. If the system
shows a high number, use the top command to identify the system process
consuming CPU.
Oracle
processes (the background processes and server processes) and the user
processes (sqlplus, apache, etc.) come under “ us”.
If this number is high, use top to identify the processes. If the “ wa”
column shows a high number, it indicates the I/O system is unable to
catch up with the amount of reading or writing. This could occasionally
shoot up as a result of spikes in heavy updates in the database causing
log switch and a subsequent spike in archiving processes. But if it
consistently shows a large number, then you may have an I/O bottleneck. I/O
blockages in an Oracle database can cause serious problems. Apart from
performance issues, the slow I/O could cause controlfile writes to be
slow, which may cause a process to wait to acquire a controlfile
enqueue. If the wait is more that 900 seconds, and the waiter is a
critical process like LGWR, it brings down the database instance. If
you see a lot of swapping, perhaps the SGA is sized too large to fit in
the physical memory. You should either reduce the SGA size or increase
the physical memory.
Tip
for Oracle Users
procs | memory | page | disk | faults | cpu | ||||||||||||||||
r | b | w | swap | free | re | mf | pi | po | fr | de | sr | s0 | s1 | s2 | s3 | in | sy | cs | us | sy | id |
0 | 0 | 0 | 28872 | 8792 | 8 | 5 | 172 | 142 | 210 | 0 | 24 | 3 | 11 | 17 | 2 | 289 | 1081 | 201 | 14 | 6 | 80 |
0 | 0 | 0 | 102920 | 1936 | 1 | 95 | 193 | 6 | 302 | 1264 | 235 | 12 | 1 | 0 | 3 | 240 | 459 | 211 | 0 | 2 | 97 |
0 | 0 | 0 | 102800 | 1960 | 0 | 0 | 0 | 0 | 0 | 464 | 0 | 0 | 0 | 0 | 0 | 107 | 146 | 29 | 0 | 0 | 100 |
10:42:38 PM CPU %user %nice %system %iowait %irq %soft %idle intr/s
10:42:43 PM all 6.89 0.00 44.76 0.10 0.10 0.10 48.05 1121.60
10:42:43 PM 0 9.20 0.00 49.00 0.00 0.00 0.20 41.60 413.00
10:42:43 PM 1 4.60 0.00 40.60 0.00 0.20 0.20 54.60 708.40
10:42:43 PM CPU %user %nice %system %iowait %irq %soft %idle intr/s
10:42:48 PM all 7.60 0.00 45.30 0.30 0.00 0.10 46.70 1195.01
10:42:48 PM 0 4.19 0.00 2.20 0.40 0.00 0.00 93.21 1034.53
10:42:48 PM 1 10.78 0.00 88.22 0.40 0.00 0.00 0.20 160.48
Average: CPU %user %nice %system %iowait %irq %soft %idle intr/s
Average: all 7.25 0.00 45.03 0.20 0.05 0.10 47.38 1158.34
Average: 0 6.69 0.00 25.57 0.20 0.00 0.10 67.43 724.08
Average: 1 7.69 0.00 64.44 0.20 0.10 0.10 27.37 434.17
It shows the various stats for the CPUs in the system. The –P ALL options directs the command to display stats for all the CPUs, not just a specific one. The parameters 5 2 directs the command to run every 5 seconds and for 2 times. The above output shows the metrics for all the CPUs first (aggregated) and for each CPU individually. Finally, the average for all the CPUs has been shown at the end.
Let’s see what the column values mean:
%user |
Indicates the percentage of the processing for that CPU consumes by user processes. User processes are non-kernel processes used for applications such as an Oracle database. In this example output, the user CPU %age is very little. |
%nice |
Indicates the percentage of CPU when a process was downgraded by nice command. The command nice has been described in an earlier installment. It brief, the command nice changes the priority of a process. |
%system |
Indicates the CPU percentage consumed by kernel processes |
%iowait |
Shows the percentage of CPU time consumed by waiting for an I/O to occur |
%irq |
Indicates the %age of CPU used to handle system interrupts |
%soft |
Indicates %age consumed for software interrupts |
%idle |
Shows the idle time of the CPU |
%intr/s |
Shows the total number of interrupts received by the CPU per second |
You
may be wondering about the purpose of the mpstat command when you have
vmstat, described earlier. There is a huge difference: mpstat can show
the per processor stats, whereas vmstat shows a consolidated view of
all processors. So, it’s possible that a poorly written application not
using multi-threaded architecture runs on a multi-processor machine but
does not use all the processors. As a result, one CPU overloads while
others remain free. You can easily diagnose these sorts of issues via
mpstat. Similar
to vmstat, the mpstat command also produces CPU related stats so all
the discussion related to CPU issues applies to mpstat as well. When
you see a low %idle figure, you know you have CPU starvation. When you
see a higher %iowait figure, you know there is some issue with the I/O
subsystem under the current load. This information comes in very handy
in troubleshooting Oracle database performance.
Tip
for Oracle Users
A
key part of the performance assessment is disk performance. The iostat
command gives the performance metrics of the storage interfaces. The
beginning portion of the output shows metrics such as CPU free and I/O
waits as you have seen from the mpstat command. The
next part of the output shows very important metrics for each of the
disk devices on the system. Let’s see what these columns mean: Device The
name of the device tps Number
of transfers per second, i.e. number of I/O operations per second.
Note: this is just the number of I/O operations; each operation could
be huge or small. Blk_read/s Number
of blocks read from this device per second. Blocks are usually of 512
bytes in size. This is a better value of the disk’s utilization. Blk_wrtn/s Number
of blocks written to this device per second Blk_read Number
of blocks read from this device so far. Be careful; this is not what is
happening right now. These many blocks have already been read from the
device. It’s possible that nothing is being read now. Watch this for
some time to see if there is a change. Blk_wrtn Number
of blocks written to the device In
a system with many devices, the output might scroll through several
screens—making things a little bit difficult to examine, especially if
you are looking for a specific device. You can get the metrics for a
specific device only by passing that device as a parameter. The
CPU metrics shown at the beginning may not be very useful. To suppress
the CPU related stats shown in the beginning of the output, use the -d
option. While
the above output can be helpful, there is lot of information not
readily displayed. For instance, one of the key causes of disk issues
is the disk service time, i.e. how fast the disk gets the data to the
process that is asking for it. To get that level of metrics, we have to
get the “extended” stats on the disk, using the -x option. Let’s
see what the columns mean: Device The
name of the device rrqm/s The
number of read requests merged per second. The disk requests are
queued. Whenever possible, the kernel tries to merge several requests
to one. This metric measures the merge requests for read transfers. wrqm/s Similar
to reads, this is the number of write requests merged. r/s The
number of read requests per second issued to this device w/s Likewise,
the number of write requests per second rsec/s The
number of sectors read from this device per second wsec/s The
number of sectors written to the device per second rkB/s Data
read per second from this device, in kilobytes per second wkB/s Data
written to this device, in kb/s avgrq-sz Average
size of the read requests, in sectors avgqu-sz Average
length of the request queue for this device await Average
elapsed time (in milliseconds) for the device for I/O requests. This is
a sum of service time + waiting time in the queue. svctm Average
service time (in milliseconds) of the device %util Bandwidth
utilization of the device. If this is close to 100 percent, the device
is saturated. Well,
that’s a lot of information and may present a challenge as to how to
use it effectively. The next section shows how to use the output. You
can use a combination of the commands to get some meaning information
from the output. Remember, disks could be slow in getting the request
from the processes. The amount of time the disk takes to get the data
from it to the queue is called service time. If you want to find out
the disks with the highest service times, you issue: This
shows that the disk sdat has the highest service time (64.05 ms). Why
is it so high? There could be many possibilities but three are most
likely: Looking
at the output we see that reads/sec and writes/sec are 0.00 (almost
nothing is happening), so we can rule out #1. The utilization is also
0.00% (the last column), so we can rule out #2. That leaves #3.
However, before we draw a conclusion that the disk is inherently slow,
we need to observe that disk a little more closely. We can examine that
disk alone every 5 seconds for 10 times. If
the output shows the same average service time, read rate and
utilization, we can conclude that #3 is the most likely factor. If they
change, then we can get further clues to understand why the service
time is high for this device. Similarly,
you can sort on the read rate column to display the disk under constant
read rates. The
information helps you to locate a disk that is “hot”—that is, subject
to a lot of reads or writes. If the disk is indeed hot, you should
identify the reason for that; perhaps a filesystem defined on the disk
is subject to a lot of reading. If that is the case, you should
consider striping the filesystem across many disks to distribute the
load, minimizing the possibility that one specific disk will be hot.iostat
# iostat
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
avg-cpu: %user %nice %sys %iowait %idle
15.71 0.00 1.07 3.30 79.91
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
cciss/c0d0 4.85 34.82 130.69 307949274 1155708619
cciss/c0d0p1 0.08 0.21 0.00 1897036 3659
cciss/c0d0p2 18.11 34.61 130.69 306051650 1155700792
cciss/c0d1 0.96 13.32 19.75 117780303 174676304
cciss/c0d1p1 2.67 13.32 19.75 117780007 174676288
sda 0.00 0.00 0.00 184 0
sdb 1.03 5.94 18.84 52490104 166623534
sdc 0.00 0.00 0.00 184 0
sdd 1.74 38.19 11.49 337697496 101649200
sde 0.00 0.00 0.00 184 0
sdf 1.51 34.90 6.80 308638992 60159368
sdg 0.00 0.00 0.00 184 0
... and so on ...
# iostat sdaj
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
avg-cpu: %user %nice %sys %iowait %idle
15.71 0.00 1.07 3.30 79.91
Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sdaj 1.58 31.93 10.65 282355456 94172401
You can place optional parameters at the end to let iostat display the
device stats in regular intervals. To get the stats for this device
every 5 seconds for 10 times, issue the following:# iostat -d sdaj 5 10
You can display the stats in kilobytes instead of just bytes using the -k option:
# iostat -k -d sdaj
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sdaj 1.58 15.96 5.32 141176880 47085232# iostat -x sdaj
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
avg-cpu: %user %nice %sys %iowait %idle
15.71 0.00 1.07 3.30 79.91
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util
sdaj 0.00 0.00 1.07 0.51 31.93 10.65 15.96 5.32 27.01 0.01 6.26 6.00 0.95
How
to Use It
# iostat -x | sort -nrk13
sdat 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 18.80 0.00 64.06 64.05 0.00
sdv 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 17.16 0.00 18.03 17.64 0.00
sdak 0.00 0.00 0.00 0.14 0.00 1.11 0.00 0.55 8.02 0.00 17.00 17.00 0.24
sdm 0.00 0.00 0.00 0.19 0.01 1.52 0.01 0.76 8.06 0.00 16.78 16.78 0.32
... and so on ...
# iostat -x sdat 5 10
# iostat -x | sort -nrk6
sdj 0.00 0.00 1.86 0.61 56.78 12.80 28.39 6.40 28.22 0.03 10.69 9.99 2.46
sdah 0.00 0.00 1.66 0.52 50.54 10.94 25.27 5.47 28.17 0.02 10.69 10.00 2.18
sdd 0.00 0.00 1.26 0.48 38.18 11.49 19.09 5.75 28.48 0.01 3.57 3.52 0.61
... and so on ...
From the earlier discussions, one common thread emerges: Getting real time metrics is not the only important thing; the historical trend is equally important.
Furthermore, consider this situation: how many times has someone reported a performance problem, but when you dive in to investigate, everything is back to normal? Performance issues that have occurred in the past are difficult to diagnose without any specific data as of that time. Finally, you will want to examine the performance data over the past few days to decide on some settings or to make adjustments.
The sar utility accomplishes that goal. sar stands for System Activity Recorder, which records the metrics of the key components of the Linux system—CPU, Memory, Disks, Network, etc.—in a special place: the directory /var/log/sa. The data is recorded for each day in a file named sa<nn> where <nn> is the two digit day of the month. For instance the file sa27 holds the data for the date 27th of that month. This data can be queried by the command sar.
The
simplest way to use sar is to use it without any arguments or options.
Here is an example:
# sar
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
12:00:01 AM CPU %user %nice %system %iowait %idle
12:10:01 AM all 14.99 0.00 1.27 2.85 80.89
12:20:01 AM all 14.97 0.00 1.20 2.70 81.13
12:30:01 AM all 15.80 0.00 1.39 3.00 79.81
12:40:01 AM all 10.26 0.00 1.25 3.55 84.93
... and so on ...
The
output shows the CPU related metrics collected in 10 minute intervals.
The columns mean
CPU |
The CPU identifier; “all” means all the CPUs |
%user |
The percentage of CPU used for user processes. Oracle processes come under this category. |
%nice |
The %ge of CPU utilization while executing under nice priority |
%system |
The %age of CPU executing system processes |
%iowait |
The %age of CPU waiting for I/O |
%idle |
The %age of CPU idle waiting for work |
From the above output, you can see that the system has been well balanced; actually severely under-utilized (as seen from the high degree of %age idle number). Going further through the output we see the following:
... continued from above ...
03:00:01 AM CPU %user %nice %system %iowait %idle
03:10:01 AM all 44.99 0.00 1.27 2.85 40.89
03:20:01 AM all 44.97 0.00 1.20 2.70 41.13
03:30:01 AM all 45.80 0.00 1.39 3.00 39.81
03:40:01 AM all 40.26 0.00 1.25 3.55 44.93
... and so on ...
This tells a different story: the system was loaded by some user processes between 3:00 and 3:40. Perhaps an expensive query was executing; or perhaps an RMAN job was running, consuming all that CPU. This is where the sar command is useful--it replays the recorded data showing the data as of a certain time, not now. This is exactly what you wanted to accomplish the three objectives outlined in the beginning of this section: getting historical data, finding usage patterns and understanding trends.
If you want to see a specific day’s sar data, merely open sar with that file name, using the -f option as shown below (to open the data for 26th)
# sar -f /var/log/sa/sa26
It can also display data in real time, similar to vmstat or mpstat. To get the data every 5 seconds for 10 times, use:
# sar 5 10
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
01:39:16 PM CPU %user %nice %system %iowait %idle
01:39:21 PM all 20.32 0.00 0.18 1.00 78.50
01:39:26 PM all 23.28 0.00 0.20 0.45 76.08
01:39:31 PM all 29.45 0.00 0.27 1.45 68.83
01:39:36 PM all 16.32 0.00 0.20 1.55 81.93
… and so on 10 times …
Did you notice the “all” value under CPU? It means the stats were rolled up for all the CPUs. In a single processor system that is fine; but in multi-processor systems you may want to get the stats for individual CPUs as well as an aggregate one. The -P ALL option accomplishes that.
#sar -P ALL 2 2
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
01:45:12 PM CPU %user %nice %system %iowait %idle
01:45:14 PM all 22.31 0.00 10.19 0.69 66.81
01:45:14 PM 0 8.00 0.00 24.00 0.00 68.00
01:45:14 PM 1 99.00 0.00 1.00 0.00 0.00
01:45:14 PM 2 6.03 0.00 18.59 0.50 74.87
01:45:14 PM 3 3.50 0.00 8.50 0.00 88.00
01:45:14 PM 4 4.50 0.00 14.00 0.00 81.50
01:45:14 PM 5 54.50 0.00 6.00 0.00 39.50
01:45:14 PM 6 2.96 0.00 7.39 2.96 86.70
01:45:14 PM 7 0.50 0.00 2.00 2.00 95.50
01:45:14 PM CPU %user %nice %system %iowait %idle
01:45:16 PM all 18.98 0.00 7.05 0.19 73.78
01:45:16 PM 0 1.00 0.00 31.00 0.00 68.00
01:45:16 PM 1 37.00 0.00 5.50 0.00 57.50
01:45:16 PM 2 13.50 0.00 19.00 0.00 67.50
01:45:16 PM 3 0.00 0.00 0.00 0.00 100.00
01:45:16 PM 4 0.00 0.00 0.50 0.00 99.50
01:45:16 PM 5 99.00 0.00 1.00 0.00 0.00
01:45:16 PM 6 0.50 0.00 0.00 0.00 99.50
01:45:16 PM 7 0.00 0.00 0.00 1.49 98.51
Average: CPU %user %nice %system %iowait %idle
Average: all 20.64 0.00 8.62 0.44 70.30
Average: 0 4.50 0.00 27.50 0.00 68.00
Average: 1 68.00 0.00 3.25 0.00 28.75
Average: 2 9.77 0.00 18.80 0.25 71.18
Average: 3 1.75 0.00 4.25 0.00 94.00
Average: 4 2.25 0.00 7.25 0.00 90.50
Average: 5 76.81 0.00 3.49 0.00 19.70
Average: 6 1.74 0.00 3.73 1.49 93.03
Average: 7 0.25 0.00 1.00 1.75 97.01
This shows the CPU identifier (starting with 0) and the stats for each. At the very end of the output you will see the average of runs against each CPU.
The command sar is not only fro CPU related stats. It’s useful to get the memory related stats as well. The -r option shows the extensive memory utilization.
# sar -r
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
12:00:01 AM kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
12:10:01 AM 712264 32178920 97.83 2923884 25430452 16681300 95908 0.57 380
12:20:01 AM 659088 32232096 98.00 2923884 25430968 16681300 95908 0.57 380
12:30:01 AM 651416 32239768 98.02 2923920 25431448 16681300 95908 0.57 380
12:40:01 AM 651840 32239344 98.02 2923920 25430416 16681300 95908 0.57 380
12:50:01 AM 700696 32190488 97.87 2923920 25430416 16681300 95908 0.57 380
Let’s see what each column means:
kbmemfree |
The free memory available in KB at that time |
kbmemused |
The memory used in KB at that time |
%memused |
%age of memory used |
kbbuffers |
This %age of memory was used as buffers |
kbcached |
This %age of memory was used as cache |
kbswpfree |
The free swap space in KB at that time |
kbswpused |
The swap space used in KB at that time |
%swpused |
The %age of swap used at that time |
kbswpcad |
The cached swap in KB at that time |
At the very end of the output, you will see the average figure for time period.
You can also get specific memory related stats. The -B option shows the paging related activity.
# sar -B
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
12:00:01 AM pgpgin/s pgpgout/s fault/s majflt/s
12:10:01 AM 134.43 256.63 8716.33 0.00
12:20:01 AM 122.05 181.48 8652.17 0.00
12:30:01 AM 129.05 253.53 8347.93 0.00
... and so on ...
The column shows metrics at that time, not currently.
pgpgin/s |
The amount of paging into the memory from disk, per second |
pgpgout/s |
The amount of paging out to the disk from memory, per second |
fault/s |
Page faults per second |
majflt/s |
Major page faults per second |
To get a similar output for swapping related activity, you can use the -W option.
# sar -W
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
12:00:01 AM pswpin/s pswpout/s
12:10:01 AM 0.00 0.00
12:20:01 AM 0.00 0.00
12:30:01 AM 0.00 0.00
12:40:01 AM 0.00 0.00
... and so on ...
The columns are probably self-explanatory; but here is the description of each anyway:
pswpin/s |
Pages of memory swapped back into the memory from disk, per second |
pswpout/s |
Pages of memory swapped out to the disk from memory, per second |
If you see a lot of swapping, you may be running low on memory. It’s not a foregone conclusion but rather something that may be a strong possibility.
To get the disk device statistics, use the -d option:
# sar -d
Linux 2.6.9-55.0.9.ELlargesmp (prolin3) 12/27/2008
12:00:01 AM DEV tps rd_sec/s wr_sec/s
12:10:01 AM dev1-0 0.00 0.00 0.00
12:10:01 AM dev1-1 5.12 0.00 219.61
12:10:01 AM dev1-2 3.04 42.47 22.20
12:10:01 AM dev1-3 0.18 1.68 1.41
12:10:01 AM dev1-4 1.67 18.94 15.19
... and so on ...
Average: dev8-48 4.48 100.64 22.15
Average: dev8-64 0.00 0.00 0.00
Average: dev8-80 2.00 47.82 5.37
Average: dev8-96 0.00 0.00 0.00
Average: dev8-112 2.22 49.22 12.08
Here is the description of the columns. Again, they show the metrics at that time.
tps |
Transfers per second. Transfers are I/O operations. Note: this is just number of operations; each operation may be large or small. So, this, by itself, does not tell the whole story. |
rd_sec/s |
Number of sectors read from the disk per second |
wr_sec/s |
Number of sectors written to the disk per second |
To get the historical network statistics, you use the -n option:
# sar -n DEV | more
Linux 2.6.9-42.0.3.ELlargesmp (prolin3) 12/27/2008
12:00:01 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
12:10:01 AM lo 4.54 4.54 782.08 782.08 0.00 0.00 0.00
12:10:01 AM eth0 2.70 0.00 243.24 0.00 0.00 0.00 0.99
12:10:01 AM eth1 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth2 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth3 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth4 143.79 141.14 73032.72 38273.59 0.00 0.00 0.99
12:10:01 AM eth5 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth6 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM eth7 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12:10:01 AM bond0 146.49 141.14 73275.96 38273.59 0.00 0.00 1.98
… and so on …
Average: bond0 128.73 121.81 85529.98 27838.44 0.00 0.00 1.98
Average: eth8 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Average: eth9 3.52 6.74 251.63 10179.83 0.00 0.00 0.00
Average: sit0 0.00 0.00 0.00 0.00 0.00 0.00 0.00
In summary, you have these options for the sar command to get the metrics for the components:
Use this option … |
… to get the stats on: |
-P |
Specific CPU(s) |
-d |
Disks |
-r |
Memory |
-B |
Paging |
-W |
Swapping |
-n |
Network |
What if you want to get the all the available stats on one output? Instead of calling sar with all these options, you can use the -A option which shows all the stats stored in the sar files.
%CPU | PID | USER | COMMAND |
78.1 | 4789 | oracle | ora_dbwr_DDDS2 |
8.5 | 4793 | oracle | ora_lgwr_DDDS2 |
2.4 | 6206 | oracle | oracleDDDS2 (LOCAL=NO) |
0.1 | 4797 | oracle | ora_smon_DDDS2 |
0.1 | 6207 | oracle | oracleDDDS2 (LOCAL=NO) |
etc. | etc. | etc. | etc. |
SELECT a.username, a.osuser, a.program, spid, sid, a.serial#
FROM v$session a, v$process b
WHERE a.paddr = b.addr
AND spid = '&pid';
/etc/init.d/
directory, in this case
the file is called myservice
, containing the commands you
wish to run at startup and/or shutdown.chmod
command to set the privileges to 750:Link the file into the appropriate run-level script directories:chmod 750 /etc/init.d/myservice
Associate theln -s /etc/init.d/myservice /etc/rc0.d/K10myservice
ln -s /etc/init.d/myservice /etc/rc3.d/S99myservice
myservice
service with the appropriate run
levels:The script should now be automatically run at startup and shutdown (with "start" or "stop" as a commandline parameter) like other service initialization scripts.chkconfig --level 345 dbora on
Examples* - All available values or "first-last".
3-4 - A single range representing each possible from the start to the end of the range inclusive.
1,2,5,6 - A specific list of values.
1-3,5-8 - A specific list of ranges.
0-23/2 - Every other value in the specified range.
This script returns TRUE (0) only on the node which is the CFS serving cluster_root.#!/bin/ksh
set -- $(/usr/sbin/cfsmgr -F raw /)
shift 12
[[ "$1" = "$(/bin/hostname -s)" ]] && exit 0
exit 1
Although the cron jobs fire on all nodes, the "/bin/cronrun &&" part of the entry prevents the script from running on all nodes except the current CFS serving cluster_root.5 * * * /bin/cronrun && /usr/local/bin/myjob
First the mount point must be shared so it can be seen by remote machines:exportfs
Next the share can be mounted on a remote machine by root using:share -F nfs -o ro /cdrom
mkdir /cdrom#1
mount -o ro myhost:/cdrom /cdrom#1
Append the following entry to the "/etc/exports" file:mkdir /u04/backup
Make sure the correct permissions are granted on the directory:/u04/backup
On the client machine:chmod -R 777 /u04/backup
Append an following entry to the "/etc/fstab" file:mkdir /backup
Finally, mount the fileset:nfs-server-name:/u04/backup /backup nfs rw,bg,intr 0 0
At this point you can start to use the mount point from your client machine. Thanks to Bryan Mills for his help with Tru64.mount /backup
- From the command promot on the PC do the following:<client-name>:0
- The X environment should start in a new window.set PATH=PATH;c:cygwinbin;c:cygwinusrX11R6bin
XWin.exe :0 -query <server-name>
DISPLAY=<client-name>:0.0; export DISPLAY
The command line history can be accessed using the [Esc][k] by adding the following entry:stty erase "^H"
Auto completion of paths using a double strike of the [Esc] key can be configured by adding the following entry:set -o vi
set filec
Path | Contents |
/etc/passwd | User settings |
/etc/group | Group settings for users. |
/etc/hosts | Hostname lookup information. |
/etc/system | Kernel parameters for Solaris. |
/etc/sysconfigtab | Kernel parameters for Tru64. |