歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> Centos 部署Cobbler系統

Centos 部署Cobbler系統

日期:2017/3/6 9:46:43   编辑:學習Linux

Centos 部署Cobbler系統


Centos 部署Cobbler系統


一.簡介

Cobbler 可以用來快速建立 Linux 網絡安裝環境,它已將 Linux 網絡安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。(~..~)

二.安裝環境以及資源

  1. 系統:centos 6.5   IP:192.168.30.158/24

  2. 自動安裝鏡像:CentOS-6.5-x86_64-bin-DVD1.iso

三.安裝步驟

  1. 安裝epel源:

    [root@cobbler ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

  2. 安裝DHCP、tftp,rsync,xinetd,httpd(這些都是所需要的,如果有則不需要安裝。)

    [root@cobbler ~]#yum-yinstalldhcp tftp rsync xinetd httpd

  3. 安裝cobbler

    [root@cobbler ~]# wgethttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

  4. [root@cobbler ~]# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

  5. [root@cobbler ~]# yum install cobbler

  6. 安裝cobbler完成後,重啟cobblerd。還暫時不能使用,我們可以運行一下這個命令,檢查一下。可以看到的錯誤信息

    [root@cobbler ~]# cobbler checkThe following are potential configuration items that you may want to fix:

  7. 1: The'server'fieldin/etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvablehostnameor IPforthe boot server as reachable by all machines that will use it.

  8. 2: For PXE to be functional, the'next_server'fieldin/etc/cobbler/settings must be set to something other than127.0.0.1, and should match the IP of the boot server on the PXE network.

  9. 3: change'disable'to'no'in/etc/xinetd.d/tftp

  10. 4: some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run'cobbler get-loaders'to download them, or,ifyou only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Filesinthis directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The'cobbler get-loaders'command is the easiest way to resolve these requirements.

  11. 5: change'disable'to'no'in/etc/xinetd.d/rsync

  12. 6: comment out'dists'on /etc/debmirror.confforproper debian support7: comment out'arches'on /etc/debmirror.confforproper debian support8: The default password used by the sample templatesfornewly installed machines (default_password_cryptedin/etc/cobbler/settings) is still set to'cobbler'and should be changed, try:"openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'"to generate new oneRestart cobblerd andthenrun'cobbler sync'to apply changes.

  13. 現在就一個一個的來解決以上的錯誤條目。

  • 1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
    上面提示需要修改cobbler服務器的ip地址。配置文件是/etc/cobbler/settings.找到

    [root@cobbler ~]# vim /etc/cobbler/settingsserver:192.168.30.158next_server:192.168.30.158

  • 2 : change 'disable' to 'no' in /etc/xinetd.d/tftp  修改disable 為 no

    [root@cobbler ~]#vi/etc/xinetd.d/tftp

  • # default: off

  • # description: The tftp server serves files using the trivialfiletransfer \

  • # protocol. The tftp protocol is often used to boot diskless \

  • # workstations, download configuration files to network-aware printers, \

  • # and to start the installation processforsome operating systems.

  • service tftp{

  • socket_type = dgram

  • protocol = udp

  • wait= yes

  • user = root

  • server = /usr/sbin/in.tftpd

  • server_args = -s /var/lib/tftpboot

  • disable =no

  • per_source =11

  • cps =1002

  • flags = IPv4

  • }

  • 3 : some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.

    [root@cobbler ~]# cobbler get-loaders

  • task started:2015-08-26_161520_get_loaders

  • task started (id=Download Bootloader Content,time=Wed Aug2616:15:202015)

  • downloading http://cobbler.github.com/loaders/README to /var/lib/cobbler/loaders/README

  • downloading http://cobbler.github.com/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo

  • downloading http://cobbler.github.com/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot

  • downloading http://cobbler.github.com/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux

  • downloading http://cobbler.github.com/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi

  • downloading http://cobbler.github.com/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot

  • downloading http://cobbler.github.com/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0

  • downloading http://cobbler.github.com/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32

  • downloading http://cobbler.github.com/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi

  • downloading http://cobbler.github.com/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi*** TASK COMPLETE ***

  • 4 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one

  • [root@cobbler ~]# opensslpasswd-1-salt'222222''999999'

  • $1$222222$D38AxheCTHf/nVAzlN0.z0

  • 此處按提示操作,最後一個生成的“999999”密碼,是cobbler客戶端安裝完系統後的root密碼。生成後的密碼$1$222222$D38AxheCTHf/nVAzlN0.z0需要寫入下面的文件內:/etc/cobbler/settings內

    [root@cobbler ~]# vim /etc/cobbler/settings

  • default_password_crypted:"$1$222222$D38AxheCTHf/nVAzlN0.z0"

  • 5 : comment out 'dists' on /etc/debmirror.conf for proper debian support;comment out 'arches' on /etc/debmirror.conf for proper debian support

    [root@cobbler ~]# vim /etc/debmirror.conf#@dists="sid";#@arches="i386";

    找到以上兩行,並注釋掉這兩句。

  • 6: change 'disable' to 'no' in /etc/xinetd.d/rsync  修改disable 為 no

    [root@cobbler ~]#vi/etc/xinetd.d/rsync

  • # default: off

  • # description: The rsync server is a good addition to anftpserver, as it \

  • # allows crc checksumming etc.

  • service rsync

  • {

  • disable=no

  • flags = IPv6

  • socket_type = stream

  • wait= no

  • user = root

  • server = /usr/bin/rsync

  • server_args = --daemon

  • log_on_failure += USERID

  • }

  • 7:將上述錯誤修改完畢後,重啟下cobblerd服務,再次運行cobbler check檢查,出現以下便表示前面幾條的提示已經被解決了。

    [root@cobbler ~]# service cobblerd restart

  • Stopping cobbler daemon: [ OK ]

  • Starting cobbler daemon: [ OK ]

  • [root@cobbler ~]# cobbler checkNo configuration problems found. All systems go.

  • 8:修改cobbler配置文件,讓cobbler來接管DHCP的目的

  • [root@cobbler ~]#vi/etc/cobbler/settingsmanage_dhcp:1

  • 9:修改DHCP配置模板,修改成如下配置(根據自己的網絡環境配置)

    [root@cobbler ~]#vi/etc/cobbler/dhcp.template

  • subnet192.168.30.0netmask255.255.255.0{

  • option routers192.168.30.1;

  • option domain-name-servers192.168.30.1;

  • option subnet-mask255.255.255.0;

  • range dynamic-bootp192.168.30.100192.168.30.254;

  • default-lease-time21600;

  • max-lease-time43200;

  • next-server $next_server;

  • 10:安裝光盤已經放在光驅裡了,現在需要創建文件,然後掛載到電腦上。

    [root@cobbler ~]#mkdir-p /cobbler/ISO

  • [root@cobbler /]#mount/dev/cdrom /cobbler/ISO/

  • mount: block device /dev/sr0 iswrite-protected, mounting read-only

    之後導入安裝鏡像。

    [root@cobbler ~]# cobbler import --path=/cobbler/ISO/ --name=CentOS-6.5_86x64

  • task started:2015-08-26_181805_import

  • task started (id=Media import,time=Wed Aug2618:18:052015)

  • Found a candidate signature: breed=redhat, version=rhel6

  • Found a matching signature: breed=redhat, version=rhel6

  • Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.5_86x64:

  • creating new distro: CentOS-6.5_86x64-x86_64

  • trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.5_86x64 -> /var/www/cobbler/links/CentOS-6.5_86x64-x86_64

  • creating new profile: CentOS-6.5_86x64-x86_64

  • associating repos

  • checkingforrsync repo(s)

  • checkingforrhn repo(s)

  • checkingforyumrepo(s)

  • starting descent into /var/www/cobbler/ks_mirror/CentOS-6.5_86x64forCentOS-6.5_86x64-x86_64

  • processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.5_86x64

  • need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.5_86x64

  • lookingfor/var/www/cobbler/ks_mirror/CentOS-6.5_86x64/repodata/*comps*.xml

  • Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.5_86x64/repodata

  • *** TASK COMPLETE ***

  • 11: 現在同步cobbler

    [root@cobbler ~]# cobblersync

  • task started:2015-08-26_182224_sync

  • task started (id=Sync,time=Wed Aug2618:22:242015)

  • running pre-synctriggers

  • cleaning trees

  • removing: /var/www/cobbler/images/CentOS-6.5_86x64-x86_64

  • removing: /var/lib/tftpboot/pxelinux.cfg/default

  • removing: /var/lib/tftpboot/grub/efidefault

  • removing: /var/lib/tftpboot/grub/images

  • removing: /var/lib/tftpboot/images/CentOS-6.5_86x64-x86_64

  • removing: /var/lib/tftpboot/s390x/profile_list

  • copying bootloaders

  • trying hardlink /var/lib/cobbler/loaders/pxelinux.0-> /var/lib/tftpboot/pxelinux.0

  • trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32

  • trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot

  • trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi

  • trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi

  • copying distros to tftpboot

  • copying filesfordistro: CentOS-6.5_86x64-x86_64

  • trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.5_86x64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6.5_86x64-x86_64/vmlinuz

  • trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.5_86x64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6.5_86x64-x86_64/initrd.img

  • copying images

  • generating PXE configuration files

  • generating PXE menu structure

  • copying filesfordistro: CentOS-6.5_86x64-x86_64

  • trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.5_86x64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6.5_86x64-x86_64/vmlinuz

  • trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.5_86x64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6.5_86x64-x86_64/initrd.img

  • Writing template filesforCentOS-6.5_86x64-x86_64

  • rendering TFTPD files

  • generating /etc/xinetd.d/tftp

  • processing boot_filesfordistro: CentOS-6.5_86x64-x86_64

  • cleaning link caches

  • running post-synctriggers

  • running python triggers from /var/lib/cobbler/triggers/sync/post/*

  • running python trigger cobbler.modules.sync_post_restart_services

  • running shell triggers from /var/lib/cobbler/triggers/sync/post/*

  • running python triggers from /var/lib/cobbler/triggers/change/*

  • running python trigger cobbler.modules.scm_track

  • running shell triggers from /var/lib/cobbler/triggers/change/*

  • *** TASK COMPLETE ***

    重啟一下

  • [root@cobbler cobbler]# /etc/init.d/xinetd restart

  • Stopping xinetd: [ OK ]

  • Starting xinetd: [ OK ]

  • 12:現在配置基本上已經完成了,可以達到自動裝機的效果了。(可能生產環境中需要修改一些環境變量,或者預安裝的軟件包)

四.現在測試一下

  • 開機,選擇網卡啟動

  • 之後在出現的系統菜單中,選擇所需要安裝的系統

  • 選擇Centos6.5後即可自動進行安裝。

    文中可能有遺漏之處,還請提出,如果轉載,還請注明源地址!謝謝....
    本文出自 “Elephant” 博客,請務必保留此出處http://zlyang.blog.51cto.com/1196234/1785947

http://xxxxxx/Linuxjc/1134278.html TechArticle

Copyright © Linux教程網 All Rights Reserved