最近机房要上线几个机柜的机器,必须实现自动化装机。
一、安装
系统环境是centos6.4,采用yum安装:
rpm -Uvh http://mirrors.hustunique.com/epel/6/x86_64/epel-release-6-8.noarch.rpm yum -y install cobbler cobbler-web httpd rsync tftp-server xinetd dhcp python-ctypes debmirror pykickstart
二、配置
1、关闭防火墙和SELinux 后重启系统:
/etc/init.d/iptables stop #关闭防火墙 chkconfig iptables off sed -i ‘/SELINUX=/d‘ /etc/selinux/config && echo "SELINUX=disabled">> /etc/selinux/config #关闭SELINUX
2、修改cobbler配置文件:
‘next_server: 127.0.0.1‘ 替换成 ‘next_server:172.28.26.188‘ #DHCP服务地址 ‘server: 127.0.0.1‘ 替换成 ‘server: 172.28.26.188‘ #cobbler服务地址 ‘manage_dhcp: 0‘ 替换成 ‘manage_dhcp: 1‘ #cobbler管理dhcp ‘manage_rsync: 0‘ 替换成 ‘manage_rsync: 1‘ #cobbler管理rsync功能 default_password_crypted: "$1$cobber$yV9XfOuaaiVDvImopK7o.1" sed -i ‘s/next_server: 127.0.0.1/next_server: 172.28.26.188/g‘ /etc/cobbler/settings sed -i ‘s/server: 127.0.0.1/server: 172.28.26.188/g‘ /etc/cobbler/settings sed -i ‘s/manage_dhcp: 0/manage_dhcp: 1/g‘ /etc/cobbler/settings sed -i ‘s/manage_rsync: 0/manage_rsync: 1/g‘ /etc/cobbler/settings sed -i ‘s/http_port: 80/http_port: 9080/g‘ /etc/cobbler/settings openssl passwd -1 -salt "cobber" "123456 #把生成的密码填到/etc/cobbler/settings配置里default_password_crypted:生成的新密码,这个密码就是装完系统后的root密码。
3、修改tftp服务和rsync服务配置 :
sed -i ‘/disable/c disable = no‘ /etc/xinetd.d/tftp #设置 ‘disable‘ 为 ‘no‘ sed -i -e ‘s/= yes/= no/g‘ /etc/xinetd.d/rsync #设置 ‘disable‘ 为 ‘no‘
4、修改dhcp模板 :
subnet 192.168.66.0 netmask 255.255.255.0 { option routers 192.168.66.87; option domain-name-servers 202.106.0.20; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.66.100 192.168.66.102; default-lease-time 21600; max-lease-time 43200; next-server $next_server; class "pxeclients" { .....
5、修改cobbler-web配置
sed -i ‘s/module = authn_denyall/module = authn_configfile/g‘ /etc/cobbler/modules.conf #修改认证 htdigest /etc/cobbler/users.digest "Cobbler" cobbler #修改cobbler WEB页面管理密码
6、启动相关的服务
/etc/init.d/httpd start /etc/init.d/xinetd start /etc/init.d/dhcpd start /etc/init.d/cobblerd start chkconfig --level 35 httpd on chkconfig --level 35 xinetd on chkconfig --level 35 dhcpd on chkconfig --level 35 cobblerd on
7、效验cobbler安装条件:
service cobblerd restart cobbler get-loaders #修复cobbler check时出现的错误信息 cobbler check
三、导入镜配置:
1:使用光盘镜像 挂载ISO镜像到/mnt目录 mount -o loop /data/CentOS_6.4_vm.iso /mnt/ 导入ISO,并设置为“x86_64”,并将其命名为Centos6.4 cobbler import --path=/mnt/ --name=CentOS_6.4 --arch=x86_64 2:挂载linux光盘: mount /dev/cdrom /media/ cobbler import --path=/media/CentOS_6.4_Final --name=Centos6.4 查看导入结果 cobbler distro list 完成后同步所有配置 cobbler sync
这时,我们就可以访问cobbler的web界面了:
四、需要装系统的机器从网卡启动:
ks.cfg:
#set $swap= $getVar(‘$swap‘, ‘12000‘) autostep --autoscreenshot install url --url=$tree # If any cobbler repo definitions were referenced in the kickstart profile, include them here. $yum_repo_stanza text skipx lang en_US.UTF-8 keyboard us network --onboot yes --bootproto dhcp --noipv6 --nodns rootpw --iscrypted \$6\$Qz7FvhTWfC2yTdb1\$qNF1o.fpE44l/F1ROzJ.bXRKeB4OVQ.maYCY3tMZKDS7tDLrHthIAREXZFvW1G08tOqptkLMxfvyW4wA.vPOz1 firewall --disabled firstboot --disabled authconfig --enableshadow --passalgo=sha512 selinux --disabled #timezone --isUtc Asia/Shanghai timezone --utc Asia/Shanghai # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work logging --level=info #bootloader --append="nohz=off" --location=mbr bootloader --location=mbr --driveorder=sda --append="biosdevname=0 nohz=off thash_entries=1048576 rhash_entries=1048576 selinux=0" zerombr yes # clearpart --all --initlabel --drives=sda clearpart --all --initlabel # ignoredisk --only-use=sda part / --fstype=ext4 --asprimary --size=50000 --maxsize=50000 --label=/ part swap --asprimary --size=$swap --maxsize=$swap --label=swap part /data --fstype=xfs --grow --asprimary --size=12000 --label=/data %pre $SNIPPET(‘pre_install_network_config‘) # Add Pre-Installation Script here date %end %packages --excludedocs --ignoremissing @base @core @development @server-policy ftp nc telnet cmake compat-gcc-34 compat-gcc-34-c++ sgpio libXtst yum-plugin-priorities koan openssl tengine -lvm2 -acpid -biosdevname -hunspell-en -abrt-cli -man-pages-overrides -blktrace -words -abrt-addon-kerneloops -abrt-addon-ccpp -bridge-utils -nano -mtr -hunspell -abrt-addon-python -man-pages -byacc -indent -diffstat -doxygen -intltool -git -ctags -cscope -iptables -system-config-firewall-base -iptables-ipv6 -system-config-firewall-tui -subversion %end $SNIPPET(‘services_disable_enable‘) %post $SNIPPET(‘post_install_network_config‘) $SNIPPET(‘env_init‘) $SNIPPET(‘kis_cobbler_api‘) $SNIPPET(‘cactirelease‘) $SNIPPET(‘kisyum_install‘) #/usr/sbin/eject -rv /dev/sr* # eject P cdrom echo ‘v1.3‘ > ~root/VERSION %end # finish reboot
原文地址:http://linuxadmin.blog.51cto.com/2683824/1626777