Linux内核升级,从2.6.18升级到3.2.14
今日在centos上安装jsp环境,即(Nginx+jdk+mysql+tomcat)发现nginx启动后无法访问,于是查看日志,log如下
[root@AY12122501352213a7156 ~]# cat /var/log/nginx/error.log
2013/01/12 16:29:43 [emerg] 32055#0: eventfd() failed (38: Function not implemented)
2013/01/12 16:29:43 [alert] 32054#0: worker process 32055 exited with fatal code 2 and can not be respawn
到网上以查找,原来内核版本太低,没有Linux-native aio,但是最新版Nginx 需要 Linux-native aio 啊,没办法,升级内核吧。
1、查看当前内核版本
[root@AY12122501352213a7156 ~]# uname -r
2.6.18-164.el5
2、下载linux-3.2.14内核包
[root@AY12122501352213a7156 ~]# wget -c http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.14.tar.bz2
[root@AY12122501352213a7156 ~]#tar -jxvf linux-3.2.14.tar.bz2
[root@AY12122501352213a7156 ~]#cd linux-3.2.14
3、配置内核并安装
# make mrproper #清除环境变量,即清除配置文件
# make menuconfig #在菜单模式下选择需要编译的内核模块
一定要勾选(输入y选中,M编译为模块)
a、General setup→[*] enable deprecated sysfs features to support old userspace tools
b、Processor type and features→HighMemory Support。
c、找到以下选中选项并选中networking support → networking options → network packet filtering framework(netfilter)
(1)Corenetfilter configuration
- 勾中"Netfilter connection tracking support" -m state相关模块是依赖它的,不选则没有。
- 将netbios name service protocal support(new) 编译成模块,不然后面升级iptables后启动时会出错
- 勾中"Netfilter Xtables support (required for ip_tables)"
(2)IP: Netfilter Configuration
- 将 "IPv4 connection tracking support (require for NAT)" 编译成模块。
- 勾中IP tables support (required for filtering/masq/NAT) 。
- 将 "Full NAT" 下的 "MASQUERADE target support" 和 "REDIRECT target support" 编译成模块
(3)其它模块可以根据自己的需要进行选择,若不懂可以参考内核配置手册.
# make clean #确保所有东西均保持最新状态.
# make bzImage #生成内核文件
# make modules #编译模块
# make modules_install #安装模块
# make install #安装
注意:编译内核的时候可能会出现如下问题:
cp include/linux/hidraw.h /usr/include/linux/
cp include/linux/hid.h /usr/include/linux/
vi samples/hidraw/hid-example.c
(在Linux下编译程序有时会遇到这种问题,这貌似是一个Linux历史遗留问题:
把所有#include <sys/xxx.h>都提到最前面,把#include <linux/xxx.h>的包含放在其后,就可以编译通过了,之所以出现面的问题是存在循环引用所致。)
将13-15行的如下3行移动到33行以后。
13 #include <linux/types.h>
14 #include <linux/input.h>
15 #include <linux/hidraw.h>
29 #include <sys/ioctl.h>
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <fcntl.h>
33 #include <unistd.h>
vi /usr/include/linux/input.h
line 647
#define BUS_PCI 0x01
#define BUS_ISAPNP 0x02
#define BUS_USB 0x03
#define BUS_HIL 0x04
#define BUS_BLUETOOTH 0x05
/*以下一行为新增*/
#define BUS_VIRTUAL 0x06
#define BUS_ISA 0x10
#define BUS_I8042 0x11
#define BUS_XTKBD 0x12
#define BUS_RS232 0x13
#define BUS_GAMEPORT 0x14
#define BUS_PARPORT 0x15
#define BUS_AMIGA 0x16
#define BUS_ADB 0x17
#define BUS_I2C 0x18
#define BUS_HOST 0x19
#define BUS_GSC 0x1A
/*以下两行为新增*/
#define BUS_ATARI 0x1B
#define BUS_SPI 0x1C
然后重复(1)上面步骤即可完成
4、vim /etc/grub.conf,将 default=1 改为 default=0
# vi /etc/grub.conf# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS Linux (3.2.2)
root (hd0,0)
kernel /vmlinuz-3.2.2 ro root=/dev/mapper/VolGroup-lv_root rd_LVM_LV=VolGroup/lv_root rd_LVM_LV=VolGroup/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-3.2.2.img
title centos (2.6.32-71.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.el6.i686 ro root=/dev/mapper/VolGroup-lv_root rd_LVM_LV=VolGroup/lv_root rd_LVM_LV=VolGroup/lv_swap rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-71.el6.i686.img
5、重启系统,并查看内核
# reboot