一、下载解压并打上内核补丁
  我以2.6.10为例子,patche以bk4的例子,目的只是让大家知道怎么打patch,其实本人用的是2.6.6的内核,因为在AS3.0上升级到2.6.9以上的内核,mount大的nfs网络硬盘时,df 显示不正确,明明是800G的盘变成4.2G,不过还是能正常用,我升级过nfs和mount的包都没用,/var/log/message里提示是kernel: nfs warning: mount version older than kernel, 还望知道的告知一声,谢 :) BTW:2.6.8的内核没用过
  
  内核源代码:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.10.tar.bz2
  最新内核补丁:http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/patch-2.6.10-bk4.bz2
  
  cd /usr/src
  rm -rf linux
  tar jxf /download/linux-2.6.10.tar.bz2
  ln -s linux-2.6.10 linux
  cd linux
  bunzip2 -dv /download/patch-2.6.10-bk4.bz2 |patch -p1
  如果在/usr/src目录下就用patch -p0
  
  二、修改内核源代码 (升级2.6就是为了优化,干脆连源代码也改了吧)
  
  1.修改/usr/src/linux/include/linux/posix_types.h
  设置fd_set支持的最大数量
  #define __FD_SETSIZE 1024 ---> 65536
  
  2.修改/usr/src/linux/include/linux/fs.h
  设置最大打开文件数量(TCP连接数量)
  #define INR_OPEN 1024 ---> 65536
  #define NR_FILE 8192 ---> 65536
  #define NR_RESERVED_FILES 10 ---> 128
  
  3.修改/usr/src/linux/include/net/tcp.h
  设置TIMEOUT的时间为1秒
  #define TCP_TIMEWAIT_LEN (60*HZ) 60 ---> 1*HZ
  设置在backlog队列里的半连接的重试次数,每次都会花相应的时间,本质上也是减少重试时间
  #define TCP_SYNACK_RETRIES 5 ---> 3
  
  针对RHEL-AS3本来就是稳定+优化的,不过就算你用 RHEL-AS3 自己的内核,那也要修改一下上面的参数才好呀 :)

  
  三、安装必要的工具
  
  1.下载module-init-tools-3.1.tar.bz2
  http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.1.tar.bz2
  代码:
    ./configure --prefix=/
    make moveold
    make all install
    ./generate-modprobe.conf /etc/modprobe.conf
  
  2.下载新的mkinitrd
  ftp://195.220.108.108/linux/6/fedora/core/3/i386/os/Fedora/RPMS/mkinitrd-4.1.18-2.i386.rpm
  它需要lvm2 device-mapper
  ftp://195.220.108.108/linux/6/fedora/core/3/i386/os/Fedora/RPMS/device-mapper-1.00.19-2.i386.rpm
  ftp://195.220.108.108/linux/6/fedora/core/3/i386/os/Fedora/RPMS/lvm2-2.00.25-1.01.i386.rpm
  如果不更新这个包在make install时会提示以下错误:
  代码:
    No module mptbase found for kernel 2.6.10-bk4, aborting.
    mkinitrd failed
    make[1]: *** [install] Error 1
    make: *** [install] Error 2
  
  安装lvm2-2.00.25-1.01.i386.rpm时请用rpm -ivh --nodeps package name

四、make menuconfig
代码:
  01.Code maturity level options  --->
    [*] Prompt for development and/or incomplete code/drivers         
    [*] Select only drivers expected to compile cleanly              
  02.General setup --->
    [*] Support for paging of anonymous memory (swap)           
    [*] System V IPC                                 
    [*] POSIX Message Queues                             
    [ ] BSD Process Accounting                           
    [*] Sysctl support                                 
    [ ] Auditing support                                
    [ ] Support for hot-pluggable devices                        
    [*] Kernel Userspace Events                            
    [ ] Kernel .config support                             
    [*] Configure standard kernel features (for small systems) --->  
     [*] Load all symbols for debugging/kksymoops                    
       [ ]  Do an extra kallsyms pass                           
       [*]  Enable futex support                              
       [*]  Enable eventpoll support                            
       [ ]  Optimize for size                                
       [*]  Use full shmem filesystem
  03.Loadable module support --->     
    [*] Enable loadable module support                     
    [*]  Module unloading                            
    [ ]  Forced module unloading                       
    [ ]  Module versioning support (EXPERIMENTAL)                
    [ ]  Source checksum for all modules                    
    [*]  Automatic kernel module loading
  04.Processor type and features ---> 
      Subarchitecture Type (PC-compatible) --->  
      Processor family (Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon) --->  
    [*] Generic x86 support                  
    [ ] HPET Timer Support                   
    [*] Symmetric multi-processing support   多CPU        
    (8)  Maximum number of CPUs (2-255)            
    [*]  SMT (Hyperthreading) scheduler support        
    [*] Preemptible Kernel           抢占式内核,请选上它  
    [ ] Machine Check Exception                
    < > Toshiba Laptop support                 
    < > Dell laptop support                  
    < > /dev/cpu/microcode - Intel IA32 CPU microcode support 
    < > /dev/cpu/*/msr - Model-specific register support    
    < > /dev/cpu/*/cpuid - CPU information support       
      Firmware Drivers --->                 
      High Memory Support (4GB) --->     高内存       
    [ ] Allocate 3rd-level pagetables from highmem       
    [ ] Math emulation                     
    [*] MTRR (Memory Type Range Register) support       
    [*] Enable kernel irq balancing              
    [ ] Use register arguments (EXPERIMENTAL)    
  05.Power management options (ACPI, APM) --->  电源管理 自定 (偶没选)
  06.Bus options (PCI, PCMCIA, EISA, MCA, ISA) ---> 板卡支持 自定
    [*] PCI support                                  
    PCI access mode (Any) --->                        
    [ ] Message Signaled Interrupts (MSI and MSI-X)                
    [*] Legacy /proc/pci interface                          
    [*] PCI device name database                           
    [ ] ISA support                                  
    [ ] MCA support                                  
    < > NatSemi SCx200 support
  07.Executable file formats --->
    [*] Kernel support for ELF binaries                        
    <M> Kernel support for a.out and ECOFF binaries                 
    <M> Kernel support for MISC binaries    
  08.Device Drivers --->  设备驱动及网络支持
     Generic Driver Options ---> 默认
      [*] Select only drivers that don't need compile-time external firmware          
      [*] Prevent firmware from being built                   
     Memory Technology Devices (MTD) ---> 不选
     Parallel port support --->  并行端口  自定(偶没选)    
     Plug and Play support --->  支持热插拔 自定(偶没选)
     Block devices --->
      <*> Normal floppy disk support                   
      < > Compaq SMART2 support                     
      < > Compaq Smart Array 5xxx support                
      < > Mylex DAC960/DAC1100 PCI RAID Controller support        
      < > Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL) 
      <M> Loopback device support                    
      < > Cryptoloop Support                      
      <M> Network block device support                  
      < > Promise SATA SX8 support                    
      <M> RAM disk support                        
      (16) Default number of RAM disks                 
      (4096) Default RAM disk size (kbytes)               
      () Source directory of cpio_list                 
      [ ] Support for Large Block Devices                
      < > Packet writing on CD/DVD media                 
         IO Schedulers --->  IO调度器,都选上吧 可以在grub.conf指定用IO调度哪种方式,后面会讲的        
           <*> Anticipatory I/O scheduler               
           <*> Deadline I/O scheduler                 
           <*> CFQ I/O scheduler      
     ATA/ATAPI/MFM/RLL support --->  ATA设备 自定 (偶没选)
     SCSI device support --->    SCSI设备 自定我有scsi的设备所以有以下选项
      <*> SCSI device support                                
      [*]  legacy /proc/scsi/ support                            
      ---  SCSI support type (disk, tape, CD-ROM)                      
      <*>  SCSI disk support                
     因为偶式MPT的SCSI,所以以下都没选,省略之
     Multi-device support (RAID and LVM) ---> 支持RAID和LVM(逻辑卷) 自定
      [*] Multiple devices driver support (RAID and LVM)    
      <*>  RAID support                    
      < >   Linear (append) mode               
      <*>   RAID-0 (striping) mode              
      < >   RAID-1 (mirroring) mode             
      < >   RAID-10 (mirrored striping) mode (EXPERIMENTAL) 
      <*>   RAID-4/RAID-5 mode                
      < >   RAID-6 mode (EXPERIMENTAL)            
      <*>   Multipath I/O support              
      < >   Faulty test module for MD            
      <*>  Device mapper support               
      < >   Crypt target support               
      < >   Snapshot target (EXPERIMENTAL)          
      < >   Mirror target (EXPERIMENTAL)           
      < >   Zero target (EXPERIMENTAL)         
     Fusion MPT device support --->  偶的SCSI是这个,所以选了 还是自定        
         <*> Fusion MPT (base + ScsiHost) drivers                 
      (40) Maximum number of scatter gather entries               
      <*>  Fusion MPT misc device (ioctl) driver  
     IEEE 1394 (FireWire) support ---> 自定 (偶没选)
     I2O device support --->   自定 (偶没选)
     Networking support --->   网络选项
        [*] Networking support                                 
         Networking options --->                    
               <*> Packet socket                                    
           [ ]  Packet socket: mmapped IO                             
           < > Netlink device emulation                              
           <*> Unix domain sockets    如果你有网络就选                           
           < > PF_KEY sockets                                   
           [*] TCP/IP networking                                  
           [ ]  IP: multicasting                                 
           [ ]  IP: advanced router                                
           [ ]  IP: kernel level autoconfiguration                        
           < >  IP: tunneling                                   
           < >  IP: GRE tunnels over IP                              
           [ ] IP: ARP daemon support (EXPERIMENTAL)                        
           [*] IP: TCP syncookie support (disabled per default)   能防DOS攻击,但会降低一点性能,总的说性价比不错              
           < > IP: AH transformation                                
           < > IP: ESP transformation                               
           < > IP: IPComp transformation                              
           < > IP: tunnel transformation                              
           <*> IP: TCP socket monitoring interface                         
           IP: Virtual Server Configuration --->          lvs 支持              
           < > The IPv6 protocol (EXPERIMENTAL)                          
           [*] Network packet filtering (replaces ipchains) --->  包过滤省略(知道的自己选,不熟悉的都选上) 
                      以下都没选,省略
        [ ] Amateur Radio support --->                            
      < > IrDA (infrared) subsystem support --->                      
      < > Bluetooth subsystem support --->                         
      [*] Network device support                               
      < >  Dummy net driver support        这个是nis服务器的吧,不大清楚,没用过                     
      <*>  Bonding driver support         双网卡绑定的                     
      < >  EQL (serial line load balancing) support                     
      < >  Universal TUN/TAP device driver support           
         ARCnet devices --->                               
         Ethernet (10 or 100Mbit) --->                          
         Ethernet (1000 Mbit) --->            
           < > Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support                  
           < > D-Link DL2000-based Gigabit Ethernet support                       
           < > Intel(R) PRO/1000 Gigabit Ethernet support                        
           < > National Semiconduct DP83820 support                           
           < > Packet Engines Hamachi GNIC-II support                          
           < > Packet Engines Yellowfin Gigabit-NIC support (EXPERIMENTAL)               
           < > Realtek 8169 gigabit ethernet support                          
           < > Marvell Yukon Chipset / SysKonnect SK-98xx Support                    
           <*> Broadcom Tigon3 support  
        以下都没选,省略  
    ISDN subsystem --->                     
    Telephony Support --->
    Input device support --->                     
     Character devices --->                        
    I2C support --->       
    Dallas's 1-wire bus --->   
    Misc devices --->       
    Multimedia devices --->    
    Graphics support --->     
    Sound --->          
    USB support --->       
    MMC/SD Card support --->  以上都没选,需要的自己选
  09.File systems --->    文件系统   
    < > Second extended fs support                                
    <*> Ext3 journalling file system support                          
    [ ]  Ext3 extended attributes                               
    [*] JBD (ext3) debugging support                              
    < > Reiserfs support                                    
    < > JFS filesystem support                                 
    < > XFS filesystem support                                 
    < > Minix fs support                                    
    < > ROM file system support                                
    [ ] Quota support                                     
    < > Kernel automounter support                               
    <*> Kernel automounter version 4 support (also supports v3)                
      CD-ROM/DVD Filesystems --->                       
        <*> ISO 9660 CDROM file system support                       
        [ ]  Microsoft Joliet CDROM extensions                      
        [ ]  Transparent decompression extension                     
        < > UDF file system support 
      DOS/FAT/NT Filesystems --->       floppy要用到的文件格式
        <*> MSDOS fs support                                                          
        <*> VFAT (Windows-95) fs support                          
        (437) Default codepage for FAT (NEW)                        
        (iso8859-1) Default iocharset for FAT (NEW)                    
        < > NTFS file system support                             
      Pseudo filesystems --->
        [*] /proc file system support               proc文件系统支持               
        [ ]  /proc/kcore support                                
        [ ] /dev file system support (OBSOLETE)                         
        [ ] /dev/pts Extended Attributes                            
        [*] Virtual memory file system support (former shm fs)   虚拟内存支持               
        [ ]  tmpfs Extended Attributes                             
        [ ] HugeTLB file system support                               
      Miscellaneous filesystems --->                   
      Network File Systems --->                             
        <*> NFS file system support           nfs客户端支持                               
        [*]  Provide NFSv3 client support                                      
        [ ]  Provide NFSv4 client support (EXPERIMENTAL)                               
        [ ]  Allow direct I/O on NFS files (EXPERIMENTAL)                            
        < > NFS server support              nfs服务端支持                      
        < > Secure RPC: Kerberos V mechanism (EXPERIMENTAL)                           
        < > Secure RPC: SPKM3 mechanism (EXPERIMENTAL)                              
        < > SMB file system support (to mount Windows shares etc.)    samba支持                
        < > CIFS support (advanced network filesystem for Samba, Window and other CIFS compliant servers)    
        < > NCP file system support (to mount NetWare volumes)                          
        < > Coda file system support (advanced network fs)                            
        < > Andrew File System support (AFS) (Experimental)          
      Partition Types --->    
      Native Language Support --->         自己选   
  10.Profiling support --->               没选                       
  11.Kernel hacking --->                没选              
  12.Security options --->               没选
  13.Cryptographic options --->             没选  
  14.Library routines --->                    
     < > CRC-CCITT functions                
     <*> CRC32 functions                  
     <M> CRC32c (Castagnoli, et al) Cyclic Redundancy-Check


  五、编译安装
  步骤:make -jn(n代表同时编译的进程,可以加快编译速度,n由你的配置决定,我的配置用15-25)
  make modules_install
  make install
  
  六、grub的设置
  设置之前先介绍一下2.6的I/O调度器
  2.6包含的四个I/O调度器分别是No-op I/O scheduler、Anticipatory I/O scheduler、Deadline I/O scheduler与CFQ I/O scheduler。
  在后文中分别简称为ns、as、ds与cfq。
  
  ns是一个简化的调度程序它只作最基本的合并与排序。与桌面系统的关系不是很大,主要用在一些特殊的软件
  与硬件环境下,这些软件与硬件一般都拥有自己的调度机制对内核支持的要求很小,这很适合一些嵌入式系统环境。作为桌面用户我们一般不会选择它。
  
  as是当前内核中默认的I/O调度器。它拥有非常好的性能,在2.5中它就相当引人注意。在与2.4内核进行的对比测试中,在2.4中多项以分钟为单位
  完成的任务,它则是以秒为单位来完成的。正因为如此它成为目前2.6测试版中默认的I/O调度器。但它也存在着弱点,它本身是比较庞大与复杂的,
  在一些特殊的情况下,特别是在数据吞吐量非常大的数据库系统中它会变的比较缓慢。
  
  ds就是针对as的缺点进行改善而来的,还处于测试阶段,但已经很稳定了。目前表现出的性能几乎与as一样好。加之比as更加小巧,
  是相当有前途的调度器,值得一试:)
  
  cfq为系统内的所有任务分配相同的带宽,提供一个公平的工作环境,它比较适合桌面环境。事实上在测试中它也有不错的表现,
  mplayer xmms等多媒体播放器与它配合的相当好,回放平滑几乎没有因访问磁盘而出现的跳帧现象。对于喜欢在Linux下听音乐看电影的朋友不妨尝试一下。
  
  好了,下面说说怎么设置:参数的格式为elevator=调度器名
  
  修改/boot/grub/grub.conf,在kernel那行后门加入elevator=deadline
  例如:kernel /boot/vmlinuz-2.6.10-bk4 ro root=/dev/你的根分区 elevator=deadline
  
  七、reboot