- 인쇄
- PDF
CentOS 7
- 인쇄
- PDF
VPC 환경에서 이용 가능합니다.
네이버 클라우드 플랫폼 CentOS 7 서버의 커널 업데이트 방법을 설명합니다.
이 가이드는 네이버 클라우드 플랫폼에서 신규 생성한 서버를 기준으로 작성했기 때문에 사용자 서버 환경과 차이가 있을 수 있습니다. 사용자 서버 환경은 보안 하드닝 작업이나 여러 설정 작업 등 다양한 이유로 커널 업데이트 작업 및 서버 재시작에 영향을 받을 수 있습니다. 따라서 다음 사항을 확인한 후 커널 업데이트를 수행해 주십시오.
- 실제 서버의 커널을 업데이트하기 전에 서버 이미지를 사용하여 복제 서버를 생성합니다. 생성한 복제 서버에서 커널 업데이트를 수행하고 정상적으로 재시작이 되는지 확인합니다. 재시작 후 운영 상태로 전환이 되면 서비스에 문제가 없는지 확인합니다. 충분히 검증한 후에 문제가 없을 경우에만 서버 커널 업데이트를 수행해 주십시오.
- GPU 서버의 경우, 커널 버전에 맞는 GPU 드라이버가 설치되어 있어야만 정상적으로 동작합니다. 업데이트한 커널이 GPU 드라이버와 호환되지 않을 경우 GPU 서버가 정상 동작하지 않을 수 있습니다. 따라서 GPU 드라이버 호환성을 확인한 후 커널 업데이트를 수행해 주십시오. 관련 정보는 GPU 드라이버 가이드를 확인해 주십시오.
- NCP Repo는 VPC Private Subnet 등 외부 접속이 원활하지 않은 사용자 환경을 지원하기 위해 네이버 클라우드 플랫폼에서 제공하는 리포지토리입니다. NCP Repo는 최신 패키지를 제공하지 않을 수 있습니다.
네이버 클라우드 플랫폼에서 모든 커널 버전의 업데이트를 테스트한 것은 아닙니다. 2024년 1월 1일 기준으로 CentOS 7에 커널 업데이트 적용 테스트한 버전은 3.10.0-1160.102.1.el7.x86_64 입니다.
- 사용자 서버 커널 업데이트는 전적으로 사용자의 책임 하에 수행되어야 하며, 커널 업데이트로 인해 발생하는 문제에 대해 네이버 클라우드 플랫폼에서 책임지지 않습니다.
- 커널 업데이트 및 재시작 중에는 서버의 정상적인 사용이 불가능할 수 있으며 이에 따른 복구는 지원하지 않습니다. 또한 커널 업데이트 실패 시 서버 복구를 지원하지 않습니다.
- 커널을 업데이트 전 서버 이미지를 통해 생성한 백업본은 백업이 필요 없을 때까지 보관해 주십시오.
- 이 가이드와 관련된 문제에 대해서는 별도 지원이 제공되지 않습니다.
커널 업데이트
CentOS 7.3, CentOS 7.8 서버의 커널을 업데이트하는 방법은 다음과 같습니다.
- 커널 업데이트를 적용할 서버에 원격 접속해 주십시오.
- 서버의 커널 버전을 확인해 주십시오.
- CentOS 7.3
[root@centos73 ~]# uname -r 3.10.0-514.2.2.el7.x86_64
- CentOS 7.8
[root@centos78 ~]# uname -r 3.10.0-1127.10.1.el7.x86_64
- 서버에 연결된 리포지토리 정보를 확인해 주십시오.
[root@centos78 ~]# grep ^baseurl /etc/yum.repos.d/CentOS-Base.repo baseurl=http://mirror.ncloud.com/centos/$releasever/os/$basearch baseurl=http://mirror.ncloud.com/centos/$releasever/updates/$basearch/ baseurl=http://mirror.ncloud.com/centos/$releasever/extras/$basearch/ baseurl=http://mirror.ncloud.com/centos/$releasever/centosplus/$basearch/ baseurl=http://mirror.ncloud.com/centos/$releasever/contrib/$basearch/
- yum-config-manager를 사용해서 Repo 파일을 다운로드해 주십시오.
- CentOS 7.3
yum-config-manager를 사용하기 위해서 yum-utils 패키지를 먼저 설치한 후, Repo 파일을 다운로드해 주십시오.
[root@centos73 ~]# rpm -qa | grep yum-utils | wc -l 0 [root@centos73 ~]# yum install yum-utils Loaded plugins: fastestmirror Determining fastest mirrors Resolving Dependencies --> Running transaction check ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch --> Running transaction check ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch --> Running transaction check ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================================================================= Installing: yum-utils noarch 1.1.31-54.el7_8 base 122 k Installing for dependencies: python-chardet noarch 2.2.1-3.el7 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k Transaction Summary ================================================================================================================================================================================================= Install 1 Package (+2 Dependent packages) Total download size: 616 k Installed size: 2.8 M Is this ok [y/d/N]: y ... 생략 ... Installed: yum-utils.noarch 0:1.1.31-54.el7_8 Dependency Installed: python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7 Complete! [root@centos73 ~]# yum-config-manager --add-repo http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo Loaded plugins: fastestmirror adding repo from: http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo grabbing file http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo to /etc/yum.repos.d/CentOS-Base.repo repo saved to /etc/yum.repos.d/CentOS-Base.repo
- CentOS 7.8
[root@centos78 ~]# yum-config-manager --add-repo http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo Loaded plugins: fastestmirror, langpacks adding repo from: http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo grabbing file http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo to /etc/yum.repos.d/CentOS-Base.repo repo saved to /etc/yum.repos.d/CentOS-Base.repo
- CentOS 7.3
- 변경된 리포지토리 정보를 확인해 주십시오.
[root@centos78 ~]# grep ^baseurl /etc/yum.repos.d/CentOS-Base.repo baseurl=http://repo.ncloud.com/centos/$releasever/os/$basearch baseurl=http://repo.ncloud.com/centos/$releasever/updates/$basearch/ baseurl=http://repo.ncloud.com/centos/$releasever/extras/$basearch/ baseurl=http://repo.ncloud.com/centos/$releasever/centosplus/$basearch/ baseurl=http://repo.ncloud.com/centos/$releasever/contrib/$basearch/
- 리포지토리에서 제공하는 커널 버전을 확인해 주십시오.
[root@centos78 ~]# rm -rf /var/cache/yum/* [root@centos78 ~]# yum list kernel-3.10.0-1160.102.1.el7 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Available Packages kernel.x86_64 3.10.0-1160.102.1.el7 update
- 최신 버전의 커널을 설치해 주십시오.
신규 설치 패키지, 업데이트 패키지, 삭제 패키지 목록을 상세하게 확인한 후 이상이 없을 경우y
를 입력하여 설치를 완료해 주십시오.- CentOS 7.3
[root@centos73 ~]# yum install kernel-3.10.0-1160.102.1.el7 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package kernel.x86_64 0:3.10.0-1160.102.1.el7 will be installed --> Processing Dependency: linux-firmware >= 20190429-72 for package: kernel-3.10.0-1160.102.1.el7.x86_64 --> Running transaction check ... 생략 ... Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: kernel x86_64 3.10.0-1160.102.1.el7 update 52 M Updating: kexec-tools x86_64 2.0.15-51.el7_9.3 update 351 k selinux-policy-targeted noarch 3.13.1-268.el7_9.2 update 7.0 M Updating for dependencies: libselinux x86_64 2.5-15.el7 base 162 k libselinux-devel x86_64 2.5-15.el7 base 187 k libselinux-python x86_64 2.5-15.el7 base 236 k libselinux-utils x86_64 2.5-15.el7 base 151 k libsemanage x86_64 2.5-14.el7 base 151 k libsepol x86_64 2.5-10.el7 base 297 k libsepol-devel x86_64 2.5-10.el7 base 77 k linux-firmware noarch 20200421-80.git78c0348.el7_9 update 80 M policycoreutils x86_64 2.5-34.el7 base 917 k selinux-policy noarch 3.13.1-268.el7_9.2 update 498 k Transaction Summary ============================================================================================================================================================================ Install 1 Package Upgrade 2 Packages (+10 Dependent packages) Total download size: 142 M Is this ok [y/d/N]: y ... 생략 ... Installed: kernel.x86_64 0:3.10.0-1160.102.1.el7 Updated: kexec-tools.x86_64 0:2.0.15-51.el7_9.3 selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2 Dependency Updated: libselinux.x86_64 0:2.5-15.el7 libselinux-devel.x86_64 0:2.5-15.el7 libselinux-python.x86_64 0:2.5-15.el7 libselinux-utils.x86_64 0:2.5-15.el7 libsemanage.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 libsepol-devel.x86_64 0:2.5-10.el7 linux-firmware.noarch 0:20200421-80.git78c0348.el7_9 policycoreutils.x86_64 0:2.5-34.el7 selinux-policy.noarch 0:3.13.1-268.el7_9.2 Complete!
- CentOS 7.8
[root@centos78 ~]# yum install kernel-3.10.0-1160.102.1.el7 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package kernel.x86_64 0:3.10.0-1160.102.1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================ Installing: kernel x86_64 3.10.0-1160.102.1.el7 update 52 M Transaction Summary ============================================================================================================================================================================ Install 1 Package Total download size: 52 M Installed size: 66 M Is this ok [y/d/N]: y ... 생략 ... Installed: kernel.x86_64 0:3.10.0-1160.102.1.el7 Complete!
- 설치가 완료된 후에 부팅 가능한 커널 버전 및 기본 부팅 커널 버전을 확인해 주십시오.
- CentOS 7.3
[root@centos73 ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2 CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-7b63677441464f9a89b04041488122e0) 7 (Core) [root@centos73 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
- CentOS 7.8
[root@centos78 ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2 CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-aaaeb22f90c34b3e90e68880b8553310) 7 (Core) [root@centos78 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
참고설치한 커널 버전이 보이지 않는 경우, grub2-mkconfig 명령을 사용하여 grub.cfg를 다시 생성해 주십시오.
# grub2-mkconfig -o /boot/grub2/grub.cfg
- 기본 부팅 커널 버전이 설치한 커널 버전과 다른 경우, 기본 부팅 커널을 변경해 주십시오.
[root@centos78 ~]# ls -ld /etc/grub2* lrwxrwxrwx. 1 root root 22 Aug 31 2020 /etc/grub2.cfg -> ../boot/grub2/grub.cfg [root@centos78 ~]# grub2-mkconfig -o /etc/grub2.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-1127.10.1.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-1127.10.1.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-1127.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-1127.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-aaaeb22f90c34b3e90e68880b8553310 Found initrd image: /boot/initramfs-0-rescue-aaaeb22f90c34b3e90e68880b8553310.img done [root@centos78 ~]# grub2-set-default "CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)" [root@centos78 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
참고기본 부팅 커널이 아닌 커널로 부팅하려면 부팅 시 grub 화면에서 커널을 변경할 수 있습니다. CentOS 7.3 grub 화면 대기 시간이 짧을 경우에는 CentOS 7.3 grub 화면 대기 시간 연장을 참고하여 대기 시간을 연장해 주십시오.
- 설치한 커널 버전을 활성화하기 위해서 서버를 재부팅해 주십시오.
[root@centos78 ~]# reboot
참고서버 재부팅에 실패한 경우 커널 업데이트가 정상적으로 수행되지 않은 것입니다. 이 경우에는 커널 업데이트 원복을 참고하여 이전의 커널 버전으로 되돌려 주십시오.
- 서버에 다시 로그인하여 새로운 커널이 활성화 상태인지 확인해 주십시오.
- CentOS 7.3
[root@centos73 ~]# uname -r 3.10.0-1160.102.1.el7.x86_64
- CentOS 7.8
[root@centos78 ~]# uname -r 3.10.0-1160.102.1.el7.x86_64
참고업데이트한 커널이 정상 적용되었는지 확인하려면 커널 업데이트 확인을 참고하여 커널 설치 상황을 확인해 주십시오.
CentOS 7.3 grub 화면 대기 시간 연장
CentOS 7.3 grub 화면의 대기 시간을 연장하는 방법은 다음과 같습니다.
- 서버 부팅 전에 grub 설정 파일을 확인해 주십시오.
[root@centos73 ~]# grep GRUB_TIMEOUT /etc/default/grub GRUB_TIMEOUT=5
- grub default 설정 파일을 변경하고 grub.cfg 파일을 다시 생성해 주십시오.
[root@centos73 ~]# sed -i "s/GRUB_TIMEOUT=5/GRUB_TIMEOUT=30/" /etc/default/grub [root@centos73 ~]# grep GRUB_TIMEOUT /etc/default/grub GRUB_TIMEOUT=30 [root@centos73 ~]# grub2-mkconfig -o /etc/grub2.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-514.2.2.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-514.2.2.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-7b63677441464f9a89b04041488122e0 Found initrd image: /boot/initramfs-0-rescue-7b63677441464f9a89b04041488122e0.img done
커널 업데이트 확인
업데이트 커널이 정상적으로 적용되었는지 확인하는 방법은 다음과 같습니다.
- 서버에 원격 접속해 주십시오.
- 커널 패키지가 설치되어 있는지 확인해 주십시오.
[root@centos78 ~]# rpm -qa | grep kernel-3.10.0-1160.102.1.el7.x86_64 kernel-3.10.0-1160.102.1.el7.x86_64
- /boot 디렉터리에 initramfs 파일과 vmlinuz 파일이 생성되어 있는지 확인해 주십시오.
[root@centos78 ~]# ls -l /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img -rw------- 1 root root 21897039 Dec 4 11:00 /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img [root@centos78 ~]# ls -l /boot/initramfs-3.10.0-1160.102.1.el7.x86_64kdump.img -rw------- 1 root root 20211564 Dec 4 11:10 /boot/initramfs-3.10.0-1160.102.1.el7.x86_64kdump.img [root@centos78 ~]# ls -l /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64 -rwxr-xr-x 1 root root 7051880 Oct 18 00:46 /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64
- grub.cfg 파일에 최신 커널 설정이 등록되어 있는지 확인해 주십시오.
[root@centos78 ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2 CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-aaaeb22f90c34b3e90e68880b8553310) 7 (Core)
- grub 설정을 확인해 주십시오.
[root@centos78 ~]# grep GRUB_DEFAULT /etc/default/grub GRUB_DEFAULT=saved [root@centos78 ~]# cat /boot/grub2/grubenv # GRUB Environment Block saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) ... 생략 ...
커널 업데이트 원복
커널 업데이트 후 서버 재시작이 정상적으로 수행되지 않을 경우, 업데이트 이전의 커널로 되돌려야 합니다. 설치된 커널 중 여러 버전으로 원복할 수 있습니다. 이 가이드에서는 커널 업데이트하기 직전에 사용한 커널 버전으로 원복하는 방법을 다루고 있습니다.
커널 버전을 원복하는 방법은 다음과 같습니다.
서버 재시작 문제를 해결하기 위해 Single mode에 진입하여 서버 복구를 시도할 수도 있습니다. Single mode 부팅 방법은 서버 복구 가이드를 참고해 주십시오.
- 네이버 클라우드 플랫폼 콘솔의 Region 메뉴와 Platform 메뉴에서 이용 중인 환경을 클릭해 주십시오.
- Services > Compute > Server 메뉴를 차례대로 클릭해 주십시오.
- Server 메뉴를 클릭해 주십시오.
- 서버 목록에서 복구할 서버를 선택한 후 [서버 접속 콘솔] 버튼을 선택해 주십시오.
- grub 부팅 화면에서 부팅 커널을 이전 버전으로 선택하여 재부팅해 주십시오.
CentOS 7.3 grub 부팅 화면
CentOS 7.8 grub 부팅 화면
- 부팅 완료 후에 서버 커널 버전을 확인해 주십시오.
- CentOS 7.3
[root@centos73 ~]# uname -r 3.10.0-514.2.2.el7.x86_64
- CentOS 7.8
[root@centos78 ~]# uname -r 3.10.0-1127.10.1.el7.x86_64
- 현재 활성화된 커널 버전을 확인해 주십시오.
- CentOS 7.3
[root@centos73 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) [root@centos73 ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2 CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-7b63677441464f9a89b04041488122e0) 7 (Core)
- CentOS 7.8
[root@centos78 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) [root@centos78 ~]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2 CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core) CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core) CentOS Linux (0-rescue-aaaeb22f90c34b3e90e68880b8553310) 7 (Core)
- 부팅 시 기본값 커널 버전을 이전 버전의 커널 버전으로 재설정해 주십시오.
- CentOS 7.3
[root@centos73 ~]# grub2-set-default "CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)" [root@centos73 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)
- CentOS 7.8
[root@centos78 ~]# grub2-set-default "CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)" [root@centos78 ~]# grub2-editenv list saved_entry=CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)
참고최신 버전 커널 업데이트 시에 기본 부팅 커널 설정을 변경했기 때문에, 커널 원복 시 부팅 커널 기본값도 같이 변경해야 합니다. 그렇지 않을 경우 다음 부팅 시에 문제 버전의 커널로 부팅됩니다.
- (선택사항) 변경된 커널 버전으로 정상 부팅되는지 확인하기 위해서 서버를 재부팅해 주십시오.
[root@centos78 ~]# reboot
- (선택사항) 서버에 다시 로그인하여 부팅 여부 및 커널 버전을 확인해 주십시오.
- CentOS 7.3
[root@centos73 ~]# uname -r 3.10.0-514.2.2.el7.x86_64
- CentOS 7.8
[root@centos78 ~]# uname -r 3.10.0-1127.10.1.el7.x86_64