CentOS7 使用cobbler批量安装
cobbler是kickstart的升级版,优点是比较容易配置,还自带web界面比较易于管理,集成并接管了pxe、dhcp、Kickstart、tftp和http等服务,配置相对比较简单
服务端192.168.10.11 DHCP范围192.168.10.100-192.168.10.110
安装组件
yum install cobbler cobbler-web dhcp httpd xinetd tftp-server syslinux pykickstart rsync -y
配置httpd
rm -rf /etc/httpd/conf.d/welcome.conf sed -i 's#\#ServerName www.example.com:80#ServerName 127.0.0.1:80#g' /etc/httpd/conf/httpd.conf systemctl enable httpd systemctl start httpd
配置cobbler
systemctl enable cobblerd systemctl start cobblerd cobbler check #提示8个错误并逐一解决 #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. #将server地址改为正确本机ip sed -i 's/^server: 127.0.0.1/server: 192.168.10.11/' /etc/cobbler/settings #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. #指定tftp服务器地址 sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.10.11/' /etc/cobbler/settings #3 : change 'disable' to 'no' in /etc/xinetd.d/tftp #开启tftp sed -i '/disable\>/s/\<yes\>/no/' /etc/xinetd.d/tftp sed -i '/manage_tftpd:/s/0/1/' /etc/cobbler/settings systemctl enable tftp systemctl restart tftp.service #4 : 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. #下载缺少的组件 cobbler get-loaders #5 : enable and start rsyncd.service with systemctl #开启rsyncd sed -i 's/manage_rsync: 0/manage_rsync: 1/g' /etc/cobbler/settings systemctl enable rsyncd systemctl start rsyncd #6 : debmirror package is not installed, it will be required to manage debian deployments and repositories #缺少debian组件 yum install debmirror -y sed -i 's/@dists=\"sid\";/#@dists=\"sid\";/g' /etc/debmirror.conf sed -i 's/@arches=\"i386\";/#@arches=\"i386\";/g' /etc/debmirror.conf #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 #缺少创建的新系统初始密码 pass=`openssl passwd -1 -salt '12345678' '12345678' ` sed -i "101c default_password_crypted: \"$pass\"" /etc/cobbler/settings #8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them #缺少fence设备相关和电源管理组件 yum install fence-agents -y
其他配置
#使用cobblerd接管dhcp sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings #避免重复安装 sed -i 's/pxe_just_once: 0/pxe_just_once: 1/g' /etc/cobbler/settings #修改dhcp配置模板 sed -i '/^subnet/s/192.168.1.0/192.168.10.0/' /etc/cobbler/dhcp.template sed -i '/routers/s/192.168.1.5/192.168.10.2/' /etc/cobbler/dhcp.template sed -i '/domain-name-servers/s/192.168.1.1/192.168.10.2/' /etc/cobbler/dhcp.template sed -i '/dynamic-bootp/s/192.168.1.100 192.168.1.254/192.168.10.100 192.168.10.110/' /etc/cobbler/dhcp.template #再次检测 systemctl restart cobblerd.service cobbler check
同步配置
sed -n -e '/manage_tftpd:/p' -e '/manage_dhcp:/p' -e '/manage_rsync:/p' /etc/cobbler/settings systemctl restart cobblerd.service cobbler sync
挂载镜像
mount -o loop /dev/cdrom /media cobbler import --path=/media --name=CentOS-7.7.1908
指定ks
mv /root/anaconda-ks.cfg /var/lib/cobbler/kickstarts/centos7.ks cobbler profile edit --name=CentOS-7.7.1908-x86_64 --distro=CentOS-7.7.1908-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks #附上centos7.ks #version=RHEL7 # System authorization information url --url=$tree #url --url http://192.168.10.11/cobbler/ks_mirror/CentOS-7.7.1908/ # Run the Setup Agent on first boot firewall --disabled selinux --disabled reboot ignoredisk --only-use=sda # Keyboard keyboard us # System language lang en_US.UTF-8 # Network information network --onboot=yes --ipv6=no --bootproto=static --device=ens33 --gateway=192.168.10.2 --ip=192.168.10.15 --nameserver=8.8.8.8 --netmask=255.255.255.0 # Installation logging level logging --level=debug # Root password rootpw --iscrypted $1$mgFXptMu$u3fP3Gbq5b49HqIPYMvS71 # System timezone timezone Asia/Shanghai --isUtc # System bootloader configuration bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda autopart --type=lvm # Partition clearing information zerombr clearpart --all --initlabel #clearpart --none --initlabel %packages @^minimal @compat-libraries @core @debugging @development @system-admin-tools kexec-tools tree net-snmp nmap sysstat lrzsz dos2unix telnet iptraf ncurses-devel openssl-devel zlib-devel OpenIPMI-tools screen chrony wget net-tools ntp ntpdate %end
相关命令
cobbler list cobbler report cobbler profile report cobbler distro list cobbler distro report
网页管理
sed -i 's/authn_denyall/authn_configfile/g' /etc/cobbler/modules.conf htdigest /etc/cobbler/users.digest "Cobbler" cobbler #访问https://192.168.10.11/cobbler_web
本站所有文章均可随意转载,转载时请保留原文链接及作者。