KERNEL TUNING
Kernel
Tuning – change the Kernel Values / Parameters / Limitation is call kernel
tuning
---------------------------------------------------------------------------------------------------------------------
TASK
Error
– too may open files (comman issue) – file
loaded in memory (open files)
Its menas Kernel have limitations of open files.
How many files open in memory?
[root@centoshost ~]# lsof
------------------check list open files
[root@centoshost ~]# lsof | wc –l ----------check
count of open files in ram
7478
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# cat /proc/sys/
-------------------we want to change fs parameters
abi/
crypto/ debug/ dev/ fs/ kernel/ net/ vm/
[root@centoshost ~]# cat /proc/sys/fs/file-max -----check open flles limitation
186668 -------------------------------we want to
change these parameters to “600000”
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# vi /proc/sys/fs/file-max
-----we can’t go and write this
file .
186668 -----change this value
“600000”
---------------------------------------------------------------------------------------------------------------------
1) [root@centoshost ~]# echo 600000 > /proc/sys/fs/file-max---change parameters of open file
[root@centoshost ~]# cat /proc/sys/fs/file-max ---
check open file limit
600000 ---------Parameters will be change but this
a temporary after reboot parameters
are as defailts
menas “186668”
---------------------------------------------------------------------------------------------------------------------
How
many parameters / value / tuning we can change
sysctl
----------system control tool
used for kernel tuning
[root@centoshost
~]# sysctl –a --- all the list of tuning
parameters
[root@centoshost
~]# sysctl -a | wc –l ----count of
parameters we can change
764
---we can 764 parameters will change
[root@centoshost
~]# sysctl -a | grep –i file ----check
search specific parameters name
fs.file-max
= 600000 ------------
---------------------------------------------------------------------------------------------------------------------
OR
2) [root@centoshost
~]# sysctl -w fs.file-max=700000--- change
parameters of open file
fs.file-max
= 700000 -------------------change value
[root@centoshost ~]# sysctl -a | grep -i file
-------check file max value change or not
fs.file-nr = 5120 0 700000
fs.file-max
= 700000 -------change value ----this is only temporary
---------------------------------------------------------------------------------------------------------------------
Advanstage
of sysctl command ------without given path we will change parameters
---------------------------------------------------------------------------------------------------------------------
echo
600000 > /proc/sys/fs/file-max
------Tune with Path
sysctl
-w fs.file-max=700000
------------Tune without Path
---------------------------------------------------------------------------------------------------------------------
How to change swap value
[root@centoshost ~]# sysctl -a | grep -i swap
---first check parameters name and value
vm.swappiness
= 60
OR
[root@centoshost ~]# cat /proc/sys/vm/swappiness ---check
parameters value with path
60
---------------------------------------------------------------------------------------------------------------------
Swappiness has tree value ( 0 ) ,
( 60 ) , ( 100 )
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# sysctl -w vm.swappiness=100
---change the value
[root@centoshost ~]# sysctl -a | grep -i swap
-----check value
vm.swappiness
= 100
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# echo 60 > /proc/sys/vm/swappiness ---- change the value
[root@centoshost ~]# sysctl -a | grep -i swap --
-check value
vm.swappiness
= 60
---------------------------------------------------------------------------------------------------------------------
How
to persistent the tuning command
[root@centoshost ~]# vi /etc/rc.local ----add sysctl
-w vm.swappiness=100 or
echo
60 > /proc/sys/vm/swappiness
for persistent but don’t used this file because kernel have separate
file for tuning -----sysctl.conf
file (no
need add commands in rc.local file )
---------------------------------------------------------------------------------------------------------------------
(rc.local-Its
file execute before login and all the mention command are execute –Run before
login)
---------------------------------------------------------------------------------------------------------------------
How to persistent the tuning command
[root@centoshost ~]# vi /etc/sysctl.conf - This file
for persistent kernel tuning & copy
TAG
#### swap memory #######
vm.swappiness = 100
---------------------------Tags
###### Open File ######
fs.file-max = 800000 -------------------------Tag
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# sysctl –p ----After add tuning
commands in sysctl.conf file,
sysctl
–p command re-read the file and execute
without reboot
--------------------------------------------------------------------------------------------------------------------
[root@centoshost
~]# sysctl -a | grep -i swap -----check
value
vm.swappiness
= 100
[root@centoshost ~]# sysctl
-a | grep -i file -----check value
fs.file-nr = 5088 0 800000
fs.file-max
= 800000
---------------------------------------------------------------------------------------------------------------------
What is swappiness
Swappiness is a Linux
kernel parameter that controls the relative weight
given to swapping out runtime memory, as opposed to dropping pages from the
system page cache. Swappiness can be set to values between 0
and 100 inclusive. A low value causes the kernel to avoid swapping, a higher
value causes the kernel to try to use swap space. The default value is 60
, and for
most desktop systems, setting it to 100 may affect the overall performance,
whereas setting it lower (even 0) may decrease response latency.
Value
|
Strategy
|
vm.swappiness
= 0 |
|
vm.swappiness
= 1 |
Kernel version 3.5 and over, as well as kernel version
2.6.32-303 and over: Minimum amount of swapping without disabling it
entirely.
|
vm.swappiness
= 10 |
This value is sometimes recommended to improve performance when
sufficient memory exists in a system.
|
vm.swappiness
= 60 |
The default value.
|
vm.swappiness
= 100 |
The kernel will swap aggressively.
|
With kernel version 3.5
and over, as well as kernel version 2.6.32-303 and over, it is likely better to
use 1 for cases where 0 used to be optimal.[2]
To temporarily set the swappiness in Linux, write the desired
value (e.g.
10
)
to /proc/sys/vm/swappiness
using
the following command, running as root user:
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# echo 3 > /proc/sys/vm/drop_caches
----clear memory
1
---Dirty Inode Clean
2
---Dirty Block Clean
3 –-
Both Inode + Block Clean
---------------------------------------------------------------------------------------------------------------------
I
want to check ORACLE Tuning Parameters -3 to 4 Tuning Parameters
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# sysctl -a | grep -i shm
-----oracle parameters
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.shm_rmid_forced = 0
x
[root@Tusharjahdav ~]# sysctl -a | grep -i sem
-----oracle parameters
kernel.shmmax = 68719476736
kernel.sem = 250 32000
32 128
---------------------------------------------------------------------------------------------------------------------
How
to persistent the tuning command
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# vi /etc/sysctl.conf -- this
file for persistent kernel tuning
####
swap memory ####
vm.swappiness = 100
#####
file max limit #####
fs.file-max = 900000
#######
Oracle #####
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
wq!
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# sysctl –p ------Re-read & Executed
without reboot the system
vm.swappiness = 100
------------------------swap value
fs.file-max = 900000
------------------------File system value
kernel.shmmax = 68719476736 ---------------------oracle
value
kernel.shmall = 4294967296
---------------------oracle value
kernel.shmmni = 4096 ---------------------oracle value
---------------------------------------------------------------------------------------------------------------------
Make node - Point / Location
Node
- means device driver identity of major and minor numbers
---------------------------------------------------------------------------------------------------------------------
Kernel
Identify the driver by Major number and Minor number
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav
~]# ls -l /dev/sda ------to check hdd devices
sda sda1
sda2 sda3 || sdb
sdb1 || sdc
sdc1 || sdd sdd1
-----4 HDD connected
[root@Tusharjahdav ~]# ls -l /dev/sda1
brw-rw----. 1 root disk 8, 1 Jan 7 05:15 /dev/sda1
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# df –h ----check hdd mount point
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 2.9G
14G 17% /
tmpfs 497M 72K
497M 1% /dev/shm
/dev/sda1 291M 35M
242M 13% /boot
/dev/mapper/myvol-lv1 3.2G
12M 3.1G 1% /Dell
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# ls -l /dev/sdc -----check hdd
partition
brw-rw----. 1 root disk 8, 32 Jan 7 05:15 /dev/sdc
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# df –h -----check hdd partition
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 2.9G
14G 17% /
tmpfs 497M
72K 497M 1% /dev/shm
/dev/sda1 291M 35M
242M 13% /boot
/dev/mapper/myvol-lv1 3.2G
12M 3.1G 1% /Dell ---------/dev/sda3
---------------------------------------------------------------------------------------------------------------------
Are the major, minor number Unique?
Do we have any citations and reference to it?
NAME
MAJ:MIN RM SIZE RO MOUNTPOINT
sda
8:0 0 465.8G 0
├─sda1
8:1 0 298.2M 0
├─sda2
8:2 0 3G
0
├─sda3 8:3 0 458.7G
0 /
├─sda4
8:4 0 1K
0
└─sda5
8:5 0 3.8G
0
sr0
11:0 1 1024M
0
[root@Tusharjahdav ~]# ls
-l /dev/sda --- to check major and minor
number
brw-rw----. 1 root disk 8, 0 Jan 7 05:15 /dev/sda
[root@Tusharjahdav ~]# ls
-l /dev/sdb --- to check major and minor number
brw-rw----. 1 root disk 8, 16 Jan 7 05:15 /dev/sdb
[root@Tusharjahdav ~]# ls
-l /dev/sdc --- to check major and minor number
brw-rw----. 1 root disk 8, 32 Jan 7 05:15 /dev/sdc
[root@Tusharjahdav ~]# ls
-l /dev/sdd --- to check major and minor number
brw-rw----. 1 root disk 8, 48 Jan 7 05:15 /dev/sdd
---------------------------------------------------------------------------------------------------------------------
Major
number is – 8 | minor number is --- 0 to 48
---------------------------------------------------------------------------------------------------------------------
Task -Corrupt my device driver link /dev/sda3
---------------------------------------------------------------------------------------------------------------------
/dev/mapper/myvol-lv1
3.2G 12M 3.1G 1% /Dell ---------/dev/sda3
---------------------------------------------------------------------------------------------------------------------
Example:
[root@Tusharjahdav ~]# mknod /opt/kartina b
8 3 ----- ( b =block size )
[root@Tusharjahdav ~]# mount /opt/kartina /common
-------mount /common DIR
[root@Tusharjahdav ~]# df –h ----check created nodes
---------------------------------------------------------------------------------------------------------------------
Example:
[root@Tusharjahdav
~]# mknod /dev/sda3 b
8 3 ----- ( b =block size )
[root@Tusharjahdav ~]# mount /dev/sda9 /common
-------mount on new created node
[root@Tusharjahdav ~]# df –h ----check created nodes
[root@Tusharjahdav ~]# vi /etc/fstab ----add entry for persistence
/dev/sd3 /comman ext3 defaults 0 0
---------------------------------------------------------------------------------------------------------------------
DEV Runs insides the Drives – dsa1 / sdb1 /sdc1
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav
~]# ls /dev/sdb* -----check HDD partitions
/dev/sdb /dev/sdb1
[root@Tusharjahdav ~]# ls /dev/sdc* -----check HDD
partitions
/dev/sdc /dev/sdc1
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# MAKEDEV /dev/sdd
[root@Tusharjahdav ~]# MAKEDEV /dev/sdb
[root@Tusharjahdav ~]# MAKEDEV /dev/sda
[root@Tusharjahdav ~]# MAKEDEV /dev/sde --------to create sda driver
[root@Tusharjahdav ~]# ls /dev/sde*
/dev/sde /dev/sdeb10 /dev/sded12
/dev/sdef14 /dev/sdeh2 /dev/sdej4
/dev/sdel6 /dev/sden8
/dev/sdeq /dev/sdes10 /dev/sdeu12
/dev/sdew14 /dev/sdey2
/dev/sde1 /dev/sdeb11
/dev/sded13 /dev/sdef15 /dev/sdeh3
/dev/sdej5 /dev/sdel7 /dev/sden9
/dev/sdeq1 /dev/sdes11 /dev/sdeu13
/dev/sdew15 /dev/sdey3
/dev/sde10 /dev/sdeb12
/dev/sded14 /dev/sdef2 /dev/sdeh4
/dev/sdej6 /dev/sdel8 /dev/sdeo
/dev/sdeq10 /dev/sdes12 /dev/sdeu14
/dev/sdew2 /dev/sdey4
/dev/sde11 /dev/sdeb13
/dev/sded15 /dev/sdef3 /dev/sdeh5
/dev/sdej7 /dev/sdel9 /dev/sdeo1
/dev/sdeq11 /dev/sdes13 /dev/sdeu15
/dev/sdew3 /dev/sdey5
/dev/sde12 /dev/sdeb14
/dev/sded2 /dev/sdef4 /dev/sdeh6
/dev/sdej8 /dev/sdem /dev/sdeo10
/dev/sdeq12 /dev/sdes14 /dev/sdeu2
/dev/sdew4 /dev/sdey6
Device names, device nodes, and major/minor numbers
The Linux kernel represents character and block
devices as pairs of numbers <major>:<minor>.
Some
major numbers are reserved for particular device drivers. Other major numbers
are dynamically assigned to a device driver whenLinux boots. For example,
major number 94 is always the major number for DASD devices while the device
driver for channel-attached tape devices has no fixed major number. A major
number can also be shared by multiple device drivers. See /proc/devices to
find out how major numbers are assigned on a running Linux instance.
The
device driver uses the minor number <minor> to
distinguish individual physical or logical devices. For example, the DASD
device driver assigns four minor numbers to each DASD: one to the DASD as a
whole and the other three for up to three partitions.
Device
drivers assign device names to their devices, according to a device
driver-specific naming scheme. Each device name is associated with a minor
number.
Figure 1. Minor numbers and
device names
User
space programs access character and block devices through device nodes also
referred to as device special files. When a device node is created,
it is associated with a major and minor number.
Figure 2. Device nodes
Red Hat
Enterprise Linux 7.2 uses udev to create device nodes for
you. There is always a device node that matches the device name that is
used by the kernel, and additional nodes might be created by special udev
rules. See the udev man page for more details.
[root@Tusharjahdav
~]# less /proc/devices -----check mojor number of devices
Character devices: Block
devices:
1 mem
|
1 ramdisk
|
4 /dev/vc/0
|
259 blkext
|
4 tty
|
7 loop
|
4 ttyS
|
8 sd
|
5 /dev/tty
|
9 md
|
5 /dev/console
|
11 sr
|
5 /dev/ptmx
|
65 sd
|
7 vcs
|
66 sd
|
10 misc
|
67 sd
|
13 input
|
68 sd
|
14 sound
|
69 sd
|
21 sg
|
70 sd
|
29 fb
|
71 sd
|
99 ppdev
|
128 sd
|
116 alsa
|
129 sd
|
128 ptm
|
130 sd
|
136 pts
|
131 sd
|
162 raw
|
132 sd
|
180 usb
|
133 sd
|
189 usb_device
|
134 sd
|
202 cpu/msr
|
135 sd
|
203 cpu/cpuid
|
253 device-mapper
|
249 hidraw
|
254 mdp
|
250 usbmon
|
|
251 bsg
|
|
252 pcmcia
|
|
253 watchdog
|
|
254 rtc
|
|
No comments:
Post a Comment