linux自動化運維之cobbler

一:cobbler是什麼?

  Cobbler是一個快速網絡安裝linux的服務,而且在經過調整也可以支持網絡安裝windows。該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令即可完成PXE網絡安裝環境的配置,同時還可以管理DHCP,DNS,以及yum包鏡像。Cobbler支持命令行管理,web界面管理,還提供了API接口,可以方便二次開發使用,和PXE不同的是,使用cobbler不會因爲在局域網中啓動了dhcp而導致有些機器因爲默認從pxe啓動在重啓服務器後加載tftp內容導致啓動終止。

二:cobbler常用架構

  

wKiom1RDKxWzLkuzAADTcatEYQI310.jpg

三:cobbler的安裝

  1)安裝cobbler需要epel源.利用yum進行安裝

 yum install cobbler

   查看下生成的文件

[root@node3 ~]# tree /var/www/cobbler/
/var/www/cobbler/
├── aux
│   ├── anamon
│   └── anamon.init
├── p_w_picpaths
├── ks_mirror   
│   └── config
├── links
├── localmirror
├── pub
├── rendered
├── repo_mirror
└── svc
    ├── services.py
    ├── services.pyc
    └── services.pyo
10 directories, 5 files

 2)啓動前的準備

 啓動httpd服務.檢測cobbler  check 

[root@node3 ~]# service httpd start
[root@node3 ~]# service cobblerd start
Starting cobbler daemon:                                   [  OK  ]

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

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 : debmirror package is not installed, it will be required to manage debian deployments and repositories
6 : ksvalidator was not found, install pykickstart
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

啓動cobbler後檢測了一下發現了許多錯誤,根據這些錯誤提示進行排錯.

 

解決第一個問題,編輯vim /etc/cobbler/settings

server: 172.16.16.5

解決DHCP服務器問題

next_server: 172.16.16.5

確保syslinux已經安裝

[root@node3 ~]# yum install syslinux
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package syslinux-4.02-8.el6.x86_64 already installed and latest version #提示已經安裝
Nothing to do

確保rsync開機啓動

[root@node3 ~]# chkconfig rsync on

 安裝pykickstart

[root@node3 ~]# yum install pykickstart

生成cobbler隨機密碼並進行替換

[root@node3 ~]# openssl passwd -apr1 -salt 'openssl rand -hex 4'
Password: #輸入密碼
$apr1$openssl $aA7bNBhsYJPhUH8z6mKS3/

vim /etc/cobbler/setting
default_password_crypted: "$1$mF86/UHC$WvcIcX2t6crBz2onWxyac."

cd /usr/share/syslinux 下複製當前目錄的所有文件到 /var/lib/cobbler/loaders/

修改/etc/cobbler/setting配置文件選擇是否有cobbler自己提供DHCP和LFTP服務

爲1是自己提供爲0是單獨的服務器提供

修復完成後重啓cobblerd和sync


3)提供cobbler依賴的服務

  安裝配置DHCP服務

yum install dhcp

  提供DHCP的配置文件

cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample   /etc/dhcp
mv dhcpd.conf.sample  dhcpd.conf
vim dhcpd.conf

spacer.gif

wKioL1RDMqTDTQn6AACM5jyygGY814.jpg

提供tftp服務器(在安裝cobbler時默認已經安裝了)

chkconfig tftp on
service xinetd start

4)提供 distro文件

 通過掛載光盤映像文件來提供

wKiom1RDMyiyWdzBAAGFCZ3F8DI583.jpg

mount /dev/cdrom /mnt -r   掛載cdrom下的光盤鏡像到/mnt 下

 把掛載的光盤鏡像內的文件導入cobbler

wKioL1RDM9bioumCAAHLwQq7NZA113.jpg

導入過程要多等一會....................................

完成後查看cobbler distro list 是否有導入的文件


5)提供profile文件

 創建profile文件依賴於kickstart. 所以要先提供kickstart文件

 創建kickstart請參考pxe安裝

 正式創建profile

cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/root/centos6.x86_64.cfg

 查看創建有哪些profile第一個爲創建distro時自動創建的做基本的profile.第二個爲自己新增加創建的profile

wKiom1RDNE2yzWV9AABuj7CIHDw204.jpg

導入完成以後執行cobbler sync 下 sync後會在/var/lib/tftpboot/pxelinux.cfg 自動創建一個default文件

查看下此文件

wKioL1RDNPaxn3MXAAJLIoPwhF8426.jpg

6)新創建虛擬機進行安裝

  安裝系統選擇

wKiom1RDNTTA-7tBAADEBAyM9vs141.jpg

成功進入安裝界面

wKiom1RDNYyBKZMFAAD1NVajreg375.jpg

注:重新修改安裝配置的話要重新加載一下cobbler

例:cobbler profile edit --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/root/centos6.x86_64.cfg

修改profit文件後需要從新加載一下 cobbler sync



7)安裝cobbler的WEB管理

 

 yum -y cobbler-web
   vim /etc/cobbler/modules.conf

wKioL1RDNtKRF1HnAAAtOoEqALM937.jpg

添加cobbler用戶添加cobbler密碼

wKioL1RDNx7AXI_bAAEARwtXtgg655.jpg

 編輯/etc/cobbler/users.conf配置文件

wKioL1RDN2GzZg3VAAAyNdAXrME156.jpg

重啓cobblerd

service cobblerd restart

重啓一下httpd

service  httpd restart

wKiom1RDN4PT4oAoAADhApYjj4c488.jpg


OK cobbler配置已經完成

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章