本文共 4489 字,大约阅读时间需要 14 分钟。
cobbler系统自动化安装
准备环境:
centos7EPEL源(sohu旧源)连接互联网独立网段vmnet6 (确保vmware中dhcp服务关闭)eth0:10.0.0.200/16 vmnet6 eth1:172.20.0.7/16 vmnet0 桥接 192.168.33.131 NAT 可以上网[root@centos7 ~]#getenforce //确保selinux已经关闭
Disabled[root@centos7 ~]#iptables -F //清防火墙1、 安装包
[root@centos7 ~]#yum install cobbler cobbler-web dhcp[root@centos7 ~]#systemctl enable dhcpd httpd tftp cobblerd //暂且先不起dhcp, 服务尚未配置[root@centos7 ~]#systemctl start cobblerd httpd tftp2、检查cobbler配置存在的问题,逐一解决
[root@centos7 ~]#cobbler check3、编辑cobbler的配置文件
[root@centos7 ~]#vim /etc/cobbler/settingsserver 10.0.0.200next_server: 10.0.0.200 manage_dhcp: 1default_password_crypted: "$1$iXvBL83y$EYkqMm9z.clIubP/kB6PC0" //用下面命令生成密码来取代默认的密码,更安全[root@centos7 ~]#openssl passwd -1 //生成root口令
Password: Verifying - Password: $1$iXvBL83y$EYkqMm9z.clIubP/kB6PC0执行 cobbler get-loaders 命令即可;否则,需要安装syslinux程序包,而后复制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目录中;
[root@centos7 ~]#cobbler get-loaderstask started: 2019-01-31_100341_get_loaderstask started (id=Download Bootloader Content, time=Thu Jan 31 10:03:41 2019)downloading to /var/lib/cobbler/loaders/READMEdownloading to /var/lib/cobbler/loaders/COPYING.elilodownloading to /var/lib/cobbler/loaders/COPYING.yabootdownloading to /var/lib/cobbler/loaders/COPYING.syslinuxdownloading to /var/lib/cobbler/loaders/elilo-ia64.efidownloading to /var/lib/cobbler/loaders/yabootdownloading to /var/lib/cobbler/loaders/pxelinux.0downloading to /var/lib/cobbler/loaders/menu.c32downloading to /var/lib/cobbler/loaders/grub-x86.efidownloading to /var/lib/cobbler/loaders/grub-x86_64.efi TASK COMPLETE//查看/var/lib/cobbler/loaders/目录结构
[root@centos7 ~]#tree /var/lib/cobbler/loaders//var/lib/cobbler/loaders/├── COPYING.elilo├── COPYING.syslinux├── COPYING.yaboot├── elilo-ia64.efi├── grub-x86_64.efi├── grub-x86.efi├── menu.c32├── pxelinux.0├── README└── yaboot//查看/var/lib/tftpboot/目录结构
[root@centos7 ~]#tree /var/lib/tftpboot//var/lib/tftpboot/├── boot│ └── grub│ └── menu.lst├── etc├── grub│ ├── efidefault│ └── images -> ../images├── images├── images2├── memdisk├── menu.c32├── ppc├── pxelinux.0├── pxelinux.cfg│ └── default└── s390x└── profile_list4、修改cobbler的dhcp模版,这个模板会覆盖dhcp本身的配置文件
[root@centos7 ~]#vim /etc/cobbler/dhcp.template subnet 10.0.0.0 netmask 255.255.0.0 { option routers 10.0.0.254;option domain-name-servers 223.5.5.5;range dynamic-bootp 10.0.0.10 10.0.100.254;5、同步cobbler的配置,可以看到同步干了哪些事
[root@centos7 ~]#cobbler sync[root@cobbler ~]# cobbler //Cobbler的命令行管理(6和7的命令是一致的)
usagecobbler <distro|profile|system|repo|p_w_picpath|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version|signature|get-loaders|hardlink> [options|--help]cobbler check //核对当前设置是否有问题cobbler list //列出所有的cobbler元素cobbler report //列出元素的详细信息cobbler sync //同步配置到数据目录,更改配置最好都要执行下cobbler reposync //同步yum仓库cobbler distro //查看导入的发行版系统信息cobbler system //查看添加的系统信息cobbler profile //查看配置信息6、导入系统源
[root@centos7 ~]#echo "- - -" > /sys/class/scsi_host/host0/scan //添加光驱,挂载光盘,通过下面步骤识别光盘[root@centos7 ~]#df
Filesystem 1K-blocks Used Available Use% Mounted on/dev/sr0 9176232 9176232 0 100% /run/media/root/CentOS 7 x86_64/dev/sr1 3897932 3897932 0 100% /run/media/root/CentOS_6.10_Final[root@centos7 ~]#mount /dev/sr1 /mnt/ //临时挂载光盘
[root@centos7 mnt]# cobbler import --name=centos-6.10-x86_64 --path=/mnt --arch=x86_64
--name //为安装源定义一个名字--path //镜像路径--arch //指定安装源是32位、64位、ia64, 目前支持的选项有: x86 x86_64 ia64#查看镜像列表
[root@centos7 mnt]# cobbler distro listCentOS-6.10-x86_64[root@centos7 ~]#du -sh /var/www/cobbler/ks_mirror/ //导入文件的路径
3.8G /var/www/cobbler/ks_mirror/[root@centos7 ~]#cat /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menuPROMPT 0MENU TITLE Cobbler | TIMEOUT 200TOTALTIMEOUT 6000ONTIMEOUT localLABEL local
MENU LABEL (local)MENU DEFAULTLOCALBOOT -1LABEL centos-6.10-x86_64
kernel /images/centos-6.10-x86_64/vmlinuzMENU LABEL centos-6.10-x86_64append initrd=/images/centos-6.10-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=ipappend 2MENU end7、 导入自定义的ks文件
[root@centos7 ~]#cobbler profile remove --name=centos-7.6-x86_64[root@centos7 ~]#cobbler profile add --name=centos-7.6-x86_64_test --distro=centos-7.6-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7_mini.cfgcobbler 自动化部署也可以参考网上资料:
Cobbler-自动化部署神器:转载于:https://blog.51cto.com/8845692/2350839