yum定时进行更新系统会导致kernel改变,实际环境并不希望自动对kernel进行更新,通过对yum.conf配置可避免该问题:
# cat /etc/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release
默认配置会更新kernel,可以在该配置后增加--exclude避免对kernel更新:
CentOS7.5/7.6 --exclude kmod-kvdo*,kernel*,centos-release* CentOS7.2-7.4 --exclude initscripts*,kernel*,centos-release* CentOS6.8/6.9 --exclude kernel*,centos-release*
yum更新由cron进行控制,更新的级别由yum-cron.conf或yum-cron-hourly.conf进行配置,不同的是按天或按小时,默认为类型与yum upgrade命令一致
# cat /etc/yum/yum-cron.conf [commands] # What kind of update to use: # default = yum upgrade # security = yum --security upgrade # security-severity:Critical = yum --sec-severity=Critical upgrade # minimal = yum --bugfix update-minimal # minimal-security = yum --security update-minimal # minimal-security-severity:Critical = --sec-severity=Critical update-minimal update_cmd = default --按天更新 $ cat /etc/cron.daily/0yum-daily.cron #!/bin/bash # Only run if this flag is set. The flag is created by the yum-cron init # script when the service is started -- this allows one to use chkconfig and # the standard "service stop|start" commands to enable or disable yum-cron. if [[ ! -f /var/lock/subsys/yum-cron ]]; then exit 0 fi # Action! exec /usr/sbin/yum-cron ---按小时更新 $ cat /etc/cron.hourly/0yum-hourly.cron #!/bin/bash # Only run if this flag is set. The flag is created by the yum-cron init # script when the service is started -- this allows one to use chkconfig and # the standard "service stop|start" commands to enable or disable yum-cron. if [[ ! -f /var/lock/subsys/yum-cron ]]; then exit 0 fi # Action! exec /usr/sbin/yum-cron /etc/yum/yum-cron-hourly.conf
如果更新修改了kernel如何修改?
centos 6.x:
# cat /etc/grub.conf default=0 <<<<title按顺序排号,修改该数据为1为第二个tital内核 timeout=15 #splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal --timeout=10 serial console title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21.el5) root (hd0,0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 dom0_mem=256MB module /vmlinuz-2.6.17-1.2519.4.21.el5 ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5.img title Red Hat Enterprise Linux Server (2.6.17-1.2519.4.21.el5xen) root (hd0,0) kernel /xen.gz-2.6.17-1.2519.4.21.el5 com1=115200,8n1 dom0_mem=256MB module /vmlinuz-2.6.17-1.2519.4.21.el5xen ro root=/dev/VolGroup00/LogVol00 module /initrd-2.6.17-1.2519.4.21.el5xen.img
centos7.x+
---查看可配置内核 # cat /boot/grub2/grub.cfg |grep 'menuentry ' menuentry 'CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1160.el7.x86_64-advanced-09dccbf5-8ad3-440f-beb7-3ff28555b167' { menuentry 'CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1127.el7.x86_64-advanced-4aa22c64-38fe-4c66-87b9-e4f1fa7a7cc2' { menuentry 'CentOS Linux (0-rescue-73e3403620a6477da3634cbacc8e7a6c) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-73e3403620a6477da3634cbacc8e7a6c-advanced-4aa22c64-38fe-4c66-87b9-e4f1fa7a7cc2' { ---当前内核 # grub2-editenv list saved_entry=CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core) ---修改启动顺序 grub2-set-default 'CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)' ---重启 reboot
参考:
https://access.redhat.com/solutions/3089