Cobbler 和 koan 的安裝源:
ubuntu(12.04)的源:
注: Ubuntu的可用源可從這里查詢:http://wiki.ubuntu.org.cn/Template:12.04source
cat /etc/apt/source.list
deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted universe multiverse
apt-get install koan
RHEL(6.4)需要以下兩個源:
Centos源: http://mirror.centos.org/centos/6/os/x86_64/
Epel源: http://download.fedoraproject.org/pub/epel/6/$basearch
下面主要以RHEL6.4上部署Cobbler為例:
rpm -ivh ftp://ftp.muug.mb.ca/mirror/fedora/epel/6/x86_64/Django14-1.4.21-1.el6.noarch.rpm //cobbler-web需要Django支持. yum install cobbler cobbler-web tftp-server dhcp xinetd rsync httpd yum install koan //此在需要借助Cobbler自動重裝系統的Client上安裝.可通過它來修改Client 的grub.conf,從而讓Client從網絡啟動,來重裝系統.
部署前:
1. cobbler check //讓Cobbler自行判斷,正常啟動你還需要做哪些工作.
2. 根據提示修改:
(1)修linux的Selinux為禁用。
vim /etc/selinux/config 【SELINUX=disabled //修改后需reboot(重啟)】
(2)修改tftp、rsync服務為啟動
vim /etc/xinet.d/tftp 和 /etc/xinet.d/rsync 【disable = no】 chkconfig xinetd on
(3)安裝缺少的包
yum install syslinux-nonlinux debmirror ---》對debian linux的鏡像源的支持,若需要做本地apt源時,需要安裝。 pykickstart
(4)修改cobbler的主配置文件【注: cobbler的主配置文件修改后,必須重啟才能生效.】
cp -a /etc/cobbler/settings{,.bak} vim /etc/cobbler/settings 【 allow_dynamic_settings: 1 //開啟不重啟cobbler,也可動態載入修改的主配置信息. 注: 此項,僅在使用cobbler setting edit --name=配置項名 --value=值時才有效, 但此命令會清除配置文件中所有注釋內容. manage_dhcp: 1 //若需要cobbler管理DHCP,則需要將其設置為1 注: 若要使用dhcpd 來提供DHCP服務,則修改dhcp.template 若要使用dnsmasq來提供DHCP服務,則修改 dnsmasq.template但無論使用誰,都需要將其設置為1.。 另注:modules.conf中默認設置Cobbler使用 dhcpd來提供DHCP服務. server: 192.168.137.203 //指定cobbler監聽的地址 next_server: 192.168.137.203 //指定tftp server的地址 pxe_just_once: 1 //避免循環從網絡啟動;當PXE客戶端安裝完成后,會通知cobbler, cobbler將設置netboot標志為false,強制PXE客戶端從本地磁盤引導。 】
(5)復制PXE啟動所需的引導文件
cd /usr/share/syslinux //此為syslinux-nonlinux的安裝文件存儲位置。 cp pxelinux.0 menu.c32 vesamenu.c32 memdisk /var/lib/cobbler/loaders/ 注: menu.c32 :此為文本模式背景 vesamenu.c32 : 此為圖形模式背景 memdisk :引導IMG、IMA、ISO映像,所必須加載的文件,它也可用來加載WinPE.ISO來提供網絡PE.
或直接執行:
cobbler get-loaders //若聯網則直接執行它即可,自動下載 [root@cobbler etc]# ls /var/lib/cobbler/loaders/ COPYING.elilo COPYING.yaboot grub-x86_64.efi memdisk pxelinux.0 vesamenu.c32 COPYING.syslinux elilo-ia64.efi grub-x86.efi menu.c32 README yaboot
(6)修改Cobbler的默認兩個的密碼
1> 修改所安裝系統的默認root密碼:
ROOTPWD=$(openssl -1 -salt `openssl rand -hex 4` 'Root_Password') vim /etc/cobbler/settings 【default_password_crypted: $ROOTPWD】
2>修改Cobbler_Web登錄的用戶名和密碼:
vim /etc/cobbler/users.digest 【格式: 用戶名:Cobbler:密碼 //Cobbler的含義不明, 用戶名和密碼默認為cobbler,可修改. admin:Cobbler:密碼部分必須用htdigest修改 】 修改admin的密碼: htdigest /etc/cobbler/users.digest "Cobbler" admin
注:
要登錄Web管理.需要注意httpd服務必須啟動.
且cobbler出現"error: [Errno 111] Connection refused",httpd沒有啟動的原因也比較大.
Cobbler的http源: http://IP/cobbler
登錄CobblerWeb界面: http:// IP /cobbler_web
另注:
默認 Cobbler的Web登錄認證方式在modules.conf中定義為: authn_configfile, 即采用user.digest中定義的
用戶名和密碼來認證,即cobbler自身提供的認證方式. 若需修改為使用系統用戶認證,即PAM方式。
則需修改:
1. sed -i '/\[authentication\]/{N;s,\(module\).*,\1=authn_pam,}' /etc/cobbler/modules.conf 2. echo 'Test_User_PWD' | passwd --stdin user1 3. sed -i '/^\(admin\).*/s,,\1="user1",' /etc/cobbler/users.conf //注意:PAM使用的用戶配置文件為:users.conf
(7)啟動服務:
/etc/init.d/xinetd restart /etc/init.d/httpd restart /etc/init.d/cobbler restart cobbler sync cobbler check
注:
執行cobbler sync后,需要注意以下信息:
….. 省略
rendering DHCP files
rendering TFTPD files
generating /etc/xinetd.d/tftp
processing boot_files for distro: Redhat-6.4-x86_64
cleaning link caches
rendering Rsync files
running post-sync triggers
running python triggers from /var/lib/cobbler/triggers/sync/post/*
running python trigger cobbler.modules.sync_post_restart_services
running: service dnsmasq restart
received on stdout:
Starting dnsmasq: [ OK ] ——–》若使用的dhcpd,則這里將啟動dhcpd.
(8)導入Redhat ISO鏡像:
mount /dev/cdrom /mnt/cdrom cobbler import --name=RedHat-6.4-x86_64 --path=/mnt/cdrom
查看導入結果:
cobbler report <==> cobbler distro report && cobbler profile report cobbler profile edit --name=Redhat-6.4-x86_64 \ --distro=Redhat-6.4-x86_64 \ --kickstart=/var/lib/cobbler/kickstarts/RedHat-6.4-x86_64.ks //修改使用指定的ks文件。
注:手工導入ISO鏡像的方法:
1. 先掛載光盤,如mount /dev/cdrom /mnt/cdrom
2. 掛載并同步
cd /var/www/cobbler/ks_mirror mkdir Ubuntu12.04-x86_64 rsync -a /mnt/cdrom/* Ubuntu12.04-x86_64/
3. 創建連接
ln -s /var/www/cobbler/ks_mirror/Ubuntu12.04-x86_64 /var/www/cobbler/links/
4. 將其添加到Cobbler中.
cobbler distro add \ --name=Ubuntu12.04-x86_64 \ --kernel=/var/www/cobbler/ks_mirror/Ubuntu12.04-x86_64/install/netboot/ubuntu-installer/amd64/linux \ --initrd=/var/www/cobbler/ks_mirror/Ubuntu12.04-x86_64/install/netboot/ubuntu-installer/amd64/initrd.gz
5. 指定其使用的preseed自動應答文件:【注: Ubuntu也可使用RHEL類似的ks文件.】
cobbler profile add --name=Ubuntu12.04-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Ubuntu12.04-x86_64.seed //附件1有詳情.
6. 執行同步:
cobbler sync cobbler check cobbler report
(9)非必須的配置
1. 給RHEL的ks文件中加入默認需要安裝的RPM包列表
》先在/var/lib/cobbler/snippets目錄中創建一個文件,名字任意.
vim /var/lib/cobbler/snippets/package_select 【@組包名 單個RPM包名 】
》修改 RHEL的ks文件:
vim /var/lib/cobbler/kickstarts/Redhat6.4_x86_64.ks 【 %packages $SNIPPET('package_select') %end 】
2. Server: 此配置是為專門定制一個服務器配置,給特定的服務器安裝系統使用。
》先在Cobbler 服務端添加以下信息:
cobbler system add --name=Test_Server1 --profile=Redhat6.4_x86_64 \ --hostname=tsrv1.test.com \ --interface=eth0 \ --static=1 \ --netboot-enabled=true \ --ip-address=1.1.1.1 \ --subnet=255.255.255.0 \ --gateway=1.1.1.2 \ --name-server='8.8.8.8' cobbler sync
》到需要安裝OS的服務器上執行:
1. 保證安裝了koan(kickstart-over-a-network) .
RHEL: 需要Centos官方源 和 Epel源(前文中提到的兩個)
Ubuntu:可使用 163 和 sohu的源.
2. 執行以下命令進行服務器系統的重新安裝:
》執行下面語句,將修改grub.conf從網絡啟動
koan –server=Cobbler_SRV_IP –port=80 –replace-self –system=Test_Server1
另注: 查看命令
koan --server=Cobbler_SRV_IP --port=80 --list=profile //查看有哪些配置可用. koan --server=Cobbler_SRV_IP --port=80 --list=server //查看有哪些server配置可用. koan --server=Cobbler_SRV_IP --port=80 --dispaly --profile=Redhat6.4_x86_64 //查看詳細配置.
附件1:Ubuntu和Debian的Preseed自動應答文件示例:
【注:seed自動應答文件與ks文件類似,ubuntu支持ks也支持seed,用其一即可.】
# 語言設置 d-i debconf/language string en d-i debian-installer/locale string en_US.UTF-8 d-i debian-installer/language string en d-i debian-installer/country string US d-i localechooser/supported-locales en_US.UTF-8, zh_CN.UTF-8 # 鍵盤設置 d-i console-setup/ask_detect boolean false d-i keyboard-configuration/modelcode string pc105 d-i keyboard-configuration/layoutcode string us d-i keyboard-configuration/variantcode string d-i console-keymaps-at/keymaps select us # 網絡設置 d-i netcfg/enable boolean true d-i netcfg/choose_interface select auto d-i netcfg/disable_dhcp boolean false d-i netcfg/dhcp_timeout string 5 d-i netcfg/disable_autoconfig boolean false d-i netcfg/dhcp_failed note # d-i netcfg/dhcp_options select Configure network manually # d-i netcfg/dhcp_hostname string none # d-i netcfg/get_nameservers string 8.8.8.8 # d-i netcfg/get_ipaddress string 192.168.1.10 # d-i netcfg/get_netmask string 255.255.255.0 # d-i netcfg/get_gateway string 192.168.1.1 # d-i netcfg/confirm_static boolean true d-i netcfg/get_hostname string $myhostname//設置主機名 d-i netcfg/get_domain string none//設置域名 # 安裝源設置 d-i mirror/country string manual d-i mirror/ http/hostname string $ http_server d-i mirror/ http/directory string $install_source_directory d-i mirror/ http/proxy string # 在Ubuntu12.10以上版本自動安裝時,若ISO中提供的是squashfs文件系統格式,會采用此方式安裝。 d-i live-installer/net-image string http://$http_server/cobbler/links/$distro_name/install/filesystem.squashfs d-i hw-detect/load_firmware boolean true//發現新硬件時,不提示自動載入. # NTP/Time Setup d-i time/zone string Asia/Shanghai d-i clock-setup/utc boolean true #d-i clock-setup/ntp boolean true #d-i clock-setup/ntp-server string ntp.ubuntu.com # 分區設置 d-i partman-auto/disk string /dev/sda//無論系統中有幾塊盤,僅使用/dev/sda。 d-i partman-auto/method string regular//采用普通方式分區,即不使用LVM、軟RAID d-i partman-lvm/device_remove_lvm boolean true//清除磁盤中找到的LVM分區 d-i partman-md/device_remove_md boolean true//清除磁盤中找到的RAID分區 #這是可選的預定義分區方式: 【注:下面這些我沒測試】 # - atomic: all files in one partition # - home: separate /home partition # - multi: separate /home, /usr, /var, and /tmp partitions d-i partman-auto/expert_recipe string \//使用專家模式分區 boot-root :: \//這是專家模式采用的預定義分區方式; 此分區方式也可分多個分區. 100 50 100 ext3 \//下面每個分區配置都是在一行的,它們以"."做為分隔。 $primary{ } $bootable{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext3 } \ mountpoint{ /boot } \ . \ 2048 512 2048 linux-swap \//每組分區中三個數字的含義為:分區最小多少MB, 優先級(越小越優先), 分區最大多少MB method{ swap } format{ } \ . \ 10240 1000 10240 ext3 \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext3 } \ mountpoint{ / } \ . d-i partman/confirm_write_new_label boolean true//不提示寫入分區信息到磁盤. d-i partman-partitioning/confirm_write_new_label boolean true//再次確認將分區信息寫入磁盤 d-i partman/confirm_nooverwrite boolean true//不提示覆蓋磁盤中已有數據 d-i partman/confirm boolean true//確認 d-i partman/choose_partition select Finish partitioning and write changes to disk//完成確認 # 用戶賬號 d-i passwd/root-login boolean true d-i passwd/root-password-crypted password $default_password_crypted # 跳過創建普通用戶 d-i passwd/make-user boolean false # APT配置 # You can choose to install restricted and universe software, or to install # software from the backports repository. # d-i apt-setup/restricted boolean true # d-i apt-setup/universe boolean true # d-i apt-setup/backports boolean true # # Uncomment this if you don't want to use a network mirror. # d-i apt-setup/use_mirror boolean false # # Select which update services to use; define the mirrors to be used. # Values shown below are the normal defaults. # d-i apt-setup/services-select multiselect security # d-i apt-setup/security_host string security.ubuntu.com # d-i apt-setup/security_path string /ubuntu # $SNIPPET('preseed_apt_repo_config') # # Enable deb-src lines # d-i apt-setup/local0/source boolean true # # URL to the public key of the local repository; you must provide a key or # apt will complain about the unauthenticated repository and so the # sources.list line will be left commented out # d-i apt-setup/local0/key string http://local.server/key # 定制安裝包 tasksel tasksel/first multiselect none//安裝指定的軟件集 d-i pkgsel/include string vim ntp ssh wget openssh-server build-essential//安裝指定的軟件包,build-essential:此為編譯工具包(包含C++等編譯器) d-i pkgsel/upgrade select full-upgrade d-i pkgsel/install-language-support boolean true d-i pkgsel/language-packs multiselect en, zh d-i pkgsel/update-policy select none # popularity-contest popularity-contest/participate boolean false d-i pkgsel/updatedb boolean true # 安裝Grub d-i grub-installer/skip boolean false d-i lilo-installer/skip boolean false d-i grub-installer/only_debian boolean true d-i grub-installer/with_other_os boolean true d-i debian-installer/add-kernel-opts string $kernel_options_post//給Kernal添加啟動參數 # 完成設置 d-i finish-install/reboot_in_progress note//安裝完成后,提示重啟 d-i finish-install/keep-consoles boolean true # This first command is run as early as possible, just after preseeding is read. # d-i preseed/early_command string [command] d-i preseed/early_command string wget -O- \ http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_early_default | \ /bin/sh -s # This command is run immediately before the partitioner starts. It may be # useful to apply dynamic partitioner preseeding that depends on the state # of the disks (which may not be visible when preseed/early_command runs). # d-i partman/early_command \ # string debconf-set partman-auto/disk "\$(list-devices disk | head -n1)" # This command is run just before the install finishes, but when there is # still a usable /target directory. You can chroot to /target and use it # directly, or use the apt-install and in-target commands to easily install # packages and run commands in the target system. # d-i preseed/late_command string [command] d-i preseed/late_command string wget -O- \ http://$http_server/cblr/svc/op/script/$what/$name/?script=preseed_late_default | \ chroot /target /bin/sh -s
附件2: 部署遇到的錯誤.
錯誤1: xmlrpclib.Fault: <Fault 1: "<class 'cobbler.cexceptions.CX'>:'login failed'">
嘗試重啟cobblerd
錯誤2: error: [Errno 111] Connection refused
檢查: cobblerd 是否啟動了25151,netstat -tnlp |grep '25151'
httpd 是否啟動了
原創文章,作者:Wn1m,如若轉載,請注明出處:http://www.www58058.com/12822
看出來的認真,但文章少了層次感,