centos6自动化装机:cobbler (tftp+http+pxe集成版)

需要准备centos的安装镜像, 下面要挂载到自定义的http服务器上

[root@cent6 ~]# ls CentOS-6.10-x86_64-minimal.iso -l
-rw-r--r--. 1 root root 425721856 7月  30 22:12 CentOS-6.10-x86_64-minimal.iso

设置dhcp服务端,使用host-only网卡

网卡 网卡类型 BOOTPROTO IPADDR
eth0 网络地址转化(NAT) dhcp 10.0.2.15
eth1 host-only staic 192.168.56.5

1, 安装软件

# 1, 安装软件包
yum -y install epel-release
yum -y install cobbler dhcp httpd xinetd tftp-server syslinux pykickstart xinetd rsync cobbler-web --skip-broken

# 2, 启动服务
service firewalld stop
systemctl disable firewalld
setenforce 0
sed -i s/SELINUX=enforcing/SELINUX=disabled/ /etc/selinux/config 
service httpd start
service cobblerd start

2,修改配置

# 1,根据提示,完成配置
[root@cent6 ~]#  cobbler check
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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment:
    https://github.com/cobbler/cobbler/wiki/Selinux
4 : change 'disable' to 'no' in /etc/xinetd.d/tftp
5 : 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.
6 : change 'disable' to 'no' in /etc/xinetd.d/rsync
7 : debmirror package is not installed, it will be required to manage debian deployments and repositories
8 : 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
9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them

# 2, 完成具体配置修改
sed -i 's/^server: 127.0.0.1/server: 192.168.56.5/' /etc/cobbler/settings  
sed -i 's/^next_server: 127.0.0.1/next_server: 192.168.56.5/' /etc/cobbler/settings # TFTP Server IP地址

sed -i   "s/disable = yes/disable = no/" /etc/xinetd.d/rsync
sed  -i  "s/disable*[[:space:]]*=[[:space:]]yes/disable= no/" /etc/xinetd.d/tftp 
cobbler get-loaders

[root@cent6 ~] cat  /etc/cobbler/dhcp.template 
.....
subnet 192.168.56.0 netmask 255.255.255.0 {
     option routers             192.168.56.1;
     option domain-name-servers 114.114.114.114;
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        192.168.56.100 192.168.56.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                $next_server;
 .....

# 3,重启服务
for x in cobblerd dhcpd httpd xinetd 
do 
  service $x restart;
  chkconfig $x on;
done

# 同步配置
cobbler sync

# 4,倒入要安装的iso镜像
mkdir /mnt/cent6.10
mount CentOS-6.10-x86_64-minimal.iso /mnt/cent6.10/ -o loop
cobbler import --path /mnt/cent6.10/ --arch=x86_64 --name=cent6.10

3,自定义kickstart文件

创建自定义的kickstart文件

cat > /var/lib/cobbler/kickstarts/my.ks <

修改当前的镜像使用自定义的kickstart配置

#1, 查看默认的kickstart配置
[root@cent6 ~]# cobbler profile report
Name                           : cent7-x86_64
TFTP Boot Files                : {}
Comment                        : 
DHCP Tag                       : default
Distribution                   : cent7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks

#2, 修改默热的kickstart文件
cobbler profile edit --name cent6.10-x86_64 --kickstart=/var/lib/cobbler/kickstarts/my.ks

#3, 更新配置
service cobblerd restart
cobbler sync

4,启动客户端裸机

配置网络启动 --->
配置:第一块网卡(host-only模式), 第二块网卡: 网络地址转换(NAT模式)---> 
关闭该host-only网卡自带的dhcp服务--->开机

你可能感兴趣的:(linux系统)