Cobbler-自動化部署神器

Cobbler-自動化部署神器

前言:html

網絡安裝服務器套件 Cobbler(補鞋匠)從前,咱們一直在作裝機民工這份頗有前途的職業。自打若干年前 Red Hat 推出了 Kickstart,此後咱們頓覺身價倍增。再也不須要刻了光盤一臺一臺地安裝 Linux,只要搞定 PXE、DHCP、 TFTP,還有那滿屏眼花繚亂不知所云的 Kickstart 腳本,咱們就能夠像哈里波特同樣,輕點魔棒,瞬間安裝上百臺服務器。這一堆花裏胡哨的東西可不是通常人都能整明白的,沒有大專以上學歷,通不過英語四級, 根本別想玩轉。node

總而言之,這是一份多麼有前途,多麼有技術含量的工做啊。j_0003.gif
python

 

很不幸,Red Hat 最新(Cobbler項目最初在2008年左右發佈)發佈了網絡安裝服務器套件 Cobbler(補鞋匠),它已將 Linux 網絡安裝的技術門檻,從大專以上文化水平,成功下降到初中如下,連補鞋匠都能學會。linux

對於咱們這些在裝機領域浸淫多年,經驗豐富,老驥伏櫪,志在千里的民工兄弟們來講,不啻爲一個晴天霹靂。ios

 

j_0004.gif居然讓我沒法ZB豈有此理!!git

筆者QQ:315420700 【讓咱們共同窗習ZB技巧吧】github

 

 

我又使用最新的centos7.3進行的安裝(2017.09.05),全程複製粘貼後,沒有任何問題,若是你還有問題那說明什麼?

j_0012.gif請認真看文檔作,先全照搬而後再自我發揮web

 

1. Cobbler介紹shell

Cobbler是一個Linux服務器快速網絡安裝的服務,並且在通過調整也能夠支持網絡安裝windows。apache

該工具使用python開發,小巧輕便(才15k行python代碼),能夠經過網絡啓動(PXE)的方式來快速安裝、重裝物理服務器和虛擬機,同時還能夠管理DHCP,DNS,TFTP、RSYNC以及yum倉庫、構造系統ISO鏡像。

Cobbler可使用命令行方式管理,也提供了基於Web的界面管理工具(cobbler-web),還提供了API接口,能夠方便二次開發使用。

Cobbler是較早前的kickstart的升級版,優勢是比較容易配置,還自帶web界面比較易於管理。

Cobbler內置了一個輕量級配置管理系統,但它也支持和其它配置管理系統集成,如Puppet,暫時不支持SaltStack。

 

Cobbler客戶端Koan支持虛擬機安裝和操做系統從新安裝,使重裝系統更便捷。

 

1)Cobbler能夠幹啥

 

使用Cobbler,您無需進行人工干預便可安裝機器。Cobbler設置一個PXE引導環境(它還可使用yaboot支持PowerPC),並 控制與安裝相關的全部方面,好比網絡引導服務(DHCP和TFTP)與存儲庫鏡像。當但願安裝一臺新機器時,Cobbler能夠:

1)使用一個之前定義的模板來配置DHCP服務(若是啓用了管理DHCP)

2)將一個存儲庫(yum或rsync)創建鏡像或解壓縮一個媒介,以註冊一個新操做系統

3)在DHCP配置文件中爲須要安裝的機器建立一個條目,並使用指定的參數(IP和MAC)

4)在TFTP服務目錄下建立適當的PXE文件

5)從新啓動DHCP服務來反應新的更改

6)從新啓動機器以開始安裝(若是電源管理已啓動)

 

2)Cobbler支持的系統和功能

Cobbler支持衆多的發行版:RedHat、Fedora、CentOS、Debian、Ubuntu和SUSE。當添加一個操做系統(一般經過使用ISO文件)時,Cobbler知道如何解壓縮合適的文件並調整網絡服務,以正確引導機器。

Cobbler可使用kickstart模板。基於Red Hat或 Fedora的系統使用kickstart文件來自動化安裝流程。經過使用模板,就會擁有基本的kickstart模板,而後定義如何針對一種配置文件或 機器配置而替換其中的變量。例如,一個模板可能包含兩個變量$domain和$machine_name.在Cobbler配置中,一個配置文件指定 domain=mydomain.com,而且每臺使用該配置文件的機器在machine_name變量中指定其名稱。該配置文件的全部機器都使用相同的 kickstart安裝且針對domain=mydomain.com進行配置,但每臺機器擁有其本身的機器名稱。您仍然可使用kickstart模板 在不一樣的域中安裝其餘機器並使用不一樣的機器名稱。

爲了協助管理系統,Cobbler可經過fence scripts鏈接到各個電源管理環境。Cobbler支持apc_snmp、bladecenter、bullpap、drac、 ether_wake、ilo、integrity、ipmilan、ipmitool、lpar、rsa、virsh和wti。要從新安裝一臺機器,可 運行reboot system foo命令,並且Cobbler會使用必要的 和信息來爲您運行恰當的fence scripts(好比機器插槽數)。

除了這些特性,還可使用一個配置管理系統(CMS)。你有兩種選擇:該工具內的一個內部系統,或者現成的外部CMS,好比Chef或 Puppet。藉助內部系統,你能夠指定文件模板,這些模板會依據配置參數進行處理(與kickstart模板的處理方式同樣),而後複製到你指定的位 置。若是必須自動將配置文件部署到特定機器,那麼此功能頗有用

使用koan客戶端,Cobbler可從客戶端配置虛擬機並從新安裝系統。

 

Cobbler官網

wKiom1dCxcGSLKQeAADZsuOaaOY616.jpg

 

2.Cobbler各個組件之間關係:

wKioL1dCyxTAinKaAAH0I6yzrL8642.jpg

 

主要目的配置網絡接口:

Cobbler的配置結構基於一組註冊的對象。每一個對象表示一個與另外一個實體相關聯的實體(該對象指向另外一個對象,或者另外一個對象指向該對象)。當一個對象指向另外一個對象時,它就繼承了被指向對象的數據,並可覆蓋或添加更多特定信息。如下對象類型的定義

Distros(發行版):表示一個操做系統,它承載了內核和initrd的信息,以及內核參數等其餘數據

Profile(配置文件):包含一個發行版、一個kickstart文件以及可能的存儲庫,還包含更多特定的內核參數等其餘數據

Systems(系統):表示要配給的額機器。它包含一個配置文件或一個景象,還包含IP和MAC地址、電源管理(地址、憑據、類型)、(網卡綁定、設置valn等)

Repository(鏡像):保存一個yum或rsync存儲庫的鏡像信息

Image(存儲庫):可替換一個包含不屬於此類比的額文件的發行版對象(例如,沒法分爲內核和initrd的對象)。

基於註冊的對象以及各個對象之間的關聯,Cobbler知道如何更改文件系統以反應具體配置。由於系統配置的內部是抽象的,因此您能夠僅關注想要執行的操做。

 

3.基礎環境準備

centos6系列:

[root@cobbler ~]# cat /etc/redhat-release #系統版本 CentOS release 6.5 (Final) [root@cobbler ~]# uname -r #內核版本 2.6.32-431.el6.x86_64 [root@cobbler ~]# getenforce #檢測selinux是否關閉(必須關閉) Disabled [root@cobbler ~]# /etc/init.d/iptables status #檢測防火牆是否關閉(必須關閉) iptables: Firewall is not running. [root@cobbler ~]# ifconfig eth0|awk -F '[ :]+' 'NR==2 {print $4}' #查看IP地址 10.0.0.71 [root@cobbler ~]# hostname #查看主機名 cobbler [root@cobbler ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo --2016-05-23 21:10:51-- http://mirrors.aliyun.com/repo/epel-6.repo Resolving mirrors.aliyun.com... 115.28.122.210, 112.124.140.210 Connecting to mirrors.aliyun.com|115.28.122.210|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1083 (1.1K) [application/octet-stream] Saving to: 「/etc/yum.repos.d/epel.repo」 #cobbler安裝必須使用到epel源 100%[====================================================================================>] 1,083 --.-K/s in 0s

centos7系列:

[root@cobbler02 ~]# cat /etc/redhat-release #系統版本 CentOS Linux release 7.2.1511 (Core) [root@cobbler02 ~]# uname -r #內核版本 3.10.0-327.18.2.el7.x86_64 [root@cobbler02 ~]# getenforce #檢測selinux是否關閉(必須關閉) Disabled [root@cobbler02 ~]# systemctl status firewalld #檢測防火牆是否關閉(必須關閉) ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) [root@cobbler02 ~]# ifconfig eth0|awk -F '[ :]+' 'NR==2{print $3}' 192.168.31.73 [root@cobbler02 ~]# hostname cobbler02 [root@cobbler02 ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo --2016-05-30 07:55:52-- http://mirrors.aliyun.com/repo/epel-7.repo Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 112.124.140.210, 115.28.122.210 Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|112.124.140.210|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1084 (1.1K) [application/octet-stream] Saving to: ‘/etc/yum.repos.d/epel.repo’ 100%[===============================================================================================>] 1,084 --.-K/s in 0s 2016-05-30 07:55:52 (270 MB/s) - ‘/etc/yum.repos.d/epel.repo’ saved [1084/1084]

 

 

注意:

  • 虛擬機網卡採用橋接模式,不使用NAT模式,咱們會搭建DHCP服務器,在同一局域網多個DHCP服務會有衝突,因此最好把路由器的DHCP服務關閉t_0015.gif我搭建服務只喜歡用橋接模式,就是不同凡響,不服?

 

4.安裝Cobbler

 

centos6系列:

[root@cobbler ~]# yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server-y cobbler #cobbler程序包 cobbler-web #cobbler的web服務包 pykickstart #cobbler檢查kickstart語法錯誤 httpd #Apache web服務 dhcp #dhcp服務 tftp-server #tftp服務 [root@cobbler ~]# rpm -ql cobbler # 查看安裝的文件,下面列出部分。 /etc/cobbler # 配置文件目錄 /etc/cobbler/settings # cobbler主配置文件,這個文件是yaml格式,cobbler是python寫的程序。 /etc/cobbler/dhcp.template # dhcp服務的配置模板 /etc/cobbler/tftpd.template # tftp服務的配置模板 /etc/cobbler/rsync.template # rsync服務的配置模板 /etc/cobbler/iso # iso模板配置文件目錄 /etc/cobbler/pxe # pxe模板文件目錄 /etc/cobbler/power # 電源的配置文件目錄 /etc/cobbler/users.conf # web服務受權配置文件 /etc/cobbler/users.digest # web訪問的用戶名密碼配置文件 /etc/cobbler/dnsmasq.template # DNS服務的配置模板 /etc/cobbler/modules.conf # cobbler模塊配置文件 /var/lib/cobbler # cobbler數據目錄 /var/lib/cobbler/config # 配置文件 /var/lib/cobbler/kickstarts # 默認存放kickstart文件 /var/lib/cobbler/loaders # 存放的各類引導程序 /var/www/cobbler # 系統安裝鏡像目錄 /var/www/cobbler/ks_mirror # 導入的系統鏡像列表 /var/www/cobbler/images # 導入的系統鏡像啓動文件 /var/www/cobbler/repo_mirror # yum源存儲目錄 /var/log/cobbler # 日誌目錄 /var/log/cobbler/install.log # 客戶端系統安裝日誌 /var/log/cobbler/cobbler.log # cobbler日誌

centos7系列:

[root@cobbler02 ~]# yum install cobbler cobbler-web pykickstart httpd dhcp tftp-server -y cobbler #cobbler程序包 cobbler-web #cobbler的web服務包 pykickstart #cobbler檢查kickstart語法錯誤 httpd #Apache web服務 dhcp #dhcp服務 tftp-server #tftp服務

 

5. 檢測Cobbler

cobbler的運行依賴於dhcp、tftp、rsync及dns服務,其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;tftp可由tftp-server程序包提供,也可由cobbler功能提供,rsync有rsync程序包提供,dns可由bind提供,也可由dnsmasq提供

cobbler可自行管理這些服務中的部分甚至是所有,但須要配置文件/etc/cobbler/settings中的「manange_dhcp」、「manager_tftpd」、「manager_rsync」、「manager_dns」分別來進行定義,另外,因爲各類服務都有着不一樣的實現方式,如若須要進行自定義,須要經過修改/etc/cobbler/modules.conf配置文件中各服務的模塊參數的值來實現。

 

centos6系列:

[root@cobbler cobbler]# /etc/init.d/httpd restart #啓動apache服務 Stopping httpd: [ OK ] Starting httpd: httpd: apr_sockaddr_info_get() failed for cobbler httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName #碰見報錯須要修改apache的配置文件,添加一行 [root@cobbler cobbler]# vim /etc/httpd/conf/httpd.conf ServerName localhost:80 #再重啓服務發現沒有報錯了 [root@cobbler cobbler]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [ OK ]
[root@cobbler cobbler]# /etc/init.d/cobblerd restart #啓動cobbler服務 Stopping cobbler daemon: [ OK ] Starting cobbler daemon:

centos7系列:

[root@cobbler02 ~]# systemctl start httpd [root@cobbler02 ~]# systemctl status httpd #查看httpd的狀態,看有沒有起來 ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2016-05-30 08:06:08 CST; 9s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 2317 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─2317 /usr/sbin/httpd -DFOREGROUND ├─2318 (wsgi:cobbler_w -DFOREGROUND ├─2319 /usr/sbin/httpd -DFOREGROUND ├─2320 /usr/sbin/httpd -DFOREGROUND ├─2321 /usr/sbin/httpd -DFOREGROUND ├─2322 /usr/sbin/httpd -DFOREGROUND └─2323 /usr/sbin/httpd -DFOREGROUND May 30 08:06:08 cobbler02 systemd[1]: Starting The Apache HTTP Server... May 30 08:06:08 cobbler02 httpd[2317]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, u...message May 30 08:06:08 cobbler02 systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@cobbler02 ~]# systemctl status cobblerd #查看cobblerd的狀態,看有沒有起來 ● cobblerd.service - Cobbler Helper Daemon Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled) Active: inactive (dead) [root@cobbler02 ~]# systemctl start cobblerd #開啓cobblerd服務 [root@cobbler02 ~]# systemctl status cobblerd #再檢查一下,發現確實起來了 ● cobblerd.service - Cobbler Helper Daemon Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2016-05-30 08:06:39 CST; 1s ago Process: 2349 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS) Main PID: 2348 (cobblerd) CGroup: /system.slice/cobblerd.service └─2348 /usr/bin/python2 /usr/bin/cobblerd -F May 30 08:06:39 cobbler02 systemd[1]: Starting Cobbler Helper Daemon... May 30 08:06:39 cobbler02 systemd[1]: Started Cobbler Helper Daemon.

 

檢查配置文件,須要在cobblerd和httpd啓動的狀況下檢查

 

centos6系列:

[root@cobbler cobbler]# cobbler check #檢查cobbler配置存在的問題,逐一解決 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp 4 : 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. 5 : change 'disable' to 'no' in /etc/xinetd.d/rsync 6 : file /etc/xinetd.d/rsync does not exist 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 8 : 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 9 : 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.

 

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

一、修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP地址或主機名,如server: 192.168.31.71;
#備份原文件 [root@cobbler cobbler]# cp /etc/cobbler/settings{,.ori} # server,Cobbler服務器的IP,修改384行server: 127.0.0.1 [root@cobbler cobbler]# sed -i 's/server: 127.0.0.1/server: 192.168.31.71/' /etc/cobbler/settings
二、修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的IP地址,如next_server: 192.168.31.71;
# server,pxe服務器的IP,因爲這裏使用的是同一臺機器,因此填Cobbler服務器的IP,修改272行next_server: 127.0.0.1 [root@cobbler cobbler]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.31.71/' /etc/cobbler/settings #因爲sed的匹配規則的緣由,上一步就已經把這裏給修改了,檢查下 [root@cobbler cobbler]# grep "server: 192.168.31.71" settings next_server: 192.168.31.71 server: 192.168.31.71
三、修改/etc/xinetd.d/tftp文件中的disable參數修改成 disable = no #備份原文件 [root@cobbler cobbler]# cp /etc/xinetd.d/tftp{,.ori} #修改替換 [root@cobbler cobbler]# sed -i 's/disable.*= yes/disable = no/g' /etc/xinetd.d/tftp
四、執行 cobbler get-loaders 命令便可;不然,須要安裝syslinux程序包,然後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目錄中; [root@cobbler cobbler]# cobbler get-loaders task started: 2016-05-23_230908_get_loaders task started (id=Download Bootloader Content, time=Mon May 23 23:09:08 2016) downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
五、修改rsync配置文件;
[root@cobbler xinetd.d]# sed -i s/"disable.*= yes"/"disable = no"/g /etc/xinetd.d/rsync [root@cobbler xinetd.d]# cat /etc/xinetd.d/rsync # default: off # description: The rsync server is a good addition to an ftp server, 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 }
六、rsync
七、安裝debmirror 
[root@cobbler cobbler]# yum install -y debmirror #安裝後再check下會報以下錯誤 3 : comment out 'dists' on /etc/debmirror.conf for proper debian support4 : comment out 'arches' on /etc/debmirror.conf for proper debian support #修改配置文件來征服報錯,其實不礙事,可是報錯有礙眼睛,遂除之 [root@cobbler cobbler]# vim /etc/debmirror.conf 28 #@dists="sid"; 30 #@arches="i386"; 註釋掉這兩行,從新check後沒有報錯了
八、生成密碼來取代默認的密碼,更安全
#try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one #根據提示your-password-here,這裏是本身的密碼,random-phrase-here,這裏是隨機的干擾碼 [root@cobbler cobbler]# openssl passwd -1 -salt 'renjunjie' '123456' $1$renjunji$G7LpR5255qFguHrw7E0KP/ [root@cobbler cobbler]# sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP\/"'/g /etc/cobbler/settings [root@cobbler cobbler]# grep -n default_pass /etc/cobbler/settings 101:default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP/"
九、安裝cman fence-agents
[root@cobbler cobbler]# yum install -y cman ence-agents
十、其餘一些沒有提示報錯的小修改
# 用cobbler管理DHCP,修改242行manage_dhcp: 0 [root@cobbler cobbler]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings # 防止循環裝系統,適用於服務器第一啓動項是PXE啓動,修改292行pxe_just_once: 0 [root@cobbler cobbler]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings
#修改完後重啓服務再進行一次檢測,發現剩下這兩個報錯,請往下走 [root@cobbler cobbler]# /etc/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] [root@cobbler cobbler]# /etc/init.d/xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] [root@cobbler cobbler]# /etc/init.d/cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ] [root@cobbler cobbler]# check checkmodule checkpolicy [root@cobbler cobbler]# cobbler check The following are potential configuration items that you may want to fix: 1 : service dhcpd is not running 2 : file /etc/xinetd.d/rsync does not exist Restart cobblerd and then run 'cobbler sync' to apply changes.

centos7系列:

[root@cobbler02 ~]# cobbler check #檢查cobbler配置存在的問題,逐一解決 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 : change 'disable' to 'no' in /etc/xinetd.d/tftp 4 : 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. 5 : enable and start rsyncd.service with systemctl 6 : debmirror package is not installed, it will be required to manage debian deployments and repositories 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.
一、修改/etc/cobbler/settings文件中的server參數的值爲提供cobbler服務的主機相應的IP地址或主機名,如server: 192.168.31.73;
#備份原文件 [root@cobbler02 ~]# cp /etc/cobbler/settings{,.ori} # server,Cobbler服務器的IP,修改384行server: 127.0.0.1 [root@cobbler02 ~]# sed -i 's/server: 127.0.0.1/server: 192.168.31.73/' /etc/cobbler/settings
二、修改/etc/cobbler/settings文件中的next_server參數的值爲提供PXE服務的主機相應的IP地址,如next_server: 192.168.31.73;
# server,pxe服務器的IP,因爲這裏使用的是同一臺機器,因此填Cobbler服務器的IP,修改272行next_server: 127.0.0.1 [root@cobbler02 ~]# sed -i 's/next_server: 127.0.0.1/next_server: 192.168.31.73/' /etc/cobbler/settings #因爲sed的匹配規則的緣由,上一步就已經把這裏給修改了,檢查下 [root@cobbler02 ~]# grep "server: 192.168.31.73" settings next_server: 192.168.31.713 server: 192.168.31.73
三、修改/etc/xinetd.d/tftp文件中的disable參數修改成 disable = no #備份原文件 [root@cobbler02 ~]# cp /etc/xinetd.d/tftp{,.ori} #修改替換 [root@cobbler02 ~r]# sed -i 's/disable.*= yes/disable = no/g' /etc/xinetd.d/tftp
四、執行 cobbler get-loaders 命令便可;不然,須要安裝syslinux程序包,然後複製/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目錄中; [root@cobbler02 ~]# cobbler get-loaders task started: 2016-05-30_082337_get_loaders task started (id=Download Bootloader Content, time=Mon May 30 08:23:37 2016) downloading http://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading http://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading http://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading http://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading http://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading http://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading http://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading http://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading http://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading http://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE ***
五、啓動rsyncd服務
[root@cobbler02 ~]# systemctl status rsyncd #檢查rsyncd服務的狀態,發現是關閉的 ● rsyncd.service - fast remote file copy program daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled) Active: inactive (dead) [root@cobbler02 ~]# systemctl enable rsyncd #開啓rsync的服務開機自啓動 Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service. [root@cobbler02 ~]# systemctl status rsyncd #檢查rsyncd服務的狀態 ● rsyncd.service - fast remote file copy program daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Active: inactive (dead) [root@cobbler02 ~]# systemctl start rsyncd #開啓rsync的服務 [root@cobbler02 ~]# systemctl status rsyncd #再次檢查rsyncd服務的狀態 ● rsyncd.service - fast remote file copy program daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2016-05-30 08:27:12 CST; 3s ago Main PID: 2455 (rsync) CGroup: /system.slice/rsyncd.service └─2455 /usr/bin/rsync --daemon --no-detach May 30 08:27:12 cobbler02 systemd[1]: Started fast remote file copy program daemon. May 30 08:27:12 cobbler02 systemd[1]: Starting fast remote file copy program daemon... May 30 08:27:12 cobbler02 rsyncd[2455]: rsyncd version 3.0.9 starting, listening on port 873
六、安裝debmirror
[root@cobbler02 ~]# yum install debmirror Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com No package debmirror available. Error: Nothing to do #這個是提供給debian的管理用的,centos7我沒找到這個包,博客中寫centos7能yum裝出來的人,麻煩不要把centos6那裏直接複製粘貼過來不加考證o(╯□╰)o請邊作邊寫博客,務必真實可靠not copy!
八、生成密碼來取代默認的密碼,更安全
#try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one #根據提示your-password-here,這裏是本身的密碼,random-phrase-here,這裏是隨機的干擾碼 [root@cobbler02 ~]# openssl passwd -1 -salt 'renjunjie' '123456' $1$renjunji$G7LpR5255qFguHrw7E0KP/ [root@cobbler02 ~]# sed -i s/'default_password_crypted:.*'/'default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP\/"'/g /etc/cobbler/settings [root@cobbler02 ~]# grep -n default_pass /etc/cobbler/settings 101:default_password_crypted: "$1$renjunji$G7LpR5255qFguHrw7E0KP/"
九、安裝cman fence-agents
[root@cobbler02 ~]# yum install -y cman fence-agents
十、其餘一些沒有提示報錯的小修改
# 用cobbler管理DHCP,修改242行manage_dhcp: 0 [root@cobbler02 ~]# sed -i 's/manage_dhcp: 0/manage_dhcp: 1/g' /etc/cobbler/settings [root@cobbler02 ~]# grep -n manage_dhcp /etc/cobbler/settings 242:manage_dhcp: 1 269:# if using cobbler with manage_dhcp, put the IP address 355:# Note that if manage_dhcp and manage_dns are disabled, the respective # 防止循環裝系統,適用於服務器第一啓動項是PXE啓動,修改292行pxe_just_once: 0 [root@cobbler02 ~]# sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings [root@cobbler02 ~]# grep -n pxe_just_once /etc/cobbler/settings 292:pxe_just_once: 1 [root@cobbler02 ~]#
#修改完後重啓服務再進行一次檢測,發現這個報錯,請往下走 [root@cobbler02 ~]# systemctl restart cobblerd.service [root@cobbler02 ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : debmirror package is not installed, it will be required to manage debian deployments and repositories Restart cobblerd and then run 'cobbler sync' to apply changes. [root@cobbler02 ~]# yum install -y debmirror #再次安裝centos7就是沒得,求適用於centos7的rpm包或者適用於centos7的編譯源碼包 Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com No package debmirror available. Error: Nothing to do

 

5.1 配置DHCP

 

centos6系列:

# 修改cobbler的dhcp模版,這個模板會覆蓋dhcp自己的配置文件。 [root@linux-node1 ~]# vim /etc/cobbler/dhcp.template #添加以下 subnet 192.168.31.0 netmask 255.255.255.0 { option domain-name-servers 223.5.5.5; option routers 192.168.31.1; range dynamic-bootp 192.168.31.100 192.168.31.250; option subnet-mask 255.255.255.0; next-server 192.168.31.71; filename "/data/sys/kickstart/ks.cfg"; next-server 192.168.31.71; filename "pxelinux.0"; } #同步cobbler的配置,能夠看到同步幹了哪些事 [root@cobbler cobbler]# cobbler sync task started: 2016-05-27_145749_sync task started (id=Sync, time=Fri May 27 14:57:49 2016) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images 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 /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk 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 images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: Starting dhcpd: [ OK ] received on stderr: 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]# cobbler check The following are potential configuration items that you may want to fix: 1 : file /etc/xinetd.d/rsync does not exist Restart cobblerd and then run 'cobbler sync' to apply changes.

centos7系列:

# 修改cobbler的dhcp模版,這個模板會覆蓋dhcp自己的配置文件。 [root@cobbler02 ~]# vim /etc/cobbler/dhcp.template #添加以下 subnet 192.168.31.0 netmask 255.255.255.0 { option domain-name-servers 223.5.5.5; option routers 192.168.31.1; range dynamic-bootp 192.168.31.100 192.168.31.250; option subnet-mask 255.255.255.0; next-server $next_server; default-lease-time 43200; max-lease-time 86400; } #同步cobbler的配置,能夠看到同步幹了哪些事 [root@cobbler02 ~]# cobbler sync task started: 2016-05-30_092640_sync task started (id=Sync, time=Mon May 30 09:26:40 2016) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/pxelinux.cfg/default removing: /var/lib/tftpboot/grub/images removing: /var/lib/tftpboot/grub/grub-x86.efi removing: /var/lib/tftpboot/grub/grub-x86_64.efi removing: /var/lib/tftpboot/grub/efidefault removing: /var/lib/tftpboot/s390x/profile_list copying bootloaders 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 images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service 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 ***

5.2 設置開機自啓動

 

centos6系列:

方法1:所有寫到rc.local
[root@cobbler cobbler]# echo "/etc/init.d/httpd restart" >>/etc/rc.local [root@cobbler cobbler]# echo "/etc/init.d/xinetd restart" >>/etc/rc.local [root@cobbler cobbler]# echo "/etc/init.d/cobblerd restart" >>/etc/rc.local [root@cobbler cobbler]# echo "/etc/init.d/dhcpd restart" >>/etc/rc.local 方法2:寫一個專門的cobbler開機腳本,這要贊一下張耀,nice boat! cat >>/etc/init.d/cobbler<<EOF #!/bin/bash # chkconfig: 345 80 90 # description:cobbler case \$1 in start) /etc/init.d/httpd start /etc/init.d/xinetd start /etc/init.d/dhcpd start /etc/init.d/cobblerd start ;; stop) /etc/init.d/httpd stop /etc/init.d/xinetd stop /etc/init.d/dhcpd stop /etc/init.d/cobblerd stop ;; restart) /etc/init.d/httpd restart /etc/init.d/xinetd restart /etc/init.d/dhcpd restart /etc/init.d/cobblerd restart ;; status) /etc/init.d/httpd status /etc/init.d/xinetd status /etc/init.d/dhcpd status /etc/init.d/cobblerd status ;; sync) cobbler sync ;; *) echo "Input error,please in put 'start|stop|restart|status|sync'!" exit 2 ;; esac EOF

centos7系列:

#設置開機自動啓動,避免白辛苦一場 [root@cobbler02 multi-user.target.wants]# systemctl enable dhcpd.service [root@cobbler02 multi-user.target.wants]# systemctl enable rsyncd.service [root@cobbler02 multi-user.target.wants]# systemctl enable tftp.service [root@cobbler02 multi-user.target.wants]# systemctl enable httpd.service [root@cobbler02 multi-user.target.wants]# systemctl enable cobblerd.service #將全部的服務重啓一遍,避免有服務忘了開啓 [root@cobbler02 multi-user.target.wants]# systemctl restart dhcpd.service [root@cobbler02 multi-user.target.wants]# systemctl restart rsyncd.service [root@cobbler02 multi-user.target.wants]# systemctl restart tftp.service [root@cobbler02 multi-user.target.wants]# systemctl restart httpd.service [root@cobbler02 multi-user.target.wants]# systemctl restart cobblerd.service

6.Cobbler的命令行管理(6和7的命令是一致的)

[root@cobbler ~]# cobbler usage ===== cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ... [add|edit|copy|getks*|list|remove|rename|report] [options|--help] cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help] cobbler check 覈對當前設置是否有問題 cobbler list 列出全部的cobbler元素cobbler report 列出元素的詳細信息 cobbler sync 同步配置到數據目錄,更改配置最好都要執行下 cobbler reposync 同步yum倉庫 cobbler distro 查看導入的發行版系統信息 cobbler system 查看添加的系統信息cobbler profile 查看配置信息

6.1導入鏡像

#掛載centos光盤鏡像 [root@cobbler ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 is write-protected, mounting read-only #導入鏡像 [root@cobbler ~]# cobbler import --path=/mnt/ --name=CentOS-6.6-x86_64 --arch=x86_64 task started: 2016-05-27_153110_import task started (id=Media import, time=Fri May 27 15:31:10 2016) 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.6-x86_64: creating new distro: CentOS-6.6-x86_64 trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64 -> /var/www/cobbler/links/CentOS-6.6-x86_64 creating new profile: CentOS-6.6-x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64 for CentOS-6.6-x86_64 processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64 looking for /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/repodata/*comps*.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/repodata *** TASK COMPLETE *** # --path 鏡像路徑 # --name 爲安裝源定義一個名字 # --arch 指定安裝源是32位、64位、ia64, 目前支持的選項有: x86│x86_64│ia64 # 安裝源的惟一標示就是根據name參數來定義,本例導入成功後,安裝源的惟一標示就是:CentOS-6.6-x86_64,若是重複,系統會提示導入失敗。 #查看鏡像列表 [root@cobbler ~]# cobbler distro list CentOS-6.6-x86_64 ## 鏡像存放目錄,cobbler會將鏡像中的全部安裝文件拷貝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-6.6-x86_64目錄下。所以/var/www/cobbler目錄必須具備足夠容納安裝文件的空間 [root@cobbler ~]# cd /var/www/cobbler/ks_mirror/ [root@cobbler ks_mirror]# ls CentOS-6.6-x86_64 config [root@cobbler ks_mirror]# ls CentOS-6.6-x86_64/ CentOS_BuildTag EULA images Packages repodata RPM-GPG-KEY-CentOS-Debug-6 RPM-GPG-KEY-CentOS-Testing-6 EFI GPL isolinux RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Security-6 TRANS.TBL

 

6.2配置ks.cfg(使用centos7的鏡像的時候,注意下方的ks.cfg要在安裝包那裏刪除掉@server-policy,這玩意在7沒有的,不要問我爲啥會特地在這裏寫,由於愛過!!!!!!被傷過!!!!!)

[root@cobbler ks_mirror]# cd /var/lib/cobbler/kickstarts/ [root@cobbler kickstarts]# ls default.ks esxi5-ks.cfg legacy.ks sample_autoyast.xml sample_esx4.ks sample_esxi5.ks sample_old.seed esxi4-ks.cfg install_profiles pxerescue.ks sample_end.ks(默認使用的ks文件) sample_esxi4.ks sample.ks sample.seed [root@cobbler kickstarts]# vim CentOS-6.6-x86_64.cfg #修改爲如下內容 [root@cobbler kickstarts]# cat CentOS-6.6-x86_64.cfg # kickstart template for Fedora 8 and later. # (includes %end blocks) # do not use with earlier distros #platform=x86, AMD64, or Intel EM64T # System authorization information #auth --useshadow --enablemd5 authconfig --enableshadow --passalgo=sha512 # System bootloader configuration bootloader --location=mbr --driveorder=sda --append="nomodeset crashkernel=auto rhgb quiet" # Partition clearing information clearpart --all --initlabel # Use text mode install text # Firewall configuration firewall --disabled # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard us # System language lang en_US # Use network installation url --url=$tree # If any cobbler repo definitions were referenced in the kickstart profile, include them here. $yum_repo_stanza # Network information $SNIPPET('network_config') # Reboot after installation reboot logging --level=info #Root password rootpw --iscrypted $default_password_crypted # SELinux configuration selinux --disabled # Do not configure the X Window System skipx # System timezone timezone Asia/Shanghai # Install OS instead of upgrade install # Clear the Master Boot Record zerombr # Allow anaconda to partition the system as needed #autopart part /boot --fstype=ext4 --asprimary --size=200 part swap --asprimary --size=1024 part / --fstype=ext4 --grow --asprimary --size=200 %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end %packages @base @compat-libraries @core @debugging @development @dial-up @hardware-monitoring @performance @server-policy sgpio device-mapper-persistent-data systemtap-client tree lrzsz telnet nmap dos2unix %end %post --nochroot $SNIPPET('log_ks_post_nochroot') %end %post $SNIPPET('log_ks_post') # Start yum configuration $yum_config_stanza # End yum configuration $SNIPPET('post_install_kernel_options') $SNIPPET('post_install_network_config') $SNIPPET('func_register_if_enabled') $SNIPPET('download_config_files') $SNIPPET('koan_environment') $SNIPPET('redhat_register') $SNIPPET('cobbler_register') # Enable post-install boot notification $SNIPPET('post_anamon') # Start final steps $SNIPPET('kickstart_done') # End final steps %end # 在第一次導入系統鏡像後,Cobbler會給鏡像指定一個默認的kickstart自動安裝文件在/var/lib/cobbler/kickstarts下的sample_end.ks。 [root@cobbler kickstarts]# cobbler list distros: CentOS-6.6-x86_64 profiles: CentOS-6.6-x86_64 systems: repos: images: mgmtclasses: packages: files: # 查看安裝鏡像文件信息 [root@cobbler kickstarts]# cobbler distro report --name=CentOS-6.6-x86_64 Name : CentOS-6.6-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/CentOS-6.6-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-6.6-x86_64'} Management Classes : [] OS Version : rhel6 Owners : ['admin'] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {} # 查看全部的profile設置 cobbler profile report # 查看指定的profile設置 cobbler profile report --name=CentOS-6.6-x86_64 [root@cobbler kickstarts]# cobbler profile report Name : CentOS-6.6-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-6.6-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/sample_end.ks Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm # 編輯profile,修改關聯的ks文件 [root@cobbler kickstarts]# cobbler profile edit --name=CentOS-6.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.cfg # 修改安裝系統的內核參數,在CentOS7系統有一個地方變了,就是網卡名變成eno*****這種形式,可是爲了運維標準化,咱們須要將它變成咱們經常使用的eth0,所以使用下面的參數。但要注意是CentOS7才須要下面的步驟,CentOS6不須要。 ###下次作centos7版本的cobbler的時候再續寫 cobbler profile edit --name=CentOS-7.0-x86_64 --kopts='net.ifnames=0 biosdevname=0' #能夠看到下面Kickstart那裏的配置cfg文件地址被改變了 [root@cobbler kickstarts]# cobbler profile report --name=CentOS-6.6-x86_64 Name : CentOS-6.6-x86_64 TFTP Boot Files : {} Comment : DHCP Tag : default Distribution : CentOS-6.6-x86_64 Enable gPXE? : 0 Enable PXE Menu? : 1 Fetchable Files : {} Kernel Options : {} Kernel Options (Post Install) : {} Kickstart : /var/lib/cobbler/kickstarts/CentOS-6.6-x86_64.cfg Kickstart Metadata : {} Management Classes : [] Management Parameters : <<inherit>> Name Servers : [] Name Servers Search Path : [] Owners : ['admin'] Parent Profile : Internal proxy : Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Repos : [] Server Override : <<inherit>> Template Files : {} Virt Auto Boot : 1 Virt Bridge : xenbr0 Virt CPUs : 1 Virt Disk Driver Type : raw Virt File Size(GB) : 5 Virt Path : Virt RAM (MB) : 512 Virt Type : kvm #同步下cobbler數據,每次修改完都要鏡像同步 [root@cobbler kickstarts]# cobbler sync task started: 2016-05-27_162048_sync task started (id=Sync, time=Fri May 27 16:20:48 2016) running pre-sync triggers cleaning trees #修改這裏,開機畫面顯示,有問題來找me個鬼,本身反覆看本文檔,作的有問題必定是你本身的鍋 [root@cobbler kickstarts]# vim /etc/cobbler/pxe/pxedefault.template MENU TITLE Cobbler | QQ:315420700 [root@cobbler kickstarts]# cobbler sync # 修改配置都要同步

wKioL1dICaeyxIpGAAAmeMdaz_Q271.jpg

這裏是若是方向鍵不選擇第二項就沒法裝機,不算自動化,咱們須要進行手動指定才能夠徹底自動化

定製化安裝

kickstart實現某臺服務器使用指定ks文件可能比較複雜,可是Cobbler就很簡單了,區分一臺服務器的最簡單的方法就是物理MAC地址。

VMware查看物理MAC地址

wKiom1dICaXQyS0JAABvtW_0gMU361.jpg

[root@cobbler kickstarts]# cobbler system add --name=ren --mac=00:0C:29:4E:73:7F --profile=CentOS-6.6-x86_64 --ip-address=192.168.31.120 --subnet=255.255.255.0 --gateway=192.168.31.1 --interface=eth0 --static=1 --hostname=linux_node --name-servers="223.5.5.5" [root@cobbler kickstarts]# cobbler system list ren [root@cobbler kickstarts]# cobbler sync ###特此說明下 若是你有幾塊網卡的話,只自定義第二塊網卡爲外網,第一塊網卡不一塊兒配置,就會仍是出如今那個選擇界面。
#補充!多網卡像這樣指定IP和網卡 [root@cobbler02 cobbler]# cobbler system add --name=zabbix02 --mac=00:0C:29:3E:E6:FF --profile=CentOS-7.2-x86_64 --ip-address=10.0.0.82 --subnet=255.255.255.0 --interface=eth0 --static=1 [root@cobbler02 cobbler]# cobbler system edit --name=zabbix02 --mac=00:0C:29:3E:E6:09 --profile=CentOS-7.2-x86_64 --ip-address=192.168.31.82 --subnet=255.255.255.0 --gateway=192.168.31.1 --interface=eth1 --static=1 --hostname=zabbix --name-servers="223.5.5.5"

開啓空的虛擬機開始裝系統

wKiom1dIDwLTDvUOAAA9xrgLbRA286.jpg

 

Cobbler的Web管理界面的安裝與配置

新版 Cobbler 的 Web 界面使用的是 https
登陸URL: https://192.168.31.71/cobbler_web

wKioL1dIEhvhoNUVAABFd51dM44828.jpg默認用戶名:cobbler
默認密碼 :cobbler

/etc/cobbler/users.conf       # Web服務受權配置文件

/etc/cobbler/users.digest     # 用於web訪問的用戶名密碼配置文件

#在Cobbler組添加ren用戶,提示輸入2遍密碼確認

[root@cobbler kickstarts]# htdigest /etc/cobbler/users.digest "Cobbler" ren
Adding user ren in realm Cobbler
New password:
Re-type new password:

同步下

[root@cobbler kickstarts]# cobbler sync

###請各位拿起手上的鼠標,去點出來一個世界吧j_0006.gif

附錄:

添加repos源

1.添加repo源
#舉個栗子,centos7.2版本的openstack的repo源 [root@cobbler02 ~]# cobbler repo add --name=centos7.2-openstack-mitaka --mirror=http://mirrors.aliyun.com/centos/7.2.1511/cloud/x86_64/openstack-mitaka/ --arch=x86_64 --breed=yum #添加repo源,舉個栗子,centos7版本的epel源 [root@cobbler02 ~]# cobbler repo add --name=centos7-x86_64-epel --mirror=http://mirrors.aliyun.com/epel/7/x86_64/ --arch=x86_64 --breed=yum 2.同步repo [root@cobbler02 ~]# cobbler reposync 3.添加repo到對應的profile cobbler profile edit --name=Centos-7-x86_64 --repos= 4.修改kickstart文件。添加。(些到%post %end中間) %post systemctl disable postfix.service $yum_config_stanza %end 5.添加定時任務,按期同步repo

客戶機重裝系統教程:1

centos7系列:

1)不指定詳細system模板,讓cobbler本身裝一臺centos7的鏡像

#注意上面若是沒有指定epel源的是沒法裝koan包的 #執行這個命令:wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo [root@zabbix ~]# yum install -y koan #指定cobbler的服務器 [root@zabbix ~]# koan --server=192.168.31.73 --list=profiles - looking for Cobbler at http://192.168.31.73:80/cobbler_api CentOS-7.2-x86_64 #指定從哪一個鏡像進行安裝 [root@zabbix ~]# koan --replace-self --server=192.168.31.73 --profile=CentOS-7.2-x86_64 - looking for Cobbler at http://192.168.31.73:80/cobbler_api - reading URL: http://192.168.31.73/cblr/svc/op/ks/profile/CentOS-7.2-x86_64 install_tree: http://192.168.31.73/cblr/links/CentOS-7.2-x86_64 downloading initrd initrd.img to /boot/initrd.img_koan url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img - reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img downloading kernel vmlinuz to /boot/vmlinuz_koan url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz - reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz - ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ksdevice=link lang= text net.ifnames=0 ks=http://192.168.31.73/cblr/svc/op/ks/profile/CentOS-7.2-x86_64 biosdevname=0 kssendmac "', '--copy-default', '--make-default', '--title=kick1464687061'] - ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root'] - reboot to apply changes #重啓系統 [root@zabbix ~]# reboot

2)指定設定好的系統配置,讓系統生成一個指定的mac地址綁定的ip和其餘你指定的東西

[root@zabbix ~]# yum install -y koan #指定cobbler的服務器選擇system模板 [root@MiWiFi-R2D-srv ~]# koan --server=192.168.31.73 --list=system - looking for Cobbler at http://192.168.31.73:80/cobbler_api koan does not know how [root@MiWiFi-R2D-srv ~]# koan --replace-self --server=192.168.31.73 --system=zabbix02 - looking for Cobbler at http://192.168.31.73:80/cobbler_api - reading URL: http://192.168.31.73/cblr/svc/op/ks/system/zabbix02 install_tree: http://192.168.31.73/cblr/links/CentOS-7.2-x86_64 downloading initrd initrd.img to /boot/initrd.img_koan url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img - reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/initrd.img downloading kernel vmlinuz to /boot/vmlinuz_koan url=http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz - reading URL: http://192.168.31.73/cobbler/images/CentOS-7.2-x86_64/vmlinuz - ['/sbin/grubby', '--add-kernel', '/boot/vmlinuz_koan', '--initrd', '/boot/initrd.img_koan', '--args', '"ksdevice=link lang= text net.ifnames=0 ks=http://192.168.31.73/cblr/svc/op/ks/system/zabbix02 biosdevname=0 kssendmac "', '--copy-default', '--make-default', '--title=kick1464688081'] - ['/sbin/grubby', '--update-kernel', '/boot/vmlinuz_koan', '--remove-args=root'] - reboot to apply changes to list that [root@MiWiFi-R2D-srv ~]# reboot

wKiom1dNXx2Rv_TJAAD2VqDefpE781.jpg

wKioL1dNYBrDaHbUAACNTjug6d8012.jpg

wKiom1dNYQKjItlHAADfOEJzCR4637.jpg

已經按照指定的system配置安裝好了,可是這裏出現了一個問題,雙網卡的話,兩個網段,如今的路由都是同一個了,因此上不了網了,求高手解決

wKioL1dNYf-jeO3iAABGPF15XNU348.jpg

相關文章
相關標籤/搜索