Difference between revisions of "OS: Tuning Kernel Scheduler"

From OnnoWiki
Jump to navigation Jump to search
 
(26 intermediate revisions by the same user not shown)
Line 1: Line 1:
Sumber: http://www.techtinker.com/linux/LinuxKernel.html#HowRedHat
+
==Mengapa tune kernel?==
  
 +
Perilaku default kernel UNIX biasanya tidak optimal karena sulit untuk mengantisipasi jenis pekerjaan atau beban kerja yang akan diberikan kepada sistem operasi . Oleh karena itu, UNIX menyediakan parameter yang dapat mengubah alokasi sumber daya. Parameter kernel tuning adalah spesifik UNIX.
  
==Why tune a kernel?==
+
Administrator sistem bertanggung jawab untuk menentukan jenis target pekerjaan dan beban kerja untuk mesin dan untuk memantau apakah terjadi perubahan dari waktu ke waktu. Administrator sistem harus memastikan bahwa setiap parameter kernel diatur untuk mengoptimalkan kinerja mesin.
  
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.
+
CATATAN: Tuning Kernel merupakan topik lanjut dan tidak boleh dilakukan tanpa pemahaman lengkap tentang hal tersebut.
  
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.
+
==Kernel tuning with sysctl==
  
NOTE: Kernel tuning is an advanced topic and should not be done without a complete understanding of the subject.
+
Sumber: http://archive09.linux.com/feature/146599
 +
Oleh Federico Kereki 9 September 2008 (4:00:00 PM)
  
    How to tune Red Hat?
+
Kernel Linux cukup fleksibel, kita bahkan dapat memodifikasi cara kerjanya sambil komputer jalan secara dinamis mengubah beberapa parameter, berkat perintah sysctl. Sysctl menyediakan sebuah antarmuka yang memungkinkan kita untuk memeriksa dan mengubah ratusan parameter kernel di Linux atau BSD. Perubahan segera berlaku, dan bahkan ada cara untuk membuat parameter tersebut tidak hilang setelah reboot. Dengan menggunakan sysctl secara bijak, kita dapat mengoptimalkan komputer tanpa harus mengkompilasi ulang kernel , dan mendapatkan hasilnya dengan cepat.
  
    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.
+
Untuk mendapatkan sedikit rasa parameter apa saja yang dapat di modifikasi oleh sysctl, jalankan sysctl -a
  
Edit the /etc/sysctl.conf file.
+
$ sysctl -a
  
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.
+
Hasilnya
  
  # -------------------------------------------------------------------------
+
  kernel.sched_child_runs_first = 0
  # Kernel parameter assumptions and rationale.
+
  kernel.sched_min_granularity_ns = 1500000
  # ===========================================
+
  kernel.sched_latency_ns = 12000000
        #
+
kernel.sched_wakeup_granularity_ns = 2000000
        # Linux Advanced Server 2.1 has a configure restricted kernel.
+
kernel.sched_tunable_scaling = 1
        #
+
kernel.sched_migration_cost = 500000
        # -------------------------------------------------------------------------
+
kernel.sched_nr_migrate = 32
        # Disables packet forwarding
+
kernel.sched_time_avg = 1000
        # -------------------------------------------------------------------------
+
kernel.sched_shares_window = 10000000
 +
kernel.timer_migration = 1
 +
kernel.sched_rt_period_us = 1000000
 +
kernel.sched_rt_runtime_us = 950000
 +
kernel.sched_autogroup_enabled = 1
 +
kernel.sched_cfs_bandwidth_slice_us = 5000
 +
kernel.panic = 0
 +
... dan seterusnya ...
 +
 
 +
Jika kita ingin mendapatkan nilai hanya satu variabel, gunakan perintah seperti
 +
 
 +
sysctl vm.swappiness
 +
 
 +
atau hanya
 +
 
 +
sysctl vm
  
        net.ipv4.ip_forward = 0
+
untuk daftar semua variabel yang dimulai dengan "vm." Tambahkan opsi -n untuk mengeluarkan hanya nilai variabel, tanpa nama,-N memiliki efek sebaliknya, dan menghasilkan nama-nama tapi tidak nilai.
  
        # -------------------------------------------------------------------------
+
Kita dapat mengubah nlai variabel dengan menggunakan opsi-w dengan sintaks
        # Enables source route verification
 
        # -------------------------------------------------------------------------
 
  
        net.ipv4.conf.default.rp_filter = 1
+
sysctl -w variable=nilai
  
        # -------------------------------------------------------------------------
+
Misalnya,
        # Set the default local port range.
 
        # -------------------------------------------------------------------------
 
  
        net.ipv4.ip_local_port_range = 1024 65000
+
sysctl -w net.ipv6.conf.all.forwarding=1
  
        # -------------------------------------------------------------------------
+
set variabel menjadi benar / true (0 sama dengan "tidak" atau "salah", 1 berarti "ya" atau "benar") sehingga memungkinkan IP6 forwarding. Anda mungkin tidak membutuhkan opsi -w tampaknya akan usang.
        # Enables the magic-sysrq key
 
        # -------------------------------------------------------------------------
 
  
        kernel.sysrq = 1
+
Informasi lebih lanjut tentang sysctl dapat di baca dengan cara mengetik
  
        # -------------------------------------------------------------------------
+
man sysctl
        # 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
 
  
        # -------------------------------------------------------------------------
+
===sysctl dan directory /proc===
        # 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
+
Virtual directory /proc/sys juga memberikan interface ke parameter sysctl memungkinkan kita untuk melihat dan mengubah parameter tersebut. Contoh, file  /proc/sys/vm/swappiness sama dengan parameter vm.swappiness parameter di sysctl.conf. Oleh karenanya, melakukan
        kernel.shmmax = 2147483648
 
  
        # -------------------------------------------------------------------------
+
echo 10 >/proc/sys/vm/swappiness
        # 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
+
sama dengan
  
        Reboot to effect the changes.
+
sysctl -w vm.swappiness=10
  
        Validate kernel boot parameters.
+
Yang perlu kita perhatikan, jika file /proc/sys read-only, maka kita tidak akan bisa mengubahnya juga dengan sysctl.
  
        The following command enables validation of kernel parameters that are set in the /etc/sysctl.conf file that are processed at boot time.
+
Tulis
 
sysctl -a | grep kernel
 
  
Hasilnya
+
ls /proc/sys/kernel
  
kernel.sysrq = 0
+
untuk melihat parameter kernel yang bisa kita ubah.
kernel.core_uses_pid = 1
 
kernel.sem = 430 129000 430 300
 
kernel.shmmni = 300
 
kernel.shmmax = 2147483648
 
  
==Benchmark==
+
===sysctl.conf===
  
* Tbench
+
Nilai paramter sysctl akan di load dari file /etc/sysctl.conf saat boot. File ini dapat memiliki baris kosong, komen (start dengan #), dan baris dengan format "variable=nilai" format. Contoh isi sysctl.conf adalah sebagai berikut,
* Dbench
 
* SPECJbb
 
* Lmbench
 
* Kernbench http://freecode.com/projects/kernbench
 
* Hackbench
 
  
==Kernel tuning with sysctl==
+
# Disable response to broadcasts.
Sumber: http://archive09.linux.com/feature/146599
+
net.ipv4.icmp_echo_ignore_broadcasts = 1
 +
 +
# enable route verification on all interfaces
 +
net.ipv4.conf.all.rp_filter = 1
 +
 +
# enable ipV6 forwarding
 +
net.ipv6.conf.all.forwarding = 1
 +
 +
# increase the number of possible inotify(7) watches
 +
fs.inotify.max_user_watches = 65536
  
By Federico Kereki on September 09, 2008 (4:00:00 PM)
+
Jika kita ingin mengaktifkan / mereload parameter sysctl, dapat dilakukan dengan perintah
  
Share    Print    Comments 
+
sysctl -p.
  
The Linux kernel is flexible, and you can even modify the way it works on the fly by dynamically changing some of its parameters, thanks to the sysctl command. Sysctl provides an interface that allows you to examine and change several hundred kernel parameters in Linux or BSD. Changes take effect immediately, and there's even a way to make them persist after a reboot. By using sysctl judiciously, you can optimize your box without having to recompile your kernel, and get the results immediately.
 
  
To start getting a taste of what sysctl can modify, run sysctl -a and you will see all the possible parameters. The list can be quite long: in my current box there are 712 possible settings.
 
  
$ sysctl -a kernel.panic = 0 kernel.core_uses_pid = 0 kernel.core_pattern = core kernel.tainted = 129 ...many lines snipped...
+
Sumber: http://www.techtinker.com/linux/LinuxKernel.html#HowRedHat
  
If you want to get the value of just a single variable, use something like sysctl vm.swappiness, or just sysctl vm to list all variables that start with "vm." Add the -n option to output just the variable values, without the names; -N has the opposite effect, and produces the names but not the values.
 
  
You can change any variable by using the -w option with the syntax sysctl -w variable=value. For example, sysctl -w net.ipv6.conf.all.forwarding=1 sets the corresponding variable to true (0 equals "no" or "false"; 1 means "yes" or "true") thus allowing IP6 forwarding. You may not even need the -w option -- it seems to be deprecated. Do some experimenting on your own to confirm that.
+
==Contoh Tuning Kernel untuk Oracle9i==
  
For more information, run man sysctl to display the standard documentation.
+
Contoh berikut adalah tuning Linux Kernel sebelum menginstalasi Oracle9i atau Oracle Applications 11i.
  
sysctl and the /proc directory
+
Edit file /etc/sysctl.conf
  
The /proc/sys virtual directory also provides an interface to the sysctl parameters, allowing you to examine and change them. For example, the /proc/sys/vm/swappiness file is equivalent to the vm.swappiness parameter in sysctl.conf; just forget the initial "/proc/sys/" part, substitute dots for the slashes, and you get the corresponding sysctl parameter. (By the way, the substitution is not actually required; slashes are also accepted, though it seems everybody goes for the notation with the dots instead.) Thus, echo 10 >/proc/sys/vm/swappiness is exactly the same as sysctl -w vm.swappiness=10. But as a rule of thumb, if a /proc/sys file is read-only, you cannot set it with sysctl either.
+
vi /etc/sysctl.conf
  
sysctl values are loaded at boot time from the /etc/sysctl.conf file. This file can have blank lines, comments (lines starting either with a "#" character or a semicolon), and lines in the "variable=value" format. For example, my own sysctl.conf file is listed below. If you want to apply it at any time, you can do so with the command sysctl -p.
+
Contoh konfigurasi
  
# Disable response to broadcasts. net.ipv4.icmp_echo_ignore_broadcasts = 1 # enable route verification on all interfaces net.ipv4.conf.all.rp_filter = 1 # enable ipV6 forwarding net.ipv6.conf.all.forwarding = 1 # increase the number of possible inotify(7) watches fs.inotify.max_user_watches = 65536
+
# -------------------------------------------------------------------------
 +
# Kernel parameter assumptions and rationale.
 +
# ===========================================
 +
 +
# -------------------------------------------------------------------------
 +
# 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
  
Getting somewhere?
 
  
With so many tunable parameters, how do you decide what to do? Alas, this is a sore point with sysctl: most of the relevant documentation is hidden in the many source files of the Linux kernel, and isn't easily available, and it doesn't help that the explanations given are sometime arcane and difficult to understand. You may find something in the /usr/src/linux/Documentation/sysctl directory, but most (if not all) files there refer to kernel 2.2, and seemingly haven't been updated in the last several years.
+
Reboot agar perubahan parameter berefek.
  
Looking around for books on the subject probably won't help much. I found hack #71 in O'Reilly's Linux Server Hacks, Volume 2, from 2005, but that was about it. Several other books include references to sysctl, but as to specific parameters or hints, you are on your own.
+
Validasi kernel boot parameter. Setelah booting, cek menggunakan perintah berikut,
 +
 +
sysctl -p | grep kernel
  
As an experiment, I tried looking for information on the swappiness parameter, which can optimize virtual memory management. The /usr/src/Linux/Documentation/sysctl/vm.txt file didn't even refer to it, probably because this parameter appeared around version 2.6 of the kernel. Doing a general search in the complete /usr/src/linux directory turned up five files that mention "swappiness": three "include" (.h) files in include/linux, plus kernel/sysctl.c and mm/vmscan.c. The latter file included the information:
+
Hasilnya
  
/* * From 0 .. 100. Higher means more swappy. */ int vm_swappiness = 60;
+
kernel.sysrq = 0
 +
kernel.core_uses_pid = 1
 +
kernel.sem = 430 129000 430 300
 +
kernel.shmmni = 300
 +
kernel.shmmax = 2147483648
  
That was it! You can see the default value (60) and a minimal reference to the field meaning. How helpful is that?
+
==Benchmark==
  
My suggestion would be to use sysctl -a to learn the available parameters, then Google around for extra help. You may find, say, an example of changing the shared memory allocation to solve a video program problem, or an explanation on vm.swappiness, or even more suggestions for optimizing IP4 network traffic.
+
* Lmbench http://www.bitmover.com/lmbench/get_lmbench.html
  
sysctl shows yet another aspect of the great flexibility of Linux systems. While documentation for it is not widely available, learning its features and capabilities on your own can help you get even more performance out of your box. That's system administration at its highest (or lowest?) level.
+
===Kadaluarsa===
Federico Kereki is an Uruguayan systems engineer with more than 20 years' experience developing systems, doing consulting work, and teaching at universities.
 
  
 +
* Kernbench http://freecode.com/projects/kernbench
 +
* Tbench
 +
* Dbench
 +
* SPECJbb
 +
* Hackbench
  
 
==Referensi==
 
==Referensi==
Line 247: Line 299:
  
 
==Pranala Menarik==
 
==Pranala Menarik==
 +
 +
* [[Linux]]
 +
* [[Ubuntu]]
 +
* [[Buku Sistem Operasi]]
 +
 +
===Secara Umum===
 +
 +
* [[Sistem Operasi]]
 +
 +
===Instalasi Linux===
 +
 +
* [[Linux: CLI untuk Survival]]
 +
* [[Linux: Skema Partisi di Linux]]
 +
* [[Linux: Instalasi Sistem Operasi]]
 +
* [[Membuat Repository Ubuntu Lokal menggunakan debmirror]]
 +
 +
===Compile Kernel===
 +
 +
* [[Kernel]]
 +
* [[OS: Linux Kernel]]
 +
* [[Kernel: Anatomi Kernel Source]]
 +
* [[Compile Kernel]]
 +
* [[Compile Kernel: Konfigurasi Kernel]]
 +
 +
===Remaster Linux===
 +
 +
* [[Cara Cepat Melakukan Remastering Ubuntu]]
 +
 +
===Sistem Operasi untuk Embedded===
 +
 +
* [[OpenWRT]]
 +
* [[OpenWRT: Download Firmware yang sudah jadi]]
 +
* [[OpenWRT: Source Repository Download]]
 +
* [[OpenWRT: Melihat Daftar Package]]
 +
 +
====Membuat Firmware Sendiri====
 +
 +
* [[OpenWRT: Build Firmware]]
 +
* [[OpenWRT: Build Firmware Buffalo WZRHPG450H]]
 +
* [[OpenWRT: Build Firmware Buffalo WZRHPG300N]]
 +
* [[OpenWRT: Build Firmware Ubiquiti NanoStation2]]
 +
* [[OpenWRT: Build Firmware Mikrotik RB433]]
 +
* [[OpenWRT: Build Firmware Linksys WRT160NL]]
 +
* [[OpenWRT: Build Firmware Linksys WRT54GL]]
 +
 +
====Flash ke Device====
 +
 +
* [[OpenWRT: Flash Linksys WRT54GL]]
 +
* [[OpenWRT: Flash Buffalo WZRHP450H]]
 +
* [[OpenWRT: Flash Buffalo WZRHP300N]]
 +
* [[OpenWRT: Flash UBNT NanoStation2]]
 +
* [[OpenWRT: Flash Linksys WRT160NL]]
 +
 +
====Beberapa Tip====
 +
 +
* [[OpenWRT: Mikrotik RB433]]
 +
* [[OpenWRT: 3G modem]]
 +
* [[OpenWRT: Build Firmware dengan 3G Modem Support]]
 +
* [[OpenWRT: Setup Firewall]]
 +
* [[OpenWRT: Konfigurasi UBNT NanoStation2 tanpa WebGUI]]
 +
 +
===Tuning Kernel===
 +
 +
* [[OS: Parameter Kernel Default]]
 +
 +
====Tuning Kernel Scheduler====
 +
 +
* [[OS: Kernel Scheduler]]
 +
* [[OS: Tuning Kernel Scheduler]]
 +
* [[OS: Tuning Completely Fair scheduler CFS]]
 +
* [[OS: Complete Teori Tuning Kernel Scheduler]]
 +
 +
====Tuning I/O Scheduler====
 +
 +
* [[OS: Tuning Completely Fair Queueing CFQ I/O scheduler]]
 +
* [[OS: Complete Teori Tuning I/O Performance]]
 +
 +
====Tuning Manajemen Memory====
 +
 +
* [[OS: Tuning Manajemen Memory]]
 +
 +
===Android===
 +
 +
* [[OS: Android - Download]]
 +
 +
===Membuat Kernel Module===
 +
 +
* [[OS: Mengerti System Call]]
 +
* [[OS: Membuat Kernel Modul]]
 +
 +
===Monitoring & Benchmark===
  
 
* [[OS: Build in Monitoring Tool]]
 
* [[OS: Build in Monitoring Tool]]
 +
* [[Linux Benchmarking]]
 +
* [[OS: Benchmarking menggunakan UnixBench]]
 +
* [[OS: Benchmarking menggunakan LLCBench]]

Latest revision as of 05:42, 9 May 2013

Mengapa tune kernel?

Perilaku default kernel UNIX biasanya tidak optimal karena sulit untuk mengantisipasi jenis pekerjaan atau beban kerja yang akan diberikan kepada sistem operasi . Oleh karena itu, UNIX menyediakan parameter yang dapat mengubah alokasi sumber daya. Parameter kernel tuning adalah spesifik UNIX.

Administrator sistem bertanggung jawab untuk menentukan jenis target pekerjaan dan beban kerja untuk mesin dan untuk memantau apakah terjadi perubahan dari waktu ke waktu. Administrator sistem harus memastikan bahwa setiap parameter kernel diatur untuk mengoptimalkan kinerja mesin.

CATATAN: Tuning Kernel merupakan topik lanjut dan tidak boleh dilakukan tanpa pemahaman lengkap tentang hal tersebut.

Kernel tuning with sysctl

Sumber: http://archive09.linux.com/feature/146599 Oleh Federico Kereki 9 September 2008 (4:00:00 PM)

Kernel Linux cukup fleksibel, kita bahkan dapat memodifikasi cara kerjanya sambil komputer jalan secara dinamis mengubah beberapa parameter, berkat perintah sysctl. Sysctl menyediakan sebuah antarmuka yang memungkinkan kita untuk memeriksa dan mengubah ratusan parameter kernel di Linux atau BSD. Perubahan segera berlaku, dan bahkan ada cara untuk membuat parameter tersebut tidak hilang setelah reboot. Dengan menggunakan sysctl secara bijak, kita dapat mengoptimalkan komputer tanpa harus mengkompilasi ulang kernel , dan mendapatkan hasilnya dengan cepat.

Untuk mendapatkan sedikit rasa parameter apa saja yang dapat di modifikasi oleh sysctl, jalankan sysctl -a

$ sysctl -a

Hasilnya

kernel.sched_child_runs_first = 0
kernel.sched_min_granularity_ns = 1500000
kernel.sched_latency_ns = 12000000
kernel.sched_wakeup_granularity_ns = 2000000
kernel.sched_tunable_scaling = 1
kernel.sched_migration_cost = 500000
kernel.sched_nr_migrate = 32
kernel.sched_time_avg = 1000
kernel.sched_shares_window = 10000000
kernel.timer_migration = 1
kernel.sched_rt_period_us = 1000000
kernel.sched_rt_runtime_us = 950000
kernel.sched_autogroup_enabled = 1
kernel.sched_cfs_bandwidth_slice_us = 5000
kernel.panic = 0
... dan seterusnya ...

Jika kita ingin mendapatkan nilai hanya satu variabel, gunakan perintah seperti

sysctl vm.swappiness

atau hanya

sysctl vm

untuk daftar semua variabel yang dimulai dengan "vm." Tambahkan opsi -n untuk mengeluarkan hanya nilai variabel, tanpa nama,-N memiliki efek sebaliknya, dan menghasilkan nama-nama tapi tidak nilai.

Kita dapat mengubah nlai variabel dengan menggunakan opsi-w dengan sintaks

sysctl -w variable=nilai

Misalnya,

sysctl -w net.ipv6.conf.all.forwarding=1

set variabel menjadi benar / true (0 sama dengan "tidak" atau "salah", 1 berarti "ya" atau "benar") sehingga memungkinkan IP6 forwarding. Anda mungkin tidak membutuhkan opsi -w tampaknya akan usang.

Informasi lebih lanjut tentang sysctl dapat di baca dengan cara mengetik

man sysctl


sysctl dan directory /proc

Virtual directory /proc/sys juga memberikan interface ke parameter sysctl memungkinkan kita untuk melihat dan mengubah parameter tersebut. Contoh, file /proc/sys/vm/swappiness sama dengan parameter vm.swappiness parameter di sysctl.conf. Oleh karenanya, melakukan

echo 10 >/proc/sys/vm/swappiness

sama dengan

sysctl -w vm.swappiness=10

Yang perlu kita perhatikan, jika file /proc/sys read-only, maka kita tidak akan bisa mengubahnya juga dengan sysctl.

Tulis

ls /proc/sys/kernel

untuk melihat parameter kernel yang bisa kita ubah.

sysctl.conf

Nilai paramter sysctl akan di load dari file /etc/sysctl.conf saat boot. File ini dapat memiliki baris kosong, komen (start dengan #), dan baris dengan format "variable=nilai" format. Contoh isi sysctl.conf adalah sebagai berikut,

# Disable response to broadcasts.
net.ipv4.icmp_echo_ignore_broadcasts = 1

# enable route verification on all interfaces
net.ipv4.conf.all.rp_filter = 1

# enable ipV6 forwarding
net.ipv6.conf.all.forwarding = 1

# increase the number of possible inotify(7) watches
fs.inotify.max_user_watches = 65536

Jika kita ingin mengaktifkan / mereload parameter sysctl, dapat dilakukan dengan perintah

sysctl -p.


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


Contoh Tuning Kernel untuk Oracle9i

Contoh berikut adalah tuning Linux Kernel sebelum menginstalasi Oracle9i atau Oracle Applications 11i.

Edit file /etc/sysctl.conf

vi /etc/sysctl.conf

Contoh konfigurasi

# -------------------------------------------------------------------------
# Kernel parameter assumptions and rationale.
# ===========================================

# -------------------------------------------------------------------------
# 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 agar perubahan parameter berefek.

Validasi kernel boot parameter. Setelah booting, cek menggunakan perintah berikut,

sysctl -p | grep kernel

Hasilnya

kernel.sysrq = 0
kernel.core_uses_pid = 1
kernel.sem = 430 129000 430 300
kernel.shmmni = 300
kernel.shmmax = 2147483648

Benchmark

Kadaluarsa

Referensi

I/O Scheduler

Pranala Menarik

Secara Umum

Instalasi Linux

Compile Kernel

Remaster Linux

Sistem Operasi untuk Embedded

Membuat Firmware Sendiri

Flash ke Device

Beberapa Tip

Tuning Kernel

Tuning Kernel Scheduler

Tuning I/O Scheduler

Tuning Manajemen Memory

Android

Membuat Kernel Module

Monitoring & Benchmark