Linux 營運自動化之Cobbler全自動安裝Centos管理與使用詳解

來源:互聯網
上載者:User

標籤:linux 營運自動化之cobbler全自動安裝centos管理與使用詳解

簡介:

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

    網路安裝伺服器套件 Cobbler(補鞋匠)從前,我們一直在做裝機民工這份很有前途的職業。自打若干年前 Red Hat 推出了 Kickstart,此後我們頓覺身價倍增。不再需要刻了光碟片一台一台地安裝 Linux,只要搞定 PXE、DHCP、TFTP,還有那滿屏眼花繚亂不知所云的 Kickstart 指令碼,我們就可以像哈裡傳輸速率一樣,輕點魔棒,瞬間安裝上百台伺服器。這一堆花裡胡哨的東西可不是一般人都能整明白的,沒有大專以上學曆,通不過英語四級,根本別想玩轉。總而言之,這是一份多麼有前途,多麼有技術含量的工作啊。很不幸,Red Hat 最新(Cobbler項目最初在2008年左右發布)發布了網路安裝伺服器套件 Cobbler(補鞋匠),它已將 Linux 網路安裝的技術門檻,從大專以上文化水平,成功降低到初中以下,連補鞋匠都能學會。對於我們這些在裝機領域浸淫多年,經驗豐富,老驥伏櫪,志在千裡的民工兄弟們來說,不啻為一個晴天霹靂。

一、安裝軟體

1、安裝cobbler

[[email protected] ~]# yum install cobbler pykickstart debmirror

2、 其他服務的安裝

額外需要的服務還有dhcp tftp,rsync,xinetd,httpd,syslinux。所以如果安裝系統的時候如果這幾個包沒裝上,請手動安裝。

二、啟動服務並檢測cobbler

1、啟動httpd和cobblerd服務

[[email protected] ~]# /etc/init.d/httpd startStarting httpd: httpd: apr_sockaddr_info_get() failed for node1 [ OK ][[email protected] ~]# /etc/init.d/cobblerd startStarting cobbler daemon: [ OK ]

2、執行“cobbler check命令檢查存的問題,逐一按提示解決:

[[email protected] ~]# 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 : comment out ‘dists‘ on /etc/debmirror.conf for proper debian support 6 : comment out ‘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 themRestart cobblerd and then run ‘cobbler sync‘ to apply changes. 如上各問題的解決方案如下所示: 1、修改/etc/cobbler/settings檔案中,server: 172.16.22.6; 2、修改/etc/cobbler/settings檔案中,next_server: 172.16.22.6; 3、如果當前節點可以訪問互連網,執行“cobbler get-loaders”命令即可;否則,需要安裝syslinux程式包,執行: [[email protected] ~]# cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/cobbler/loaders/ 4、執行[[email protected] ~]# chkconfig rsync on 5、注釋/etc/debmirror.conf檔案中的“@dists="sid";”一行; 6、注釋/etc/debmirror.conf檔案中的“@arches="i386";”一行; 7、執行“openssl passwd -1 -salt ‘random-phrase-here‘ ‘your-password-here‘”產生密碼,並用替換/etc/cobbler/settings檔案中default_password_crypted參數的值,如default_password_crypted: "$1$random-p$AOw9RDIWQm6tfUo9Ediu/0"; 8、執行“yum -y install cman fence-agents”命令安裝相應的程式包即可;

3、重啟cobblerd服務,同步新的配置至cobbler,再次檢測

[[email protected] ~]# /etc/init.d/cobblerd restartStopping cobbler daemon: [ OK ]Starting cobbler daemon: [ OK ][[email protected] ~]# cobbler synctask started: 2014-10-05_172520_synctask started (id=Sync, time=Sun Oct 5 17:25:20 2014)running pre-sync triggerscleaning treesmkdir: /var/lib/tftpboot/pxelinux.cfgmkdir: /var/lib/tftpboot/grubmkdir: /var/lib/tftpboot/s390xmkdir: /var/lib/tftpboot/ppcmkdir: /var/lib/tftpboot/etcremoving: /var/lib/tftpboot/grub/imagescopying bootloaderstrying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32copying: /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdiskcopying distros to tftpbootcopying imagesgenerating PXE configuration filesgenerating PXE menu structurerendering TFTPD filesgenerating /etc/xinetd.d/tftpcleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning shell triggers from /var/lib/cobbler/triggers/sync/post/*running python triggers from /var/lib/cobbler/triggers/change/*running python trigger cobbler.modules.scm_trackrunning shell triggers from /var/lib/cobbler/triggers/change/**** TASK COMPLETE ***[[email protected] ~]# cobbler check

三、配置及啟動cobbler所依賴的各服務

cobbler的運行依賴於dhcp、tftp、rsync及dns服務。cobbler可自行管理這些服務中的部分甚至是全部,但需要配置/etc/cobbler/settings檔案中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分別進行定義。另外,由於每種服務都有著不同的實現方式,如若需要進行自訂,需要通過修改/etc/cobbler/modules.conf設定檔中各服務的模組參數的值來實現。

本文採用了獨立管理的方式,即不通過cobbler來管理這些服務。

1、配置dhcp服務

[[email protected] syslinux]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.confcp: overwrite `/etc/dhcp/dhcpd.conf‘? y[[email protected] syslinux]# vim /etc/dhcp/dhcpd.confoption domain-name "whb.com";option domain-name-servers 172.16.22.1;default-lease-time 43200;max-lease-time 86400;log-facility local7;subnet 172.16.0.0 netmask 255.255.0.0 {range 172.16.22.20 172.16.22.25;option routers 172.16.22.1;next-server 172.16.22.6;filename="pxelinux.0";}

檢查設定檔並重啟服務

[[email protected] ~]# /etc/init.d/dhcpd configtestSyntax: OK[[email protected] ~]# /etc/init.d/dhcpd restartShutting down dhcpd: [ OK ]Starting dhcpd: [ OK ]

2、配置tftp服務

[[email protected] ~]# chkconfig tftp on[[email protected] ~]# service xinetd restartStopping xinetd: [FAILED]Starting xinetd: [ OK ]

四、配置cobbler

1、管理distro

掛載ISO鏡像,並定義distro,可以通過為其指定外部的安裝引導核心及ramdisk檔案的方式實現。而如果已經有完整的系統安裝樹(如CentOS6的安裝鏡像)則推薦使用import直接匯入的方式進行。本文為直接匯入

[[email protected] ~]# mount /dev/cdrom /mnt/mount: block device /dev/sr0 is write-protected, mounting read-only[[email protected] ~]# cobbler import --name=centos-6.5-x86_64 --path=/mnt/task started: 2014-10-05_181334_importtask started (id=Media import, time=Sun Oct 5 18:13:34 2014)Found a candidate signature: breed=redhat, version=rhel6Found a matching signature: breed=redhat, version=rhel6Adding distros from path /var/www/cobbler/ks_mirror/centos-6.5-x86_64:creating new distro: centos-6.5-x86_64trying symlink: /var/www/cobbler/ks_mirror/centos-6.5-x86_64 -> /var/www/cobbler/links/centos-6.5-x86_64creating new profile: centos-6.5-x86_64associating reposchecking for rsync repo(s)checking for rhn repo(s)checking for yum repo(s)starting descent into /var/www/cobbler/ks_mirror/centos-6.5-x86_64 for centos-6.5-x86_64processing repo at : /var/www/cobbler/ks_mirror/centos-6.5-x86_64need to process repo/comps: /var/www/cobbler/ks_mirror/centos-6.5-x86_64looking for /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/*comps*.xmlrunning: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/0dae8d32824acd9dbdf7ed72f628152dd00b85e4bd802e6b46e4d7b78c1042a3-c6-x86_64-comps.xml /var/www/cobbler/ks_mirror/centos-6.5-x86_64received on stdout: Spawning worker 0 with 3887 pkgsWorkers FinishedGathering worker resultsSaving Primary metadataSaving file lists metadataSaving other metadataGenerating sqlite DBsSqlite DBs completereceived on stderr:*** TASK COMPLETE *** 列出所有的distro:[[email protected] ~]# cobbler distro listcentos-6.5-x86_64

 

2、管理profile

cobbler使用profile來為特定的需求類別提供所需要安裝配置,即在distro的基礎上通過提供kickstart檔案來產生一個特定的系統安裝配置。distro的profile可以出現在PXE的引導菜單中作為安裝的選擇之一。

因此,如果需要為前面建立的centos-6.5-x86_64這個distro提供一個可引導安裝條目,其用到的kickstart檔案為/tmp/centos-6.5-x86_64.cfg(只提供了最基本的程式包),則可通過如下命令實現。

[[email protected] ~]# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/tmp/centos6.x86_64.cfg列出所有的profile:[[email protected] tmp]# cobbler profile listcentos-6.5-x86_64centos-6.5-x86_64-basic

五、測試

建立虛擬機器,網路啟動

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/4B/BA/wKiom1QxQp3ydCpmAACfB5u_unc393.jpg" style="float:none;" title="1.png" alt="wKiom1QxQp3ydCpmAACfB5u_unc393.jpg" />

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M01/4B/BC/wKioL1QxQtHCocreAAEcf0aO0yQ645.jpg" style="float:none;" title="2.png" alt="wKioL1QxQtHCocreAAEcf0aO0yQ645.jpg" />

看到這個圖就大功告成了!!!!!

本文出自 “gentoo” 部落格,請務必保留此出處http://linuxgentoo.blog.51cto.com/7678232/1560728

Linux 營運自動化之Cobbler全自動安裝Centos管理與使用詳解

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.