部署Centos7

时间:2023-03-09 22:03:13
部署Centos7
  • 挂载和导入镜像
mount /dev/cdrom /media
ll /media/
cobbler import --path=/media --name=centos7.4 --arch=x86_64
cobbler distro list //查看镜像列表
说明:cobber把镜像导入到该目录下:/var/www/cobbler/ks_mirror/
  • 配置centos7的ks文件
cd /var/lib/cobbler/kickstarts
vim centos7.ks
install
text
keyboard us
lang en_US
timezone Asia/ShangHai
rootpw --iscrypted $default_password_crypted
auth --useshadow --enablemd5
firewall --disabled
selinux --disabled
url --url=$tree
zerombr
bootloader --location=mbr
clearpart --all --initlabel
part /boot --fstype=xfs --size=200
part swap --size=1024
part / --fstype=xfs --grow --size=200
$yum_repo_stanza
$SNIPPET('network_config')
skipx
firstboot --disable
reboot
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
$SNIPPET('func_install_if_enabled')
@^minimal
@core
wget
lftp
vim-enhanced
bash-completion
%end
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
sed -ri "/^#UseDNS/c\UseDNS no" /etc/ssh/sshd_config
sed -ri "/^GSSAPIAuthentication/c\GSSAPIAuthentication no" /etc/ssh/sshd_config
systemctl enable httpd
%end
  • 镜像和ks文件关联
cobbler profile list                    //查看导入的镜像名称,profile包含ks文件和镜像
cobbler profile edit --name=centos7.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos7.ks
cobbler profile report
  • 修改C7的网卡为eth0,可以省略
cobbler profile edit --name=centos7.4-x86_64 --kopts='net.ifnames=0 biosdevname=0'
  • 检测ks文件是否有语法错误
cobbler validateks
  • 额外知识:添加一个profile
cp centos7.ks centos7-webserver.ks
cobbler profile add --name=centos7.4-web-server-x86_64 --distro="centos7.4-x86_64" --kickstart=/var/lib/cobbler/kickstarts/centos7.ks --kopts='net.ifnames=0 biosdevname=0'
cobbler profile report

部署Centos7

  • 报错:虚拟机上安装报错:no space left on device,
解决方案虚拟内存不足,调整内存到2G