39127

「Cobbler」002-部署

<h1 id="部署">部署

<h2 id="安装相关软件">1. 安装相关软件</h2> <blockquote> yum -y install cobbler cobbler-web dhcp \ tftp-server pykickstart httpd xinetd </blockquote> <h2 id="启动与自启动">2. 启动与自启动</h2> <blockquote> systemctl enable httpd systemctl start httpd systemctl start cobblerd.service systemctl enable cobblerd.service </blockquote> <h2 id="核对当前设置">3. 核对当前设置</h2> <blockquote> cobbler check </blockquote> <h2 id="解决相关Question">4. 解决相关Question</h2> <h3 id="备份文件">4.1 备份文件</h3> <blockquote> cp /etc/cobbler/settings{,.bak} </blockquote> <h3 id="设置变量">4.2 设置变量</h3> <blockquote> ifconfig eth0|awk 'NR==2{print $2}' IP=$(ifconfig eth0|awk 'NR==2{print $2}') </blockquote> <h3 id="修改配置">4.3 修改配置</h3> <blockquote> sed -i "s/server: 127.0.0.1/server: $IP/" /etc/cobbler/settings grep "$IP" /etc/cobbler/settings sed -i 's/manage_dhcp: 0/manage_dhcp: 1/' /etc/cobbler/settings grep "manage_dhcp: 1" /etc/cobbler/settings sed -i 's/pxe_just_once: 0/pxe_just_once: 1/' /etc/cobbler/settings grep "pxe_just_once: 1" /etc/cobbler/settings openssl passwd -1 -salt 'mine' '123456' SSL=$(openssl passwd -1 -salt 'mine' '123456') sed -i "s/default_password_crypted.*/default_password_crypted: "$SSL"/" /etc/cobbler/settings grep "$SSL" /etc/cobbler/settings cp /etc/xinetd.d/tftp{,.bak} sed -i '/disable/s#yes#no#' /etc/xinetd.d/tftp grep disable /etc/xinetd.d/tftp </blockquote> <h3 id="下载文件">4.4 下载文件</h3> <blockquote> cobbler get-loaders ls /var/lib/cobbler/loaders/ </blockquote> <h3 id="添加服务">4.5 添加服务</h3> <blockquote> systemctl enable rsyncd systemctl start rsyncd </blockquote> <h2 id="再次核对设置">5. 再次核对设置</h2> <blockquote> systemctl restart cobblerd.service cobbler check

​ 以上两个Question暂时可以忽略

</blockquote> <h2 id="配置相关模板">6. 配置相关模板</h2> <blockquote>

​ 修改cobbler的dhcp模版,不要直接修改dhcp本身的配置文件,因为cobbler会覆盖。

</blockquote> <h3 id="备份与查看">6.1 备份与查看</h3> <blockquote> cp /etc/cobbler/dhcp.template{,.bak} sed -n '21,25p' /etc/cobbler/dhcp.template </blockquote> <h3 id="修改与确认">6.2 修改与确认</h3> <blockquote> sed -i 's#192.168.1.0#10.0.0.0#' /etc/cobbler/dhcp.template sed -i 's#192.168.1.5#10.0.0.254#' /etc/cobbler/dhcp.template sed -i 's#192.168.1.100 192.168.1.254#10.0.0.150 10.0.0.190#' \ /etc/cobbler/dhcp.template sed -i 's#192.168.1.1#223.5.5.5#' /etc/cobbler/dhcp.template sed -n '21,25p' /etc/cobbler/dhcp.template </blockquote> <h3 id="重启与同步">6.3 重启与同步</h3> <blockquote>

​ 重启服务并同步配置,改完dhcp必须要sync同步配置

systemctl restart cobblerd.service cobbler sync </blockquote> <h3 id="检查与确认">6.4 检查与确认</h3> <blockquote> netstat -lnup|grep dhcp sed -n '19,23p' /etc/dhcp/dhcpd.conf </blockquote> <h2 id="导入相应镜像">7. 导入相应镜像</h2> <blockquote>

​ 根据需求导入不同的镜像,这里用 CentOS 7.6 的镜像为演示

</blockquote> <h3 id="检查与确认-1">7.1 检查与确认</h3> <blockquote>

​ 检查和确认光盘是否已经装入DVD中

</blockquote> <h3 id="挂载与导入">7.2挂载与导入</h3> <blockquote>

​ 时间会比较久,请耐心等待

mount /dev/cdrom /mnt cobbler import --path=/mnt --name=Centos-7.6 --arch=x86_64 # --path 镜像路径 # --name 为安装源定义一个名字 # --arch 指定安装源是32位、64位、ia64, 目前支持的选项有: x86│x86_64│ia64 # 安装源的唯一标示就是根据name参数来定义,本例导入成功后,安装源的唯一标示就是:CentOS-7.6-x86_64,如果重复,系统会提示导入失败。 </blockquote> <h3 id="查看与确认">7.3 查看与确认</h3> <blockquote> cobbler distro list cobbler list </blockquote> <h2 id="查看相关信息">8. 查看相关信息</h2> <blockquote>

​ 镜像存放目录,cobbler会将镜像中的所有安装文件拷贝到本地一份,放在/var/www/cobbler/ks_mirror下的CentOS-7.1-x86_64目录下。因此/var/www/cobbler目录必须具有足够容纳安装文件的空间。

</blockquote> <h3 id="查看镜像存放的目录">8.1 查看镜像存放的目录</h3> <blockquote> ls /var/www/cobbler/ks_mirror ls /var/www/cobbler/ks_mirror/Centos-7.6-x86_64 du -smh /var/www/cobbler/ks_mirror/Centos-7.6-x86_64/ </blockquote> <h3 id="查看所有的profile设置">8.2 查看所有的profile设置</h3> <blockquote> cobbler profile report </blockquote> <h3 id="查看指定的profile设置">8.3 查看指定的profile设置</h3> <blockquote> cobbler profile report --name=CentOS-7.6-x86_64 </blockquote> <h3 id="查看安装镜像文件信息">8.4 查看安装镜像文件信息</h3> <blockquote> cobbler distro report --name=CentOS-7.6-x86_64 </blockquote> <h2 id="编写相关配置">9. 编写相关配置</h2> <blockquote>

​ kickstarts 配置文件自带很多,不过一般都是根据需求定制的

</blockquote> <h3 id="kickstarts-配置文件">9.1 kickstarts 配置文件</h3> <blockquote> ls /var/lib/cobbler/kickstarts/ </blockquote> <h3 id="这里就简单演示一下">9.2 这里就简单演示一下</h3> <blockquote> cat >/var/lib/cobbler/kickstarts/CentOS-7.6-x86_64.cfg <<'EOF' #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layouts keyboard 'us' # Root password rootpw --iscrypted $1$m1pE0DG6$vALBphGGynqvUzfJaWZ6U1 # Use network installation url --url="$tree" # System language lang en_US # Firewall configuration firewall --disabled # System authorization information auth --useshadow --passalgo=sha512 # Use graphical install graphical firstboot --disable # SELinux configuration selinux --disabled # Network information network --bootproto=dhcp --device=eth0 network --bootproto=dhcp --device=eth1 # Reboot after installation reboot # System timezone timezone Asia/Shanghai # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Record zerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --asprimary --fstype="ext4" --size=200 part swap --fstype="swap" --size=1024 part / --fstype="ext4" --grow --size=1 %packages @base @core @compat-libraries @debugging @development @gnome-desktop @X Window System %end EOF cat /var/lib/cobbler/kickstarts/CentOS-7.6-x86_64.cfg </blockquote> <h3 id="指定相关文件及调整参数">9.3 指定相关文件及调整参数</h3> <blockquote>

​ 修改安装系统的内核参数,在CentOS7系统有一个地方变了,就是网卡名变成eno xxx这种形式,但是为了运维标准化,我们需要将它变成我们常用的 eth0,因此使用下面的参数。但要注意是CentOS7才需要下面的步骤,CentOS6 不需要。

cobbler profile edit --name=CentOS-7.6-x86_64 \ --kickstart=/var/lib/cobbler/kickstarts/CentOS-7.6-x86_64.cfg cobbler profile edit --name=CentOS-7.6-x86_64 \ --kopts='net.ifnames=0 biosdevname=0' cobbler profile report|sed -n '9,11p' </blockquote> <h3 id="测试有无语法错误">9.4 测试有无语法错误</h3> <blockquote> cobbler validateks </blockquote> <h3 id="进行-cobbler-同步">9.5 进行 cobbler 同步</h3> <blockquote> cobbler sync </blockquote> <h3 id="重启服务端相关服务">9.6 重启服务端相关服务</h3> <blockquote> systemctl restart xinetd.service systemctl restart cobblerd.service systemctl restart httpd.service </blockquote>

来源:博客园

作者:Mine·Gi

链接:https://www.cnblogs.com/MineGi/p/11425899.html

Recommend