pxe 와 kickstart 이용하여 OS 자동설치하기 (레드햇 계열)

문태준의 이미지

시스템자동화와 연관된 자료모음
http://tunelinux.pe.kr/wikix/index.php?display=SystemAutomation

pxe 와 kickstart 이용하여 OS 자동설치하기

ㅇ 문서소개
PXE 부팅을 이용하여 CD등 없이 원격에서 자동으로 부팅하고 설치는 kickstart 와 네트워크 설치를 이용하여 자동화한다.
kickstart 를 이용하여 설치후 필요한 작업까지 넣어두면(post 항목 이용) 좀더 편리한 서버작업이 가능하다.

여기서는 pxe, kickstart, nfs, dhcp, tftp 서버등에 대해서는 설명을 하지 않겠다.

ㅇ 사용 OS
RHEL ES 3.0 (RHEL 4.0 도 동일함)

ㅇ 참고자료
Red Hat Enterprise Linux 3: System Administration Guide Chapter 14. PXE Network Installations
http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/sysadmin-guide/ch-pxe.html

Red Hat Enterprise Linux 4: System Administration Guide Chapter 3. PXE Network Installations

syslinux, pxelinux 사이트 http://syslinux.zytor.com/pxe.php

ㅇ 세팅순서
네트워크 설치할 서버를 세팅합니다. 한대만 있으면 됩니다.
이 한대의 서버에 nfs, dhcp, tftp 서버를 올려서 이용하겠습니다.
nfs 는 /export/rhel3es 디렉토리를 이용하는 것으로 예제삼음

ㅇ 네트워크 설치준비
rhel 4장의 cd 에서 마운트하여 복사
mount /mnt/cdrom
cp -arpvf /mnt/cdrom/* /export/rhel3es

ㅇ nfs 세팅
# cat /etc/exports
/export/rhel3es *(ro,insecure)

/etc/init.d/portmap start
/etc/init.d/nfs start

ㅇ 자동설치 세팅
system-config-netboot 를 이용하여 세팅하겠음
상세 내용은 참고자료를 이용함. 이 프로그램을 실행하고 네트워크 설치를 골라서 1차 진행함

이 화면에서 Operating system identifier 에 rhel3es 라고 입력하면 내용에 따라 적절한 변경을 함

- /tftp/linux-install/rhel3es 디렉토리를 생성하고 부팅관련한 파일을 복사함.
- /tftp/linux-install/pxelinux.cfg 디렉토리에 default, pxeos.xml 파일 생성하며 여기서 pxeos.xml은 설정내용을 저장하고 있고 default 가 부팅되고나서의 옵션을 정함.

msgs:
합계 24
--rw-r--r-- 1 root root 507 12월 18 22:18 boot.msg
+-rw-r--r-- 1 root root 531 12월 18 22:19 boot.msg
-rw-r--r-- 1 root root 668 9월 1 03:35 expert.msg
-rw-r--r-- 1 root root 871 9월 1 03:35 general.msg
-rw-r--r-- 1 root root 860 9월 1 03:35 param.msg
@@ -11,4 +11,12 @@
-rw-r--r-- 1 root root 545 9월 1 03:35 snake.msg

pxelinux.cfg:
-합계 0
+합계 8
+-rw-r--r-- 1 root root 356 12월 18 22:19 default
+-rw-r--r-- 1 root root 247 12월 18 22:19 pxeos.xml
+
+rhel3es:
+합계 3368
+-rw-r--r-- 1 root root 2535139 12월 18 22:19 initrd.img
+-rw-r--r-- 1 root root 77 12월 18 22:19 ks.cfg
+-rw-r--r-- 1 root root 900120 12월 18 22:19 vmlinuz

# cat pxelinux.cfg/default
....

label 1
kernel rhel3es/vmlinuz
append initrd=rhel3es/initrd.img ramdisk_size=7000 ks=nfs:192.168.40.11:/export/rhel3es/ks222.cfg

[root@localhost pxelinux.cfg]# cat pxeos.xml
<?xml version="1.0" ?>
<OperatingSystems>
<OS Anonymous="1" Description="rhel3 es " Diskless="0" Kernel="" Kickstart="nfs:192.168.40.11:/export/rhel3es/ks222.cfg" Location="/export/rhel3es" Name="rhel3es" Password="" Protocol="NFS" Server="192.168.40.11" User=""/>

여기서 설정하는 kickstart 파일도 원격에서 이용할 수 있으므로 nfs:192.168.40.11:/export/rhel3es/ks222.cfg 와 같이 지정하면 편리하게 사용할 수 있다.

이제 특정 네트워크 또는 ip와 앞에서 정의한 os를 연결시켜주는 작업을 해야 한다.

여기서 호스트명에 192.168.40.0 이라고 넣으면 해당 네트워크 대역을 모두 포함하는 것이다. (c 클래스)

여기서도 킥스타트파일을 넣어주는 것이 있다. 그러나 여기 넣어준다고 바로 작동하지 않는다.
/tftp/linux-install/pxelinux.cfg/ 디렉토리에 아래와 같은 내용이 생기는데 이것을 참고로 해서 위의 default 파일을 수정해주든지 아니면 nfs 를 그냥 이용하는 방법을 쓰면 된다. 실제 세팅하다보면 이 부분이 헷갈릴건데 왜 이렇게 해놓았는지 모르겠다.

# cat C0A82800
default rhel3es

label rhel3es
kernel rhel3es/vmlinuz
append initrd=rhel3es/initrd.img ramdisk_size=7000 ks=http://lx03.tunelinux.pe.kr/ks.cfg

명령행에서는 pxeboot 라는 명령을 이용할 수 있는데 레드햇에서 편리하게 만들어놓은 듯 하다.

/tftp/linux-install/msgs 디렉토리는 부팅후 화면에 뿌려주는 화면이며 해당 파일을 마음대로 수정해도 된다. 단지 뿌려주는 부분이므로. 그렇지만 label은 default 파일에서 조정하는 것이므로 함께 맞추어주어야 한다.

ㅇ tftp 서버 시작

/sbin/chkconfig --level 345 xinetd on
/sbin/chkconfig --level 345 tftp on

이렇게하고 xinetd 를 시작해준다.
service xinetd restart

ㅇ dhcp 서버
dhcp 서버를 설치하면 /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample 의 파일을 참고로 해서 /etc/dhcpd.conf 를 만들어주면 된다.

여기서 수정해줄 항목은 subnet, netmask, routers (기본 게이트웨이), range dynamic-bootp (dhcp로 쓸 ip 대역을 세부적으로 나눔)
이 파일에서 아래 부분을 추가해주면 된다.

allow booting;
allow bootp;
class "pxeclients" {
match if substring(option vendor-class-identifier, 0, 9) = "PXEClient";
next-server <server-ip>;
filename "linux-install/pxelinux.0";
}

server-ip 는 tftp 서버의 ip를 말하며 별도의 서버를 쓰지 않는다면 현재 세팅하는 서버일 것이다.

ㅇ 설치하여 테스팅을 해본다.

ㅇ 참고
위와 같이 하여 모든 테스팅을 마쳤다면 자기 상황에 맞게 조절하여 사용하자.
위에서 OS버전별로 구분할 수도 있고 웹, 메일 등 서버의 기능에 따라 분리할 수도 있다. OS버전에 따라서 조정을 하고 kickstart 파일을 조정하여 세부 세팅을 하면 편리하게 이용이 가능하다.

여기서 좀 더 나간다면 새로운 서버를 추가하거나 삭제하는 경우 서버등록, dns 등록, ip 부여등을 자동으로 하는 스크립트등을 만들어서 이용할 수 있을 것이다.

설치는 이렇게 자동화를 하고 이후 시스템설정은 cfengine 을 이용하여보자.

** system rescue cd 테스팅
http://www.systemrescuecd.org/
http://tunelinux.pe.kr/zboard/view.php?id=tip&no=42
systemrescuecd 는 간단히 말해 리눅스용 고스트프로그램으로 생각하면 되며 시스템에 문제가 발생하였을 경우 cd에서 부팅해 작업할 수 있는 프로그램이고 partimage 를 이용하여 파티션을 다른 곳으로 옮기거나 복구할 수 있다.
이 cd를 다운로드받아 pxe로 부팅되는 것을 확인해보았다.
systemrescuecd 는 젠투기반이며 라이브cd같은것을 생각하면 된다. Knoppix 등 다른 배포판도 동일하게 작업을 할 수 있으리라 예상이 된다.

# mount -o loop ~test/systemrescuecd-x86-0.2.15.iso /mnt/floppy/
# cp /mnt/floppy/isolinux/vmlinuz1 /mnt/floppy/isolinux/initrd1 /tftpboot/linux-install/rescue/
커널과 initrd 파일을 복사해준것이다.

# cat /tftpboot/linux-install/pxelinux.cfg/default
label 3
kernel rescue/vmlinuz1
append initrd=/rescue/initrd1 acpi=off root=/dev/ram0 init=/linuxrc dokeymap vga=785

위와 같이 추가해주었다.

위의 내용은 아래 isolinux 에서 부팅에 관련된 파일에서 정보를 확인한 것이다. 달라진것이 있다면 우리가 rescue 디렉토리를 기준으로 하기 때문에 이 부분만 달라졌다.
# cat /mnt/floppy/isolinux/isolinux.cfg

이렇게 해서 부팅을 하면 systemrescuecd 에서 부팅을 할 수 있다.

부팅시는 3번을 골라야하며 msg 파일도 수정을 해야 편할 것이다.

Forums: 
1day1의 이미지

아주 유용하겠습니다. 감사합니다.

그런데.. 레드햇 계열만 지원되는 것인가요?

F/OSS 가 함께하길..

ydhoney의 이미지

레드햇 계열의 경우 kickstart, 수세의 경우 AutoYaST가 있고, 데비안도 정확히 이름이 기억은 안나는데 문서를 찾아보면 자동화 설치에 대한 문서가 있고 프비쪽도 있었던듯 싶은데 이건 전혀 기억에서 사라진지 오래고;;

그나저나 아직 25일 되려면 일주일 남았거든요? -_-;; 설마 벌써 크리스마스라고 생각해버리시는건 아니시겠지요?

문태준의 이미지

이와 관련된 주제를 모아보았습니다.
http://tunelinux.pe.kr/wikix/index.php?display=SystemAutomation

설치자동화툴

* Redhat : Kickstart http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/sysadmin-guide/
* Suse : Autoyast
* Debian : FAI http://www.informatik.uni-koeln.de/fai/ FAI는 설치 자동화및 cfengine을 이용하여 설정변경을 함
* Solaris : Jumpstart

데비안에서는 FAI를 쓰는데 저도 써보지는 않았지만 소개자료를 보면 설치자동화 및 cfengine을 이용하여 설정변경을 합니다.

위의 제 사이트 url을 보시면 참고자료들이 있는데 우분트, 젠투도 있지만 그 자료들은 자세하지 않네요. 막상 pxe 에 대한 자세한 이해는 별도의 자료를 보아야하겠지만 구현하는것은 비슷하지 다른 배포판이라고 하도 어렵지는 않은듯 합니다.

---------------------------
문태준
http://groups.google.co.kr/group/sysadminstudy 시스템어드민 공부모임
http://tunelinux.pe.kr
http://database.sarang.net

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.