Centos7.X版本安装cobbler vim /etc/selinux/config #关闭selinux setenforce 0 #半关闭 chkconfig iptables off #开机不自启 iptables -F #清空防火墙 [root@bogon ~]# systemctl stop firewalld #关闭防火墙 [root@bogon ~]# systemctl disable firewalld #开机不自启 [root@bogon ~]# cat /etc/redhat-release #查看linux版本 CentOS Linux release 7.4.1708 (Core) [root@bogon ~]# uname -r #查看内核版本 3.10.0-693.el7.x86_64 [root@localhost ~]# yum clean all #清理缓存 [root@localhost yum.repos.d]# yum makecache #建立缓存 [root@bogon ~]# yum -y install epel-release # [root@localhost yum.repos.d]# yum -y install cobbler cobbler-web pykickstart debmirror #pykickstart #自动配置kickstart脚本端 #debmirror #能够被PXE引导的引导文件的软件包 [root@bogon ~]# yum -y install httpd [root@bogon ~]# systemctl restart httpd [root@bogon ~]# systemctl restart cobblerd [root@bogon ~]# netstat -an |grep 25151 tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN

[root@bogon ~]# systemctl status httpd #查看apache状态 ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since 三 2018-09-12 16:11:25 CST; 3h 7min ago Docs: man:httpd(8) man:apachectl(8) Main PID: 1448 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─1448 /usr/sbin/httpd -DFOREGROUND ├─1449 /usr/sbin/httpd -DFOREGROUND ├─1450 /usr/sbin/httpd -DFOREGROUND ├─1451 /usr/sbin/httpd -DFOREGROUND ├─1452 /usr/sbin/httpd -DFOREGROUND └─1453 /usr/sbin/httpd -DFOREGROUND

9月 12 16:10:24 bogon systemd[1]: Starting The Apache HTTP Server... 9月 12 16:10:55 bogon httpd[1448]: AH00558: httpd: Could not reliably determine the se...age 9月 12 16:11:25 bogon systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.

[root@bogon ~]# systemctl status cobblerd #查看cobbler状态 ● cobblerd.service - Cobbler Helper Daemon Loaded: loaded (/usr/lib/systemd/system/cobblerd.service; disabled; vendor preset: disabled) Active: active (running) since 三 2018-09-12 16:18:02 CST; 3h 3min ago Process: 1498 ExecStartPost=/usr/bin/touch /usr/share/cobbler/web/cobbler.wsgi (code=exited, status=0/SUCCESS) Main PID: 1497 (cobblerd) CGroup: /system.slice/cobblerd.service └─1497 /usr/bin/python2 -s /usr/bin/cobblerd -F

9月 12 16:18:02 bogon systemd[1]: Starting Cobbler Helper Daemon... 9月 12 16:18:02 bogon systemd[1]: Started Cobbler Helper Daemon.

[root@bogon ~]# vim /etc/cobbler/settings

272 next_server: 192.168.10.10 384 server: 192.168.10.10

[root@bogon ~]# vim /etc/xinetd.d/tftp

default: off

description: The tftp server serves files using the trivial file transfer \

protocol. The tftp protocol is often used to boot diskless \

workstations, download configuration files to network-aware printers, \

and to start the installation process for some operating systems.

service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 } ~
[root@bogon ~]# cobbler get-loaders #更新补丁 task started: 2018-09-12_195923_get_loaders task started (id=Download Bootloader Content, time=Wed Sep 12 19:59:23 2018) downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/README downloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo downloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot downloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux downloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi downloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yaboot downloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0 downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32 downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi downloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi *** TASK COMPLETE ***

[root@bogon ~]# systemctl enable rsyncd #开启rsync Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.

[root@bogon ~]# vim /etc/debmirror.conf

Download options

$host="ftp.debian.org"; $user="anonymous"; $passwd="anonymous@"; $remoteroot="debian"; $download_method="ftp"; #@dists="sid"; #注释掉 @sections="main,main/debian-installer,contrib,non-free"; #@arches="i386"; #注释掉

[root@bogon ~]# openssl passwd -1 -salt $(openssl rand -hex 4) Password: $1$19017682$.wZFJpkl.qP88idfa34IK/ [root@bogon ~]# vim /etc/cobbler/settings default_password_crypted: "$1$19017682$.wZFJpkl.qP88idfa34IK/"

安装栅设备隔离 #centos6是有cman的,centos7是没有cman的,如果报错,是正常的。 [root@bogon ~]# yum -y install cman fence-agents 用cobbler管理DHCP,修改242行manage_dhcp: 0 vim /etc/cobbler/settings manage_dhcp: 1

#防止循环装系统,适用于服务器第一启动项是PXE启动,修改292行pxe_just_once: 0 #修改为1 285 # if this setting is set to 1, cobbler systems that pxe boot 如果这个设置被设置为1,pxe启动的cobbler系统 286 # will request at the end of their installation to toggle the 在安装结束时,将请求关闭 287 # --netboot-enabled record in the cobbler system record. This eliminates 在cobbler系统记录中启用了netboot-enabled记录。这就消除了 288 # the potential for a PXE boot loop if the system is set to PXE 如果系统被设置为PXE,那么PXE启动循环的潜力 289 # first in it's BIOS order. Enable this if PXE is first in your BIOS 首先是BIOS的顺序。如果PXE在您的BIOS中首先出现,则启用此功能 290 # boot order, otherwise leave this disabled. See the manpage 启动订单,否则将禁用此功能。看到从 291 # for --netboot-enabled. 支持netboot-启用。

292 pxe_just_once: 1

#修改完后重启服务再进行一次检测 [root@bogon system]# systemctl restart cobblerd [root@bogon system]# yum -y install dhcp [root@bogon system]# cp -a /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y

[root@bogon system]# vim /etc/dhcp/dhcpd.conf subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.100 192.168.10.200; option routers 192.168.10.2; default-lease-time 600; max-lease-time 7200; } next-server 192.168.10.10; filename="pxelinux.0";

[root@bogon system]# systemctl restart dhcpd [root@bogon system]# systemctl enable dhcpd Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.

[root@bogon system]# yum -y install xinetd #在centos7里没有xinetd [root@bogon system]# systemctl enable xinetd [root@bogon system]# systemctl restart xinetd [root@bogon system]# systemctl restart tftp [root@bogon system]# systemctl enable tftp Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket. [root@bogon system]# cobbler sync [root@bogon system]# cobbler check #检测配置文件 No configuration problems found. All systems go.

#挂载镜像

[root@bogon system]# mkdir -p /mnt/cdrom [root@bogon system]# vim /etc/fstab /dev/sr0 /mnt/cdrom iso9660 defaults 0 0 [root@bogon system]# mount -a

#导入镜像 [root@bogon system]# cobbler import --name="centos7-x86_64" --path=/mnt/cdrom/ task started: 2018-09-16_113922_import task started (id=Media import, time=Sun Sep 16 11:39:22 2018) Found a candidate signature: breed=redhat, version=rhel6 Found a candidate signature: breed=redhat, version=rhel7 Found a matching signature: breed=redhat, version=rhel7 Adding distros from path /var/www/cobbler/ks_mirror/centos7-x86_64: creating new distro: centos7-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos7-x86_64 -> /var/www/cobbler/links/centos7-x86_64 creating new profile: centos7-x86_64 associating repos checking for rsync repo(s) checking for rhn repo(s) checking for yum repo(s) starting descent into /var/www/cobbler/ks_mirror/centos7-x86_64 for centos7-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos7-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/centos7-x86_64 looking for /var/www/cobbler/ks_mirror/centos7-x86_64/repodata/comps.xml Keeping repodata as-is :/var/www/cobbler/ks_mirror/centos7-x86_64/repodata *** TASK COMPLETE *** [root@bogon mnt]# cobbler distro list #查看镜像列表 centos7-x86_64 # /var/www/cobbler/ks_mirror/ 镜像存放目录 [root@bogon ks_mirror]# cobbler profile list #查看生成的剧本 centos7-x86_64 [root@bogon ks_mirror]# cobbler profile remove --name=centos7-x86_64 #删除剧本文件

[root@bogon kickstarts]# cobbler list
distros: centos7-x86_64

profiles:

systems:

repos:

images:

mgmtclasses:

packages:

files: [root@bogon kickstarts]# cobbler distro report --name=centos7-x86_64 #查看安装镜像文件信息 Name : centos7-x86_64 Architecture : x86_64 TFTP Boot Files : {} Breed : redhat Comment : Fetchable Files : {} Initrd : /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/initrd.img Kernel : /var/www/cobbler/ks_mirror/centos7-x86_64/images/pxeboot/vmlinuz Kernel Options : {} Kernel Options (Post Install) : {} Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/centos7-x86_64'} Management Classes : [] OS Version : rhel7 Owners : ['admin'] Red Hat Management Key : <<inherit>> Red Hat Management Server : <<inherit>> Template Files : {}

[root@bogon kickstarts]# ls default.ks install_profiles sample_autoyast.xml sample_esxi4.ks sample.ks esxi4-ks.cfg legacy.ks sample_end.ks(默认使用的kickstarts文件) sample_esxi5.ks sample_old.seed esxi5-ks.cfg pxerescue.ks sample_esx4.ks sample_esxi6.ks sample.seed

#找一个centos7-x86_64.cfg文件 拷贝到/var/lib/cobbler/kickstarts目录下 [root@bogon kickstarts]# cobbler profile add --name=centos7-basic --distro=centos7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7-x86_64.cfg # #指定ks文件名称,导入镜像文件名称,导入剧本文件,把ks文件和镜像文件联立起来

如果想做多个系统,首先上传镜像文件,生成ks剧本文件,然后把剧本文件和镜像文件联立起来

cobbler profile edit --name=centos7-basic --kopts='net.ifnames=0 biosdevname=0' #修改网卡名称,使用eth0名称 #指定 cobbler system add --name=a1 --mac=00:0c:29:6f:b7:4c --profile=centos7-basic --ip-address=192.168.10.20 --subnet=255.255.255.0 --interface=eth0 --static=1 --gateway=192.168.10.2 --hostname=www.wk.com --name-servers="114.114.114.114" cobbler system list #查看指定主机

自定义安装系统: #cobble默认使用的是https连接 每次安装系统都要选择,比较麻烦,那么我们指定MAC地址进行安装,就可以达到自动安装无需再选择操作系统,即使有多个操作系统,只要指定操作系统和MAC地址就可以自动安装 #cobbler WEB端配置:账户密码都是cobbler

选择--系统--创建新系统

#定义系统信息

#配置全局网络信息,网关,DNS

#配置网卡信息 eth0 eth1 注意选择 static

在安装过程中,如果出现: No space left on device

出现这个错误的原因是虚拟机的内存不足2G,这个错误在7.3版本以上