Red Hat发布的网络安装服务器套件Cobbler(在2008年左右发布),它已将 Linux网络安装的技术门槛,从大专以上文化水平,成功下降到初中如下,连补鞋匠都能学会。对于咱们这些在装机领域浸淫多年,经验丰富,老骥伏枥,志在千里的民工兄弟们来讲,不啻为一个晴天霹雳,杯具的是之前我居然不会,话很少说,直接开始试验... html
实验环境:cobbler server 10.1.6.234 (DELL 610 ubuntu12.04) linux
待安装服务器 *2 (DELL 410) git
关于网络环境,都在同一个交换机下,同一vlan中,由于要用IPMI远程安装,网络环境仍是要设置好的。 github
实验结果:ubuntu12.0四、centos6.3安装成功,debian六、ubuntu12.10安装失败,下面开始部署cobbler环境。 web
1 安装cobbler shell
#安装cobbler apt-get install cobbler #在安装debian系列时会用到的一个软件包 apt-get install debmirror #安装cobbler的web管理界面 apt-get install cobbler-web使用到的相关环境包tftpd-hpa、dhcp3-server会自动安装。web界面能够经过http://10.1.6.234/cobbler_web查看,不过目前你还没法查看,由于相关用户尚未设置,为cobbler用户重置密码:
#回车后会让你重置密码 htdigest /etc/cobbler/users.digest "Cobbler" cobbler
2 配置基本安装环境 ubuntu
A 关于tftpd-hpa的配置:/etc/default/tftpd-hpa(默认无需修改,你能够根据本身的环境定制) centos
# /etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/var/lib/tftpboot" TFTP_ADDRESS="0.0.0.0:69" TFTP_OPTIONS="--secure"
经过/etc/init.d/tftpd-hpa 脚本管理 服务器
B 关于dhcp的配置:/etc/dhcp/dhcpd.conf(须要根据你的环境进行设置,我所在的是10.1.6.x网段),不过为了使用脚本管理dhcp的运行,咱们先设置/etc/default/isc-dhcp-server 网络
/etc/default/isc-dhcp-server:由于个人cobbler server只启动了eth0网卡,因此dhcp监听在eth0接口上
# Defaults for dhcp initscript # sourced by /etc/init.d/dhcp # installed at /etc/default/isc-dhcp-server by the maintainer scripts # This is a POSIX shell fragment # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? INTERFACES="eth0"/etc/dhcp/dhcpd.conf:
ddns-update-style none; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 10.1.6.0 netmask 255.255.255.0 { range 10.1.6.1 10.1.6.245; option routers 10.1.6.254; option broadcast-address 10.1.6.255; default-lease-time 600; max-lease-time 7200; next-server 10.1.6.234; filename "pxelinux.0"; }
通过/etc/init.d/isc-dhcp-server 脚本管理
C 关于cobbler的配置,cobbler安装完成后,仍是有不少目录要使用的,主要用到的解释以下:
/var/lib/cobbler 存储导入的镜像的配置信息,kickstarts目录存放kickstarts脚本,snippets目录存放在kickstat配置文件中能够执行的脚本,config目录提供配置信息,还有其余目录基本上无需配置。
/var/www/cobbler 是导入发行版的操做系统的数据目录,ks_mirror里面是导入的发行版系统,images里面是全部发行版的kernel和initrd,用于远程网络启动。
/var/log/cobbler 是日志目录
/etc/cobbler 是cobbler的配置文件目录,settings是主配置文件,里面还有一些相关配置模版,users.conf是用户,users.digest是用户及密码
别看这么多目录,其实安装cobbler完成后,基本配置也是不须要咱们修改的,settings配置文件是主配置文件,有不少参数能够配置,详细的选项信息能够查看:http://cobbler.github.com/manuals/2.2.3/4/2_-_Cobbler_Settings.html
D 关于IPMI的配置,由于要远程安装,在DELL服务器中,IPMI这个工具仍是很给力的,三台机器都须要设置IPMI,由于cobbler server有操做系统,因此能够在系统中经过ipmitool命令进行设置,而两台客户机由于尚未操做系统,因此要提早设置好ipmi,两台客户机以下设置:
设置IPMI地址及用户密码,开机按照提示按crtl+E进入IPMI配置界面
选择LAN Parameters,设置该客户机的IPMI地址是172.16.6.200
而后选择LAN User Configuration,设置root密码,而后保存退出。
为了在远程能抓到客户端的启动过程,还须要设置BIOS,开机按F2进入BIOS进行设置
选择Integrated Devices,由于只有一块网卡,因此设置从NIC1 启动PXE
选择Serial Communication,设置串口,而后保存退出。
3 初始化cobbler安装环境
前面说了我实验了四个发行版,成功两个,失败两个,为了快速安装都是导入相关iso做为安装源的,因此第一步是准备相关iso发行版,个人以下:
/opt ├── CentOS-6.3-x86_64-bin-DVD1.iso ├── debian-6.0.2.1-amd64-CD-1.iso ├── ubuntu-12.04-server-amd64.iso └── ubuntu-12.10-server-amd64.iso以ubuntu12.04为例进行讲解,由于用这个iso能够成功安装客户机
A 导入iso镜像
mount -o loop ubuntu-12.04-server-amd64.iso /mnt cobbler import --path=/mnt --name=ubuntu12.04B 查看导入的结果:cobbler list,也可使用cobbler profile/distro list查看
cobbler list ###显示结果以下 distros: ubuntu12.04-x86_64 profiles: ubuntu12.04-x86_64 systems: repos: images: mgmtclasses: packages: files:很惋惜ubuntu12.04默认导入的 profile/distro配置有问题,因此咱们必须修改。
修改distro
cobbler distro edit --name=ubuntu12.04-x86_64 \ --kernel=/var/www/cobbler/ks_mirror/ubuntu12.04/install/netboot/ubuntu-installer/amd64/linux \ --initrd=/var/www/cobbler/ks_mirror/ubuntu12.04/install/netboot/ubuntu-installer/amd64/initrd.gz --arch=x86_64 \ --breed=ubuntu --os-version=precise建立/var/lib/cobbler/kickstarts/ubuntu12.04.preseed,该文件为ubuntu12.04的preseed文件。
touch /var/lib/cobbler/kickstarts/ubuntu12.04.preseed #######文件内容以下######## ### Localization d-i debian-installer/locale string en_US d-i debian-installer/language string en d-i debian-installer/country string US d-i console-setup/ask_detect boolean false d-i keyboard-configuration/layoutcode string us d-i localechooser/supported-locales zh_CN.UTF-8 ### Network configuration d-i netcfg/enable boolean false d-i netcfg/choose_interface select auto d-i netcfg/disable_autoconfig boolean true d-i netcfg/dhcp_failed note d-i netcfg/dhcp_options select Do not configure the network at this time ### Mirror settings d-i mirror/country string manual d-i mirror/http/hostname string 10.1.6.234 d-i mirror/http/directory string /ubuntu12.04 d-i mirror/http/proxy string d-i mirror/udeb/components multiselect main, restricted #d-i mirror/http/mirror select mirrors.163.com #d-i mirror/suite string quantal ### Clock and time zone setup d-i clock-setup/utc boolean true d-i clock-setup/ntp boolean true d-i clock-setup/ntp-server string 10.1.1.2 d-i time/zone string Asia/Shanghai ### Partitioning d-i partman-auto/disk string /dev/sda d-i partman-auto/method string regular d-i partman-lvm/device_remove_lvm boolean true d-i partman-md/device_remove_md boolean true d-i partman-lvm/confirm boolean true #d-i partman-auto/choose_recipe select atomic d-i partman-auto/expert_recipe string \ boot-root :: \ 50000 50000 50000 ext4 \ $primary{ } \ $bootable{ } \ method{ format } \ format{ } \ use_filesystem{ } \ filesystem{ ext4 } \ mountpoint{ / } \ . \ 8000 8000 8000 linux-swap \ method{ swap } \ format{ } \ . \ 10000 1000 1000000 ext4 \ method{ format } \ format{ } \ use_filesystem{ } \ filesystem{ ext4 } \ mountpoint{ /opt } \ . \ d-i partman/default_filesystem string ext4 d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true d-i partman/mount_style select uuid ### Base system installation #d-i base-installer/install-recommends boolean true #d-i base-installer/kernel/image string linux-generic d-i base-installer/kernel/image string linux-server ### Account setup d-i passwd/root-login boolean true d-i passwd/root-password password 123456 d-i passwd/root-password-again password 123456 d-i user-setup/allow-password-weak boolean true d-i user-setup/encrypt-home boolean false d-i passwd/make-user boolean false ### Package selection tasksel tasksel/first multiselect standard d-i pkgsel/include string openssh-server d-i pkgsel/upgrade select none d-i pkgsel/language-packs multiselect de, en, zh d-i pkgsel/update-policy select none d-i pkgsel/updatedb boolean true ### Boot loader installation d-i grub-installer/only_debian boolean true d-i grub-installer/with_other_os boolean true ### Finishing up the installation d-i finish-install/reboot_in_progress note
preseed解释可见:https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt
修改profile
cobbler profile edit --name=ubuntu12.04-x86_64 \ --kickstart=/var/lib/cobbler/kickstarts/ubuntu12.04.preseed
cobbler命令有不少参数可使用:
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> [options|--help]
经常使用的有:distro相似于发行版,profile相似于该发行版的一些配置,system对安装的机器作具体配置,是根据mac地址生效的。
cobbler check 检查配置是否正确
cobbler list 列出全部的cobbler元素
cobbler distro/profile list 单独列出该信息
cobbler sync 同步信息 在修改完cobbler配置后,都须要同步信息
cobbler report 显示详细的元素信息
C 设置本地源,在ubuntu12.04.preseed配置文件中有用
cd /var/www ln -s /var/www/cobbler/ks_mirror/ubuntu12.04 ubuntu12.04
D 修改pxelinux.cfg配置,由于使用dell的机器,若是启动时没有设置速率,在远程安装的时候,抓不到屏幕,对于410以上的机器速率是115200,2950之类是57600
/var/lib/tftpboot/pxelinux.cfg/default,在append行末添加console=ttyS1,115200
DEFAULT menu PROMPT 0 MENU TITLE Cobbler | http://fedorahosted.org/cobbler TIMEOUT 200 TOTALTIMEOUT 6000 ONTIMEOUT local LABEL local MENU LABEL (local) MENU DEFAULT LOCALBOOT -1 LABEL ubuntu12.04-x86_64 kernel /images/ubuntu12.04-x86_64/linux MENU LABEL ubuntu12.04-x86_64 append initrd=/images/ubuntu12.04-x86_64/initrd.gz locale= locale=en_US priority=critical text auto url=http://10.1.6.234/cblr/svc/op/ks/profile/ubuntu12.04-x86_64 hostname=ubuntu12.04-x86-64 domain=local.lan suite=precise console=ttyS1,115200 ipappend 2 MENU end
E 在安装过程当中会弹出相似的xxx/binary-amd64/Packages was corrupt,这是由于在相关目录下没有Packages这个文件,只要进入该目录建立Packages文件就能够
F 开始安装远程客户机,在cobbler server的eth0上绑定IPMI的网段地址。
ifconfig eth0:1 172.16.6.252 netmask 255.255.255.0 ####结果以下 eth0:1 Link encap:Ethernet HWaddr 18:03:73:f0:a7:03 inet addr:172.16.6.252 Bcast:172.16.6.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:36 Memory:d6000000-d6012800 #####ping到客户端ipmi地址,发现是通的而后开两个窗口分别执行以下IPMI命令
##1窗口,经过ipmi链接到客户机 ipmitool -I lanplus -H 172.16.6.200 -U root -P 123456 sol activate ##2窗口,设置需哦那个pxe引导 ipmitool -I lanplus -H 172.16.6.200 -U root -P 123456 chassis bootdev pxe ##2窗口,设置重启客户机 ipmitool -I lanplus -H 172.16.6.200 -U root -P 123456 chassis power resetG 享受过程吧...
如下是个人配置文件设置的小问题,须要手动敲两下回车:
这个我配置文件(preseed)设置的不配置网卡,不知道为何出现这个,后面再研究一下配置文件
这一步不须要设置,不然安装过程会比较慢...
两个回车后,就能够坐等系统重启了...
H Centos6.3安装
步骤的设置和ubuntu12.04的安装过程同样,不过不须要修改distro/profile,直接import便可。
下面是centos6.3.ks的配置文件
#platform=x86, AMD64, or Intel EM64T # System authorization information auth --useshadow --enablemd5 # System bootloader configuration bootloader --location=mbr --driveorder=sda # Partition clearing information clearpart --all --initlabel # Use text mode install text # Firewall configuration firewall --disable # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard us # System language lang en_US # Use network installation #url --url=http://10.1.6.234/cblr/links/CentOS6.3-x86_64 url --url=$tree # If any cobbler repo definitions were referenced in the kickstart profile, include them here. #repo --name=source-1 --baseurl=http://10.1.6.234/cobbler/ks_mirror/CentOS6.3 $yum_repo_stanza # Network information #network --bootproto=dhcp --device=em1 --onboot=on $SNIPPET('network_config') # Reboot after installation reboot #Root password rootpw 123456 # 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 # make partion partition / --fstype="ext4" --asprimary --size=50000 part swap --size=8192 %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %packages $SNIPPET('func_install_if_enabled') $SNIPPET('puppet_install_if_enabled') %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('puppet_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此次没有出现ubuntu12.04须要手动干预的状况,IPMI从PXE启动后,直接坐等客户机系统安装完成后重启...
相关设置preseed/kickstarts资料:
http://www.debian.org/releases/stable/example-preseed.txt
https://help.ubuntu.com/12.10/installation-guide/example-preseed.txt
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/s1-kickstart2-options.html
收集已经安装完成系统的preseed信息:
获取你的Kickstarts配置文件,在Red Hat系列中system-config-kickstart能够帮助你生成一个kickstart文件,或者查看/root/anaconda-ks.cfg,关于debian系统则能够apt-get install debconf-utils而后debconf-get-selections --installer > preseed.cfg