Cobbler是一個快速網絡安裝linux的服務,而且在經過調整也可以支持網絡安裝windows。該工具使用python開發,小巧輕便(才15k行代碼),使用簡單的命令即可完成PXE網絡安裝環境的配置,同時還可以管理DHCP,DNS,以及yum包鏡像。
Cobbler支持命令行管理,web界面管理,還提供了API接口,可以方便二次開發使用
# yum install cobbler 安裝cobbler # service httpd start 文件服務器 [root@MinR dhcp]# service cobblerd start 啓動cobbler [root@node3 ~]# 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 : 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
可以看到這裏一共有8個報錯,要挨個手動修復
[root@node3 ~]# vim /etc/cobbler/setting 編輯文件 server: 172.16.17.12 修改 next_server: 172.16.17.12 [root@node3 ~]# yum list syslinux 檢查syslinux 是否已安裝,這裏已然安裝 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages syslinux.x86_64 4.02-8.el6 @base [root@node3 ~]# chkconfig rsync on 讓rsync開機啓動 [root@node3 ~]# yum install pykickstart 安裝pykickstart 修改默認密碼 [root@node3 ~]# openssl passwd -1 -salt `openssl rand -hex 4` Password: $1$28ad5f04$Q/rTKOO5LqSXaIXfuUTz31 把上面的字串複製替換默認的加密密碼 default_password_crypted: "$1$28ad5f04$Q/rTKOO5LqSXaIXfuUTz31." [root@node3 ~]# service cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ] [root@node3 ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : 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. 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories 3 : 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. [root@node3 syslinux]# cp -r ./* /var/lib/cobbler/loaders/ 複製所需文件 編輯 /etc/cobbler/setting不用自帶的tftp manage_tftpd: 0 [root@node3 ~]# yum -y install dhcp 安裝dhcp [root@node3 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 編輯dhcp的配置文件 [root@node3 ~]# vim /etc/dhcp/dhcpd.conf option domain-name "example.org"; option domain-name-servers 172.16.0.1; default-lease-time 43200; max-lease-time 86400; subnet 172.16.0.0 netmask 255.255.0.0 { range 172.16.100.101 172.16.100.200; option routers 172.16.17.12; } next-server 172.16.17.12; filename="pxelinux.0"; [root@node3 ~]# service dhcpd restart 啓動dhcp Starting dhcpd: [ OK ] [root@node3 ~]# yum -y install tftp-server 安裝tftp這裏已經安裝過 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process Package tftp-server-0.49-7.el6.x86_64 already installed and latest version Nothing to do [root@node3 ~]# chkconfig tftp on 啓動tftp [root@node3 ~]# service xinetd start Starting xinetd: [ OK ] [root@node3 ~]# cobbler distro –help disrto命令 usage ===== cobbler distro add cobbler distro copy cobbler distro edit cobbler distro find cobbler distro list cobbler distro remove cobbler distro rename cobbler distro report [root@node3 ~]# mount -r /dev/cdrom /mnt 掛載鏡像文件 [root@node3 ~]# cobbler import –help import命令 Usage: cobbler [options] Options: -h, --help show this help message and exit --arch=ARCH OS architecture being imported --breed=BREED the breed being imported --os-version=OS_VERSION the version being imported --path=PATH local path or rsync location --name=NAME name, ex 'RHEL-5' --available-as=AVAILABLE_AS tree is here, don't mirror --kickstart=KICKSTART_FILE assign this kickstart file --rsync-flags=RSYNC_FLAGS pass additional flags to rsync [root@node3 ~]# cobbler import --path=/mnt --name=centos-6.5-x86_64 創建yum源 task started: 2014-09-29_232236_import task started (id=Media import, time=Mon Sep 29 23:22:36 2014) 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-x86_64: creating new distro: centos-6.5-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos-6.5-x86_64 -> /var/www/cobbler/links/centos-6.5-x86_64 creating new profile: centos-6.5-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.5-x86_64 for centos-6.5-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos-6.5-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/centos-6.5-x86_64 looking for /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/*comps*.xml running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml /var/www/cobbler/ks_mirror/centos-6.5-x86_64 received on stdout: Spawning worker 0 with 3995 pkgs Workers Finished Gathering worker results Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete received on stderr: *** TASK COMPLETE *** 這一步時間很長,請耐心等待 [root@node3 ~]# cobbler distro list centos-6.5-x86_64
下載和配置kickstart文件
[root@node3 ~]# wget http://172.16.0.1/centos6.x86_64.cfg --2014-09-29 23:37:30-- http://172.16.0.1/centos6.x86_64.cfg Connecting to 172.16.0.1:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2823 (2.8K) [text/plain] Saving to: “centos6.x86_64.cfg” 100%[=========================================================================>] 2,823 --.-K/s in 0s 2014-09-29 23:37:31 (62.8 MB/s) - “centos6.x86_64.cfg” saved [2823/2823] [root@node3 ~]# ksvalidator centos6.x86_64.cfg 驗證是否有語法錯誤 [root@node3 ~]# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/root/centos6.x86_64.cfg [root@node3 ~]# cobbler profile list centos-6.5-x86_64 centos-6.5-x86_64-basic [root@node3 ~]# cobbler sync 此時就可以實現自動給無操作系統的大規模主機安裝操作系統了。 [root@node3 ~]# yum install cobbler-web [root@node3 ~]# cd /etc/cobbler/[root@node3 cobbler]# vim modules.conf [authentication]module = authn_pam [root@node3 cobbler]# useradd cobbleradmin 隨便添加個用戶[root@node3 cobbler]# passwd cobbleradmin 給用戶設定密碼Changing password for user cobbleradmin.New password: BAD PASSWORD: it is based on a dictionary wordBAD PASSWORD: is too simpleRetype new password: passwd: all authentication tokens updated successfully. [root@node3 cobbler]# vim users.conf [admins]admin = "cobbleradmin"cobbler = ""
瀏覽器中輸入查看