OS: Tuning Kernel Scheduler

From OnnoWiki
Jump to navigation Jump to search

Sumber: http://www.techtinker.com/linux/LinuxKernel.html#HowRedHat


   What is a kernel?
   A UNIX kernel is an interpreter that translates user level system calls into synchronized access to hardware and device drivers. The calls are defined by POSIX standards.
   The interpreter manages user level requests for file or process access. The kernel's scheduler enables UNIX to juggle file and process subsystems. The file subsystem works with raw or block disk devices. The process subsystem manages process synchronization, inter-process communication, memory management and process scheduling.
   The kernel manages through the use of two key structures, the process table and the user structure. The process table contains scheduling parameters, memory image, signals and miscellaneous process states. The user structure includes machine registries, system call state, file descriptor table, accounting and kernel stack.
   Why tune a kernel?
   The default UNIX kernel behavior is suboptimal out of the box because it is difficult to anticipate what type of work or workload the operating system will be assigned. Therefore, UNIX products provide parameters that may change the allocation of critical resources. The kernel tuning parameters are UNIX product specific.
   The system administrator is responsible to determine the target type of work and workload for a machine and to monitor whether either change over time. The system administrator should ensure that any tunable kernel parameters are set to optimize machine performance.
       NOTE:
       Kernel tuning is an advanced topic and should not be done without a complete understanding of the subject.
   How to tune Red Hat?
   The super user should configure the tunable parameters for the Red Hat Application Server 2.1 Linux kernel before installing Oracle9i or Oracle Applications 11i. If using an Oracle Development Services slot, the concurrent number of Oracle9i and Oracle 9iAS instances should be determined. The number of concurrent instances will enable validating whether the tunable kernel parameters are correctly configured.
       Edit the /etc/sysctl.conf file.
       The changes noted below should be made in the /etc/sysctl.conf file. If using a slot, log a bug to effect changes to a slot environment. Copy the following from the web page into the /etc/sysctl.conf file. Recalculate the numeric values and use the new values to edit the file.
       # -------------------------------------------------------------------------
       # Kernel parameter assumptions and rationale.
       # ===========================================
       #
       # Linux Advanced Server 2.1 has a configure restricted kernel.
       #
       # -------------------------------------------------------------------------
       # Disables packet forwarding
       # -------------------------------------------------------------------------
        net.ipv4.ip_forward = 0
       # -------------------------------------------------------------------------
       # Enables source route verification
       # -------------------------------------------------------------------------
        net.ipv4.conf.default.rp_filter = 1
       # -------------------------------------------------------------------------
       # Set the default local port range.
       # -------------------------------------------------------------------------
        net.ipv4.ip_local_port_range = 1024 65000
       # -------------------------------------------------------------------------
       # Enables the magic-sysrq key
       # -------------------------------------------------------------------------
        kernel.sysrq = 1
       # -------------------------------------------------------------------------
       # General semaphore rules:
       # -----------------------
       # 1. Semaphore tunable parameters are limited to semmsl, semmns,
       #    semopm and semmni and must be entered in the /etc/sysctl.conf
       #    file with the following syntax.
       #
       #    kernel.sem = semmsl semmns semopm semmni
       #
       # 2. The tunable kernel resource of semmsl sets the maximum number
       #    of semaphore per set. The semopm should be set equal to semmsl
       #    so that an operation can be performed on every semaphore in
       #    the set. If semopm is larger than semmsl it should raise an
       #    OS exception but doesn't in Linux.
       #
       #    Oracle8i Installation Manual for UNIX recommends this value be
       #    derived as "... the sum of the PROCESSES parameter for each
       #    Oracle database except the largest one, plus 2 times the largest
       #    PROCESSES value, plus 10 times the number of Oracle databases."
       #    Assuming 2 Oracle8i databases with the init{SID}.ora "processes"
       #    parameter set to 100 and 1 Oracle 9iAS server with "processes"
       #    parameter set to 100, the following is the recommended value:
       #
       #    Variables:
       #    =========
       #    s = sum of processes for all but largest instance
       #    m = maximum number of process for a single instance
       #    n = total number of instances
       #    i = n - largest instance.
       #
       #    semmsl = ((s * i) + (m * 2)) + (n * 10))
       #
       #    semmsl = ((100*2) + (100)*2) + (3 * 10)) = (400 + 30) = 430
       #
       #    semopm = semmsl = 430
       #
       # 3. The tunable kernel resource of semmni sets the system wide
       #    semaphore sets by creating a semid_ds control structure of
       #    84 bytes, so this parameter should not be set arbitrarily large.
       #    The Oracle8i and Oracle9i installation manual recommends 100
       #    for each Oracle instance. Assuming 2 Oracle8i databases with
       #    the init{SID}.ora processes parameter set to 100 and 1 Oracle
       #    9iAS server with processes parameter set to 100, the following
       #    is the recommended value:
       #
       #    semmni = 300
       #
       # 4. The semmsl (maximum number of semaphores per identifier) value
       #    is the product of the semmni and semmsl values, as qualified
       #    below:
       #
       #    semmns = (semmni * semmsl) = 300 * 430 = 129000
       #
       # 5. Therefore, semaphores should be set in the /etc/sysctl.conf
       #    file as follows:
       # -------------------------------------------------------------------------
        kernel.sem = 430 129000 430 300
       # -------------------------------------------------------------------------
       # General semaphore rules:
       # -----------------------
       # 1. The "Oracle9i Installation Guide, Release 2 (9.2.0.1.0) for
       #    UNIX Systems: AIX-Based Systems, Compaq Tru64 UNIX, HP 9000
       #    Series HP-UX, Linux Intel, and Sun Solaris" manual (A96167)
       #    advises default settings for shmmin, shmmni, shmseg and
       #    shmvmx shared memory kernel values.
       #
       # 2. The shmmin should be set to 1.
       #
       # 3. The shmmni memory variable sets the maximum number of
       #    system wide shmid_ds structures and should be equal to the
       #    value determined for semmni value.
       #
       #    shmmni = semmni = 300
       #
       # 4. The shmmax should be set to 50% of available memory or 2 GB but
       #    setting above 50% of available memory can cause some memory use
       #    issues in Oracle8i.
       #
       # 5. The shmmin, shmmsg and shmvmx cannot be set when using the
       #    Red Hat Advanced Server 2.1 because alteration of the kernel is
       #    not supported by Oracle and these typically tunable parameters
       #    are fixed in the supported and shipped kernels.
       #
       # -------------------------------------------------------------------------
        kernel.shmmni = 300
        kernel.shmmax = 2147483648
       # -------------------------------------------------------------------------
       # General File Management:
       # -----------------------
       # The default value of 8192 is not compatible with Oracle's file limit
       # of 65536 and should be changed to that value or higher provided memory
       # is available. For example, the typical rule-of-thumb is to divide real
       # memory by 16,384, or 64 simultaneous open files per 1 MB of memory.
       # In systems with large amounts of memory, concurrency of file access
       # would be a better rule-of-thumb. The value is set based on 2 GB of
       # real memory as follows below.
       #
       #    fs.file-max = ( 2,097,152,000 / 16384 ) = 128,000
       #
       # Using the 2.2.x Linux kernel you will need to set the inode-max
       # value to 4 to 5 times the file-max value. However, beginning with the
       # 2.4.x Linux kernel inode-max is managed dynamically and should not be
       # set in the /etc/sysctl.conf file.
       # -------------------------------------------------------------------------
        fs.file-max=128000
       Reboot to effect the changes.
       Validate kernel boot parameters.
       The following command enables validation of kernel parameters that are set in the /etc/sysctl.conf file that are processed at boot time.
       # sysctl -p | grep kernel
       kernel.sysrq = 0
       kernel.core_uses_pid = 1
       kernel.sem = 430 129000 430 300
       kernel.shmmni = 300
       kernel.shmmax = 2147483648 


Referensi

I/O Scheduler

Pranala Menarik