cobbler简介
Cobbler经过将设置和管理一个安装服务器所涉及的任务集中在一块儿,从而简化了系统配置。至关于Cobbler封装了DHCP、TFTP、XINTED等服务,结合了PXE、kickstart等安装方法,能够实现自动化安装操做系统,而且能够同时提供多种版本,以实如今线安装不一样版本的系统。linux
cobbler相关服务ios
DHCP:DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工做, 主要有两个用途:给内部网络或网络服务供应商自动分配IP地址,给用户或者内部网络管理员做为对全部计算机做中央管理的手段。DHCP有3个端口,其中UDP67和UDP68为正常的DHCP服务端口,分别做为DHCP Server和DHCP Client的服务端口;546号端口用于DHCPv6 Client,而不用于DHCPv4,是为DHCP failover服务,这是须要特别开启的服务,DHCP failover是用来作“双机热备”的。git
TFTP:TFTP是一种比较特殊的文件传输协议。相对于FTP和目前常用的SFTP,TFTP是基于TCP/IP协议簇,用于进行简单文件传输,提供简单、低开销的传输服务。TFTP的端口设置为69。
相对于常见的FTP,TFTP有两个比较好的优点:github
默认状况下,Linux内部是安装了tftp服务器包的。可是默认是不启动的。vim
PXE:预启动执行环境(Preboot eXecution Environment,PXE,也被称为预执行环境)提供了一种使用网络接口(Network Interface)启动计算机的机制。这种机制让计算机的启动能够不依赖本地数据存储设备(如硬盘)或本地已安装的操做系统。centos
PXE当初是做为Intel的有线管理体系的一部分,Intel 和 Systemsoft于1999年9月20日公布其规格(版本2.1)[1]。经过使用像网际协议(IP)、用户数据报协议(UDP)、动态主机设定协定(DHCP)、小型文件传输协议(TFTP)等几种网络协议和全局惟一标识符(GUID)、通用网络驱动接口(UNDI)、通用惟一识别码(UUID)的概念并经过对客户机(经过PXE自检的电脑)固件扩展预设的API来实现目的。服务器
交互过程网络
初始化环境dom
软件:vmware workstation 14 操做系统: centos7.4-mini 关闭防火墙: systemctl stop firewalld systemctl disable firewalld 修改selinux: sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 修改网卡配置文件: BOOTPROTO=static IPV6INIT=no ONBOOT=YES IPADDR=192.168.26.30 NETMASK=255.255.255.0 GATEWAY=192.168.26.2 DNS1=114.114.114.114 DNS2=8.8.8.8 添加yum源: cd /etc/yum.repos.d yum -y install epel-release yum clean all yum makecache 最后reboot,保存快照。
安装须要的包工具
yum -y install httpd tftp xinetd pykickstart cobbler dhcp systemctl start httpd cobblerd rsyncd systemctl enable httpd cobblerd rsyncd
修改配置文件
cobbler主目录在/etc/cobbler/settings vim /etc/cobbler/settings 将server: 127.0.0.1修改成server: 192.168.26.30 将修改成next_server: 127.0.0.1修改成next_server: 192.168.26.30 将manage_dhcp: 0修改成manage_dhcp: 1 -->表示由cobbler来控 制dhcp :x 修改tftp配置文件:/etc/xinetd.d/tftp disabled后面改成no -->开机启动 cobbler get-loaders -->下载补丁 修改dhcp:/etc/cobbler/dhcp.template ##此处提出正确配置 subnet 192.168.26.0 netmask 255.255.255.0 { option routers 192.168.26.2; option domain-name-servers 114.114.114.114; -->DNS,若是不写后面在执行安装后脚本会报错 option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.26.100 192.168.26.254; default-lease-time 21600; max-lease-time 43200; next-server $next_server; 设置安装操做系统的root密码: openssl passwd -1 -salt 'youdaoyun' 'youdaoyun' 将生成的随机字符添加到cobbler配置文件中 将以前这行注释掉替换成本身的密码,以下图
重启应用 systemctl restart cobblerd xinetd cobbler check -->检查命令,通常还剩余两个,不用管 cobbler sync -->同步配置文件
上传镜像
选择的是centos7-mini.iso包,后面有须要的东西能够写在ks文件中 1.将iso包上传到根目录下 mkdir -p /data/centos7.4-mini mount -o loop CentOS-7.4-x86_64-Minimall-1708.iso /data/centos7.4-mini/ 使用df -h查看是否挂载成功 2.导入镜像文件 cobbler import --path=/data/centos7.4-mini/ --name=CentOS_7.4_Mini --arch=x86_64 --path表明镜像地址 --name表明当pxe启动后选择的哪一个镜像 --arch表明指定安装源是64位 3.查看profile cobbler profile list 4.查看profile的内容 cobbler profile report 5.将已经作好的ks文件修改成centos7_4.cfg上传到/var/lib/cobbler/kickstarts/,等下会贴出来 6.自定义kickstart文件 cobbler profile edit --name=CentOS_7.4_Mini-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7_4.cfg 7.修改centos7内核,即网卡名 cobbler profile edit --name=CentOS_7.4_Mini-x86_64 --kopts='net.ifnames=0 biosdevname=0' 8.修改完配置文件必须运行cobbler sync同步配置
ks文件
#Kickstart Configurator for cobbler by Jason Zhao #platform=x86, AMD64, or Intel EM64T #System language lang en_US #System keyboard keyboard us #Sytem timezone timezone Asia/Shanghai #Root password rootpw --iscrypted $default_password_crypted #Use text mode install text #Install OS instead of upgrade install #Use NFS installation Media url --url=$tree #System bootloader configuration bootloader --location=mbr #Clear the Master Boot Record zerombr #Partition clearing information clearpart --all --initlabel #Disk partitioning information part /boot --fstype xfs --size 1024 --ondisk sda part swap --size 16384 --ondisk sda part / --fstype xfs --size 1 --grow --ondisk sda #System authorization infomation auth --useshadow --enablemd5 #Network information $SNIPPET('network_config') #network --bootproto=dhcp --device=em1 --onboot=on # Reboot after installation reboot #Firewall configuration firewall --disabled #SELinux configuration selinux --disabled #Do not configure XWindows skipx #Package install information %pre $SNIPPET('log_ks_pre') $SNIPPET('kickstart_start') $SNIPPET('pre_install_network_config') # Enable installation monitoring $SNIPPET('pre_anamon') %end %post systemctl disable postfix.service systemctl stop firewalld systemctl disable firewalld sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config yum -y install vim net-tools %end
启动虚拟机测试
1.设置服务器网络启动,在vmware workstation中为按下电源时打开固件
2.DHCP获取过程太快了,直接来到了cobbler的界面
选项1为从本地磁盘启动,可是由于在vmware workstation中作的,预先加载了centos7的环境,因此即便你从本地磁盘启动,也会是一个安装操做系统的界面
选项2是咱们刚刚作的,直接选择第二个,而后等待安装,在安装完成后会关闭selinux、防火墙,而且安装vim、net-tools工具包。
其他配置:有时候须要标识企业信息或者我的信息,能够经过如下方式进行修改。
vim /etc/cobbler/pxe/pxedefault.template 将第二行的 Cobbler | http://cobbler.github.io/修改为你本身的标识 修改完配置文件后须要执行cobbler sync
因为该文档直接由有道云笔记拷贝过来,图像是看不到的,还请见谅。