cobbler自動化部署多種類型的作業系統,一個軟體全部搞定

來源:互聯網
上載者:User

標籤:ubuntu   伺服器   作業系統   軟體   自動化   

在生產環境中難免會遇到,一些伺服器需要安裝centos,一些伺服器需要安裝ubuntu,或者一些系統需要安裝centos6.4一些系統需要安裝centos6.5,這時PXE就滿足不了我們的要求。本文將介紹cobbler來實現此功能。


Cobbler必選的服務:

u TFTP

u Rsync

u DHCP

u DNS(根據需求)

Cobbler 命令:

u Import

u Sync

u Reposync

u Build ISO

核心概念:

Distros:定義啟動核心、initrd檔案等

Profiles:指定kickstart     指定level

 

Cobbler:

 

一、安裝cobbler

前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可進行類似下面的安裝過程。

注意關閉selinux

wget http://mirrors.opencas.cn/epel/6/i386/epel-release-6-8.noarch.rpm

rpm -ivh epel-release-6-8.noarch.rpm 

yum clean all

 

# yum install cobbler cobbler-web pykickstart debmirror -y

# service httpd start

# service cobblerd start

# cobbler check


執行“cobbler check命令檢查存的問題,而後逐一按提示解決之。常見的問題如下所示:

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.

2 : For PXE to be functional, the ‘next_server‘ field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.

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.

4 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/rsync

5 : comment ‘dists‘ on /etc/debmirror.conf for proper debian support

6 : comment ‘arches‘ on /etc/debmirror.conf for proper debian support

7 : 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

8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

Restart cobblerd and then run ‘cobbler sync‘ to apply changes.

如上各問題的解決方案如下所示:

1、修改/etc/cobbler/settings檔案中的server參數的值為提供cobbler服務的主機相應的IP地址或主機名稱,如172.16.100.15;

2、修改/etc/cobbler/settings檔案中的next_server參數的值為提供PXE服務的主機相應的IP地址,如172.16.100.16;

3、如果當前節點可以訪問互連網,執行“cobbler get-loaders”命令即可;否則,需要安裝syslinux程式包,而後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等檔案至/var/lib/cobbler/loaders/目錄中;

4、執行“chkconfig rsync on”命令即可;

5、注釋/etc/debmirror.conf檔案中的“@dists="sid";”一行;

6、注釋/etc/debmirror.conf檔案中的“@arches="i386";”一行;

7、執行“openssl passwd -1 -salt $(openssl rand -hex 4)”產生密碼,並用其替換/etc/cobbler/settings檔案中default_password_crypted參數的值;

8、執行“yum install cman fence-agents”命令安裝相應的程式包即可;

接著重啟cobblerd,而後執行“cobbler sync”同步新的配置至cobbler。

二、安裝DHCP

 

yum install dhcp -y

vim /etc/dhcp/dhcpd.conf

option domain-name "magedu.com";

option domain-name-servers 192.168.10.254,172.16.0.1;

default-lease-time 43200;

max-lease-time 86400;

log-facility local7;

subnet 192.168.10.0 netmask 255.255.255.0 {

    range 192.168.10.21 192.168.10.100;

    option routers 192.168.10.254;

}

next-server 192.168.10.254;

filename="pxelinux.0";

service dhcpd start

service xinetd restart 

cobbler sync


匯入鏡像檔案:

插入光碟片

掛載  [[email protected] ~]# mount /dev/cdrom /misc/cd

cobbler import --name="rhel-6.5-x86_64" --path=/misc/cd

cobbler distro list 查看

 

配置Kickstart

yum install system-config-kickstart -y

system-config-kickstart

kickstart配置參照網上其他例子,這裡不做介紹

vim defcault.cfg

url --url="http://192.168.100.1/cobbler/ks_mirror/rhel-5.4-x86"

 

添加profile

cp /root/rhel-x86.cfg /var/lib/cobbler/kickstarts

cobbler profile add --name=rhel-5.4-i386-basic --distro=rhel-5.4-i386 --kickstart=/var/lib/cobbler/kickstarts/rhel-x86.cfg

 

拷貝ks.cfg檔案

cp /var/lib/cobbler/kickstarts/ks.cfg /var/www/html/cobbler/ks.cfg

編輯並修改

vim /var/lib/tftpboot/pxelinux.cfg/default 

 

ks=http://192.168.19.42/cobbler/ks.cfg

重啟服務

 

service cobblerd restart 

Cobbler list 查看

開啟虛擬機器測試!!!


cobbler自動化部署多種類型的作業系統,一個軟體全部搞定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.