一、简介
二、安装配置

  1. 将Yum源改为国内源并安装EPEL源

    1. 删除/etc/yum.repos.d/目录下的所有文件,

      1. rm -rf /etc/yum.repos.d/*
    2. 新建一个名为Centos-Base.repo的文件,文件内容如下 ```

      CentOS-Base.repo

      #

      The mirror system uses the connecting IP address of the client and the

      update status of each mirror to pick mirrors that are updated to and

      geographically close to the client. You should use this for CentOS updates

      unless you are manually picking other mirrors.

      #

      If the mirrorlist= does not work for you, as a fall back you can try the

      remarked out baseurl= line instead.

      # #

[base] name=CentOS-$releasever - Base baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

released updates

[updates] name=CentOS-$releasever - Updates baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

additional packages that may be useful

[extras] name=CentOS-$releasever - Extras baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

additional packages that extend functionality of existing packages

[centosplus] name=CentOS-$releasever - Plus baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  1. c. 清空并重新生成缓存

yum clean all yum makecache

  1. d. 安装epel
  2. yum -y install httpd dhcp tftp cobbler cobbler-web pykickstart xinetd
  3. systemctl start httpd<br />systemctl start cobblerd
  4. systemctl start cobblerd<br />systemctl stop firewalld<br />setenforce 0<br />vi /etc/sysconfig/selinux <br />cobbler check
  5. vi /etc/cobbler/settings<br />#修改278行和390行为本地的IP地址
  6. vi /etc/xinetd.d/tftp<br />disable = no
  7. cobbler get-loaders
  8. openssl passwd -1 -salt 'cobbler' 'cobbler'
  9. vi /etc/cobbler/settings<br />default_password_crypted: "$1$cobbler$M6SE55xZodWc9.vAKLJs6."<br />manage_dhcp: 1 #242行
  10. vi /etc/cobbler/dhcp.template

**

Cobbler managed dhcpd.conf file

#

generated from cobbler dhcp.conf template ($date)

Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes

in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be

overwritten.

#

**

ddns-update-style interim;

allow booting; allow bootp;

ignore client-updates; set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 192.168.152.0 netmask 255.255.255.0 { option routers 192.168.152.1; option domain-name-servers 192.168.152.1; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.152.101 192.168.152.250; default-lease-time 21600; max-lease-time 43200; next-server $next_server; class “pxeclients” { match if substring (option vendor-class-identifier, 0, 9) = “PXEClient”; if option pxe-system-type = 00:02 { filename “ia64/elilo.efi”; } else if option pxe-system-type = 00:06 { filename “grub/grub-x86.efi”; } else if option pxe-system-type = 00:07 { filename “grub/grub-x86_64.efi”; } else if option pxe-system-type = 00:09 { filename “grub/grub-x86_64.efi”; } else { filename “pxelinux.0”; } }

}

for dhcp_tag in $dhcp_tags.keys():

  1. ## group could be subnet if your dhcp tags line up with your subnets
  2. ## or really any valid dhcpd.conf construct ... if you only use the
  3. ## default dhcp tag in cobbler, the group block can be deleted for a
  4. ## flat configuration

group for Cobbler DHCP tag: $dhcp_tag

group {

  1. #for mac in $dhcp_tags[$dhcp_tag].keys():
  2. #set iface = $dhcp_tags[$dhcp_tag][$mac]
  3. host $iface.name {
  4. #if $iface.interface_type == "infiniband":
  5. option dhcp-client-identifier = $mac;
  6. #else
  7. hardware ethernet $mac;
  8. #end if
  9. #if $iface.ip_address:
  10. fixed-address $iface.ip_address;
  11. #end if
  12. #if $iface.hostname:
  13. option host-name "$iface.hostname";
  14. #end if
  15. #if $iface.netmask:
  16. option subnet-mask $iface.netmask;
  17. #end if
  18. #if $iface.gateway:
  19. option routers $iface.gateway;
  20. #end if
  21. #if $iface.enable_gpxe:
  22. if exists user-class and option user-class = "gPXE" {
  23. filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
  24. } else if exists user-class and option user-class = "iPXE" {
  25. filename "http://$cobbler_server/cblr/svc/op/gpxe/system/$iface.owner";
  26. } else {
  27. filename "undionly.kpxe";
  28. }
  29. #else
  30. filename "$iface.filename";
  31. #end if
  32. ## Cobbler defaults to $next_server, but some users
  33. ## may like to use $iface.system.server for proxied setups
  34. next-server $next_server;
  35. ## next-server $iface.next_server;
  36. }
  37. #end for

}

end for

  1. cobbler sync
  2. mount /dev/cdrom /mnt<br />cobbler import --path=/mnt --name=Centos-7.5-x86_64 --arch=x86_64
  3. vi /var/lib/cobbler/kickstarts/centos7.3-x86_64.cfg

Kickstart Configurator for cobbler by zhang

platform=x86, AMD64, or Intel EM64T

Firewall configuratio

firewall —disabled

Install OS instead of upgrade

install

Use network installation

url —url=http://192.168.152.100/cobbler/ks_mirror/Centos-7.5-x86_64

Root password

rootpw root

System authorization information

auth —useshadow—enablemd5

Use graphical mode install

graphical

Run the Setup Agent on first boot

firstboot —disable

System keyboard

keyboard us

System timezone

timezone Asia/Shanghai

System language

lang en_US

SELinux configuration

selinux —disabled

Installation logging level

logging —level=info

System timezone

timezone Asia/Shanghai

Network information

network —bootproto=dhcp —device=eth0 —onboot=on

System bootloader configuration

bootloader —location=mbr

Partition clearing information

clearpart —all —initlabel

Disk partitioning information

part /boot —fstype xfs —size 1024 —ondisk sda part swap —size=2048 —ondisk sda part / —fstype xfs —size 1 —grow —ondisk sda

Reboot after installation

reboot

Clear the Master Boot Record

zerombr

%packages gcc* sysstat lrzsz %end

```

cobbler profile edit —name=Centos-7.5-x86_64 —kickstart=/var/lib/cobbler/kickstarts/centos7.3-x86_64.cfg

cobbler profile edit —name=Centos-7.5-x86_64 —kopts=’net.ifnames=0 biosdevname=0’

cobbler sync

systemctl restart xinetd
systemctl restart httpd
systemctl restart cobblerd

systemctl enable xinetd
systemctl enable dhcpd
systemctl enable httpd
systemctl enable cobblerd
systemctl disable firewalld
setenforce 0
systemctl start xinetd httpd dhcpd cobblerd

vim /etc/cobbler/pxe/pxedefault.template # cobbler默认启动菜单路径