centos7修改密码_CentOS 7 基于cobbler实现系统的自动化安装

1 环境准备

两台主机

一台主机:CentOS 7.7 充当Cobbler,http,dhcp,tftp服务器,并关闭防火墙和SELinux

一台主机:充当测试机,用于实现自动化安装Linux系统

网络要求:关闭Vmware软件中的NAT模式中的DHCP服务,两个主机网卡基于NAT模式

2 安装相关包并启动服务

[root@centos7 ~]#yum install cobbler dhcp[root@centos7 ~]#systemctl enable --now cobblerd httpd tftp dhcpd 

3 修改cobbler相关的配置

[root@centos7 ~]#cobbler checkThe following are potential configuration items that you may want to fix:​1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work.  This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.3 : change 'disable' to 'no' in /etc/xinetd.d/tftp4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.5 : enable and start rsyncd.service with systemctl6 : debmirror package is not installed, it will be required to manage debian deployments and repositories7 : ksvalidator was not found, install pykickstart8 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one9 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them​#生成新密码,默认安装好的系统root密码为cobbler[root@centos7 ~]#openssl passwd -1  'magedu'$1$1spuisnh$j34LNmyTQWs3l6xKxCZY60​#根据以上提示,只需要做1,2,8这三项即可,修改下面四行[root@centos7 ~]#vim  /etc/cobbler/settings default_password_crypted: "$1$1spuisnh$j34LNmyTQWs3l6xKxCZY60"next_server:< tftp服务器的 IP 地址>server:manage_dhcp:1  #设置为1,表示通过cobbler生成dhcpd.conf配置文件​[root@centos7 ~]#systemctl restart cobblerd 

4 实现dhcp服务

#修改dhcp的模版文件下面的行,用来生成dhcp的配置文件[root@centos7 ~]#vim /etc/cobbler/dhcp.templatesubnet 192.168.100.0 netmask 255.255.255.0 {     option routers             192.168.100.1;     option domain-name-servers 180.76.76.76,223.6.6.6;     option subnet-mask         255.255.255.0;     range  dynamic-bootp       192.168.100.1 192.168.100.200;​[root@centos7 ~]#cobbler sync [root@centos7 ~]#systemctl start dhcpd 

5 下载启动的相关文件

[root@centos7 ~]#cobbler get-loaderstask started: 2020-02-10_163111_get_loaderstask started (id=Download Bootloader Content, time=Mon Feb 10 16:31:11 2020)downloading https://cobbler.github.io/loaders/README to /var/lib/cobbler/loaders/READMEdownloading https://cobbler.github.io/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilodownloading https://cobbler.github.io/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yabootdownloading https://cobbler.github.io/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinuxdownloading https://cobbler.github.io/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efidownloading https://cobbler.github.io/loaders/yaboot-1.3.17 to /var/lib/cobbler/loaders/yabootdownloading https://cobbler.github.io/loaders/pxelinux.0-3.86 to /var/lib/cobbler/loaders/pxelinux.0downloading https://cobbler.github.io/loaders/menu.c32-3.86 to /var/lib/cobbler/loaders/menu.c32downloading https://cobbler.github.io/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efidownloading https://cobbler.github.io/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi*** TASK COMPLETE ***[root@centos7 ~]#ls /var/lib/cobbler/loadersCOPYING.elilo     COPYING.yaboot  grub-x86_64.efi  menu.c32    READMECOPYING.syslinux  elilo-ia64.efi  grub-x86.efi     pxelinux.0  yaboot[root@centos7 ~]#tree /var/lib/tftpboot//var/lib/tftpboot/├── boot├── etc├── grub├── images├── images2├── ppc├── pxelinux.cfg└── s390x​8 directories, 0 files[root@centos7 ~]#cobbler synctask started: 2020-02-10_163219_synctask started (id=Sync, time=Mon Feb 10 16:32:19 2020)running pre-sync triggerscleaning treesremoving: /var/lib/tftpboot/grub/imagescopying bootloaderstrying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboottrying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisktrying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efitrying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.eficopying distros to tftpbootcopying imagesgenerating PXE configuration filesgenerating PXE menu structurerendering TFTPD filesgenerating /etc/xinetd.d/tftpcleaning link cachesrunning post-sync triggersrunning python triggers from /var/lib/cobbler/triggers/sync/post/*running python trigger cobbler.modules.sync_post_restart_servicesrunning shell triggers from /var/lib/cobbler/triggers/sync/post/*running python triggers from /var/lib/cobbler/triggers/change/*running python trigger cobbler.modules.manage_gendersrunning python trigger cobbler.modules.scm_trackrunning shell triggers from /var/lib/cobbler/triggers/change/**** TASK COMPLETE ***[root@centos7 ~]#tree /var/lib/tftpboot//var/lib/tftpboot/├── boot│   └── grub│       └── menu.lst├── etc├── grub│   ├── efidefault│   ├── grub-x86_64.efi│   ├── grub-x86.efi│   └── images -> ../images├── images├── images2├── memdisk├── menu.c32├── ppc├── pxelinux.0├── pxelinux.cfg│   └── default├── s390x│   └── profile_list└── yaboot​10 directories, 10 files​

6 修改菜单的标题信息

[root@centos7 ~]#vim /etc/cobbler/pxe/pxedefault.templateMENU TITLE Cobbler | http://www.magedu.com/ ​[root@centos7 ~]#cobbler sync[root@centos7 ~]#cat /var/lib/tftpboot/pxelinux.cfg/defaultDEFAULT menuPROMPT 0MENU TITLE Cobbler | http://www.magedu.com/TIMEOUT 200TOTALTIMEOUT 6000ONTIMEOUT local​LABEL local        MENU LABEL (local)        MENU DEFAULT        LOCALBOOT -1​​​MENU end

7 导入CentOS系统的安装文件,生成相应的YUM源

[root@centos7 ~]#cobbler import --name=centos-8.1-x86_64 --path=/misc/cd --arch=x86_64[root@centos7 ~]#mount /dev/sr1 /mntmount: /dev/sr1 is write-protected, mounting read-only[root@centos7 ~]#cobbler import --name=centos-7.7-x86_64 --path=/mnt --arch=x86_64[root@centos7 ~]#du -sh /var/www/cobbler/ks_mirror/*11G /var/www/cobbler/ks_mirror/centos-7.7-x86_647.2G    /var/www/cobbler/ks_mirror/centos-8.1-x86_6412K /var/www/cobbler/ks_mirror/config[root@centos7 ~]#cobbler distro list   centos-7.7-x86_64   centos-8.1-x86_64​[root@centos7 ~]#cobbler profile list   centos-7.7-x86_64   centos-8.1-x86_64​#默认生成的是最小化安装

8 准备 kickstart文件,并关联至指定的YUM源

[root@centos7 ~]#vim /var/lib/cobbler/kickstarts/centos8.cfg[root@centos7 ~]#cat /var/lib/cobbler/kickstarts/centos8.cfgignoredisk --only-use=sdazerombrtextrebootclearpart --all --initlabelselinux --disabledfirewall --disabledurl --url=$tree   #注意此行必须指定keyboard --vckeymap=us --xlayouts='us'lang en_US.UTF-8network  --bootproto=dhcp --device=ens160 --ipv6=auto --activatenetwork  --hostname=centos8.magedu.comrootpw --iscrypted $6$nOPs5JTMlP4mhQeW$R/o62B6SXAh3RR.zrZ3U0X4xYX9/u5nSLrR/vqCB6kdO2XFfMk2a4yAgrHJQpXK/e4jzRb0jiLBv2nFMXaBjB/firstboot --enableskipxservices --disabled="chronyd"timezone Asia/Shanghai --isUtc --nontpuser --name=wang --password=$6$oUfb/02CWfLb5l8f$sgEZeR7c7DpqfpmFDH6huSmDbW1XQNR4qKl2EPns.gOXqlnAIgv9pTogtFVaDtEpMOC.SWXKYqxfVtd9MCwxb1 --iscrypted --gecos="wang"part / --fstype="xfs" --ondisk=sda --size=102400part /data --fstype="xfs" --ondisk=sda --size=51200part swap --fstype="swap" --ondisk=sda --size=2048part /boot --fstype="ext4" --ondisk=sda --size=1024%packages@^minimal-environmentkexec-tools%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anacondapwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notemptypwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyokpwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty%end​#将kickstart文件,关联指定的YUM源和生成菜单列表[root@centos7 ~]#cobbler profile add --name=CentOS-8.1_test --distro=CentOS-8.1-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos8.cfg[root@centos7 ~]#cobbler profile add --name=CentOS-7.7_test --distro=CentOS-7.7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.cfg​#删除默认生成的菜单[root@centos7 ~]#cobbler profile remove --name=centos-8.1-x86_64[root@centos7 ~]#cobbler profile remove --name=centos-7.7-x86_64​​[root@centos7 ~]#cobbler profile list   CentOS-7.7_test   CentOS-8.1_test​​#删除默认的菜单列表[root@centos7 ~]#cobbler profile remove --name=CentOS8.0-x86_64

9 测试客户端基于Cobbler实现自动安装

d37ae97c15d60f72ad397f695270df36.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值