运维制动化之系统安装 实验

 

步骤
0:selinux,iptables
1 安装包
2 启服务
3 修改配置文件;reload,restart
4 测试
网卡模式不要桥接:
vim /etc/dhcp/dhcpd.conf
option domain-name “magedu.org”;
option domain-name-servers 114.114.114.114,1.1.1.1;
option routers 192.168.30.200;
default-lease-time 86400;
max-lease-time 100000;
subnet 192.168.30.0 netmask 255.255.255.0 {
        range 192.168.30.10 192.168.30.100;
        option routers 192.168.30.254;
        option domain-name-servers 8.8.8.8;
next-server 192.168.30.7;
        filename “pxelinux.0”;
}
subnet 6.6.6.0 netmask 255.255.255.0 {
        range 6.6.6.1 6.6.6.100;
}
host  testclient {
  hardware ethernet 00:0c:29:e1:f7:aa;
  fixed-address  192.168.30.6;
  option routers 192.168.30.123;
  option domain-name-servers 223.5.5.5;
tftp server pxelinux.0
}
实验:tftp服务
1 yum install tftp-server
2 systemctl start tftp.socket
3 systemctl enable tftp
实验:实现CENTOS7 PXE安装
0 selinux ,firewall 关闭
1 安装包
yum install dhcp tftp-server httpd syslinux
systemctl enable dhcpd httpd tftp.socket
systemctl start httpd
2 准备YUM源
mkdir /var/www/html/centos/{6,7}/ -pv
vim /etc/fstab 加下面行
/dev/sr0         /var/www/html/centos/7    iso9660 defaults        0 0
mount -a
df
3 准备ks文件
mkdir /var/www/html/ksdir/{6,7} -pv
cp /root/anaconda-ks.cfg  /var/www/html/ksdir/7/ks7_desktop.cfg
chmod +r /var/www/html/ksdir/7/ks7_desktop.cfg
vim /var/www/html/ksdir/7/ks7_desktop.cfg
url –url=http://192.168.30.7/centos/7
text
reboot
network  –bootproto=dhcp –device=ens33 –onboot=on –ipv6=auto –activate
network  –hostname=centos7.magedu.com
# Root password
zerombr
%packages
@base
@core
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@print-client
@x11
autofs
%end
%addon com_redhat_kdump –enable –reserve-mb=’auto’
%end
%post
systemctl enable autofs
systemctl disable initial-setup.service
systemctl set-default multi-user.target
mkdir /root/.ssh
cat > /root/.ssh/authorized_keys <<EOF
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCn7U/0bi4xPrC9ClfTC+VAHtfL37Djh22tfM9ebR1/rC9PMGGmm1oiaoLx7ltgNtJGUZEWLrvrgLmJEsv6V+89O8dROcysSSGkbiXJVMbb6Y6spHNVQBEiw30sNs8JyiWzWQJKrNyDj5WBTHDGFEzmhSP1+gZxLrwd/oZSvGL2KPzmznKfQ3P6lEWAAlsdkqB5pLLhVs55KlNo1pAF+nQ06VxYbETqEUyUZ37FqVGFdmU+tPjvLOfB0z0ufycenQSXJCnJB797yJMdqWlweAo9QmYyPFmGoPrqWVaIc/jA6b9JwMMY/Vb8SsYcBlvs3DxSfV84m27BNWb1w4Ai/P4D root@centos7.localdomain
EOF
rm -rf /etc/yum.repos.d/*
cat > /etc/yum.repos.d/base.repo <<EOF
[base]
name=base
baseurl=file:///misc/cd
gpgcheck=0
EOF
%end
4 配置dhcp服务
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
[root@centos7 tftpboot]#cat /etc/dhcp/dhcpd.conf
option domain-name “magedu.org”;
option domain-name-servers 114.114.114.114,1.1.1.1;
option routers 192.168.30.200;
default-lease-time 86400;
max-lease-time 100000;
subnet 192.168.30.0 netmask 255.255.255.0 {
        range 192.168.30.10 192.168.30.100;
        option routers 192.168.30.254;
        option domain-name-servers 8.8.8.8;
        next-server 192.168.30.7;
        filename “pxelinux.0”;
}
systemctl start dhcpd
5 准备PXE相关文件
rpm -ql syslinux
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /misc/cd/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /misc/cd/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title  Auto Install CentOS
label desktop
  menu label Install ^Desktop CentOS 7
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.30.7/ksdir/7/ks7_desktop.cfg
label mini
  menu label Install ^Mini CentOS 7
  kernel vmlinuz
  append initrd=initrd.img ks=http://192.168.30.7/ksdir/7/ks7_mini.cfg
label local
  menu default
  menu label Boot from ^local drive
  localboot 0xffff
menu end
[root@centos7 tftpboot]#tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── initrd.img
├── menu.c32
├── pxelinux.0
├── pxelinux.cfg
│?? └── default
└── vmlinuz
6 客户端测试安装
实验:在centos7实现PXE安装centos6,7
0 selinux ,firewall 关闭
1 安装包
yum install dhcp tftp-server httpd syslinux
systemctl enable dhcpd httpd tftp.socket
systemctl start httpd
2 准备YUM源
mkdir /var/www/html/centos/{6,7}/ -pv
vim /etc/fstab 加下面行
/dev/sr0         /var/www/html/centos/7    iso9660 defaults        0 0
/dev/sr1         /var/www/html/centos/6    iso9660 defaults        0 0
mount -a
df
3 准备ks文件
mkdir /var/www/html/ksdir/{6,7} -pv
cp /root/anaconda-ks.cfg  /var/www/html/ksdir/7/ks7_desktop.cfg
chmod +r /var/www/html/ksdir/7/ks7_desktop.cfg
[root@centos7 tftpboot]#tree /var/www/html/ksdir/
/var/www/html/ksdir/
├── ks6_mini.cfg
└── ks7_desktop.cfg
4 配置dhcp服务
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
[root@centos7 tftpboot]#cat /etc/dhcp/dhcpd.conf
option domain-name “magedu.org”;
option domain-name-servers 114.114.114.114,1.1.1.1;
option routers 192.168.30.200;
default-lease-time 86400;
max-lease-time 100000;
subnet 192.168.30.0 netmask 255.255.255.0 {
        range 192.168.30.10 192.168.30.100;
        option routers 192.168.30.254;
        option domain-name-servers 8.8.8.8;
        next-server 192.168.30.17;
        filename “pxelinux.0”;
}
systemctl start dhcpd
5 准备PXE相关文件
rpm -ql syslinux
mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/centos{6,7}
cp  /var/www/html/centos/7/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7/
cp  /var/www/html/centos/6/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6/
cp /var/www/html/centos/7/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
cat /var/lib/tftpboot/pxelinux.cfg/default
cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title www.magedu.com
label centos7
  menu label ^Install  Desktop CentOS  7
  kernel centos7/vmlinuz
  append initrd=centos7/initrd.img ks=http://192.168.30.17/ksdir/ks7_desktop.cfg
label centos6
  menu label install ^Mini CentOS 6
  menu default
  kernel centos6/vmlinuz
  append initrd=centos6/initrd.img ks=http://192.168.30.17/ksdir/ks6_mini.cfg
label local
  menu label Boot from ^local drive
  localboot 0xffff
menu end
tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── centos6
│?? ├── initrd.img
│?? └── vmlinuz
├── centos7
│?? ├── initrd.img
│?? └── vmlinuz
├── menu.c32
├── pxelinux.0
└── pxelinux.cfg
    └── default
3 directories, 7 files
6 客户端测试安装
实验:实现cobbler安装
1 安装包
yum install cobbler(EPEL) dhcp
systemctl enable cobblerd dhcpd httpd tftp
systemctl start cobblerd httpd tftp
2 cobbler check
3 vim /etc/cobbler/settings
server:cobberserverip
next_server:cobberserverip
defaut_password_cryptd: “xxxxxxxxxx”   #openssl passwd -1 生成口令
manage_dhcp:1
4 cobber get-loaders 联网
cobbler sync
5 vim /etc/cobbler/dhcp.template
subnet 192.168.30.0 netmask 255.255.255.0
range dynamic-bootp 192.168.30.10 192.168.30.200;
cobbler sync
systemctl restart dhcpd
6
/dev/sr0         8490330  8490330         0 100% /mnt/cdrom0
/dev/sr1         6049912  6049912         0 100% /mnt/cdrom1
cobbler import –path=/mnt/cdrom0 –name=CentOS_7.4-x86_64   –arch=x86_64
cobbler import –path=/mnt/cdrom1 –name=CentOS_6.9-x86_64   –arch=x86_64
cobbler distro list
7
#cat ks6_mini.cfg
url –url=$tree
cp ks7_desktop.cfg  ks6_mini.cfg    /var/lib/cobbler/kicstarts/
cobbler profile add –name=CentOS_7.4-x86_64_Desktop –distro=CentOS_7.4-x86_64 –kickstart=/var/lib/cobbler/kicstarts/ks7_desktop.cfg
cobbler profile add –name=CentOS_6.9-x86_64_Mini –distro=CentOS_6.9-x86_64 –kickstart=/var/lib/cobbler/kicstarts/ks6_mini.cfg
删除自带的配置
cobbler profile remove –name=CentOS_7.4-x86_64
cobbler profile remove –name=CentOS_6.9-x86_64
8 web实现
yum install cobbler-web
systemctl restart httpd
htdigest -c /etc/cobbler/users.digest Cobbler test1
https://cobberserverip/cobbler_web/
QQ截图20180525193902

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99329

发表评论

登录后才能评论

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1823388528@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班