Kickstart;无人值守安装方式,配置文件的问答安装
PXE+kickstart部署
挂载
[root@linux-node1 ~]#mount /dev/cdrom /mnt ##createrepo可以创建仓库 [root@linux-node1 ~]#yum install -y httpd createrepo [root@linux-node1 ~]#mkdir /var/www/html/CentOS-7.1-x86_64
把仓库复制到本地
[root@linux-node1 ~]#cp -a /mnt/* /var/www/html/CentOS-7.1-x86_64/
创建yum仓库
createrepo -pdo/var/www/html/CentOS-7.1-x86_64/ /var/www/html/CentOS-7.1-x86_64/
安装tftp dhcp xinetd
[root@linux-node1 ~]#yum install -y tftp-server dhcp xinetd [root@linux-node1 ~]#vim /etc/xinetd.d/tftp ##把tftp打开 disable = no
上传kickstart的配置文件
[root@linux-node1 ~]#cd /var/www/html/CentOS-7.1-x86_64/
测试能不能访问
[root@linux-node1 ~]#curl --head http://10.0.0.7/CentOS-7.1-x86_64/CentOS-7.1-x86_64.cfg HTTP/1.1 200 OK
应答文件
[[email protected]_64]# cat CentOS-7.1-x86_64.cfg #KickstartConfigurator by Reid #platform=x86, AMD64,or Intel EM64T #System language lang en_US #System keyboard keyboard us #Sytem timezone timezone Asia/Shanghai #Root password #rootpw --iscrypted$default_password_crypted rootpw --iscrypted$1$ops-node$7hqdpgEmIE7Z0RbtQkxW20 #Use text mode install text #Install OS instead ofupgrade install #Use NFS installationMedia #url --url=$tree url --url=http://10.0.0.7/CentOS-7.1-x86_64 #System bootloaderconfiguration bootloader--location=mbr #Clear the Master BootRecord zerombr #Partition clearinginformation clearpart --all--initlabel #Disk partitioninginformation part /boot --fstypexfs --size 1024 --ondisk sda part swap --size 16384--ondisk sda part / --fstype xfs--size 1 --grow --ondisk sda #System authorizationinfomation auth --useshadow --enablemd5 #Network information #$SNIPPET('network_config') network--bootproto=dhcp --device=eth0 --onboot=on # Reboot afterinstallation reboot #Firewallconfiguration firewall --disabled #SELinux configuration selinux --disabled #Do not configureXWindows skipx #Package installinformation %packages @ base @ core sysstat iptraf ntp lrzsz ncurses-devel openssl-devel zlib-devel OpenIPMI-tools mysql nmap screen %end %post systemctl disable postfix.service %end
修改dhcp的配置文件
[root@linux-node1 ~]#cd /usr/share/doc/dhcp-4.1.1/ [[email protected]]# cp dhcpd.conf.sample /etc/dhcp/dhcpd.conf subnet 10.0.0.0netmask 255.255.255.0 { range dynamic-bootp 10.0.0.100 10.0.0.200; option subnet-mask 255.255.255.0; next-server 10.0.0.7; filename "pxelinux.0"; }
启动服务
[root@linux-node1 ~]#/etc/init.d/dhcpd start [root@linux-node1 ~]#/etc/init.d/httpd start [root@linux-node1 ~]#/etc/init.d/xinetd start [root@linux-node1 ~]# netstat -ntulp Active Internetconnections (only servers) Proto Recv-Q Send-QLocal Address ForeignAddress State PID/Program name tcp 0 0 :::80 :::* LISTEN 4055/httpd udp 0 0 0.0.0.0:67 0.0.0.0:* 4155/dhcpd udp 0 0 0.0.0.0:69 0.0.0.0:* 4165/xinetd
tftp 里面一些准备文件,一些组信息,内核镜像,pxelinux.0
[root@linux-node1 ~]#yum install -y syslinux [root@linux-node1 ~]#cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ ###把pxelinux.0拷贝到tftp的启动目录 [root@linux-node1 ~]#cp /mnt/isolinux/* /var/lib/tftpboot/ ###拷贝启动镜像:vmlinuz(内核) initrd.img(映像) boot.msg(启动选单) [root@linux-node1 ~]#mkdir /var/lib/tftpboot/pxelinux.cfg [root@linux-node1 ~]#cd /var/lib/tftpboot/pxelinux.cfg/ [[email protected]]# cp /mnt/isolinux/isolinux.cfg default [[email protected]]# vim default ##写一个安装的CentOS 7 label ks menu label ^AUTO CentOS 7 kernel vmlinuz append initrd=initrd.imgks=http://10.0.0.7/CentOS-7.1-x86_64/CentOS-7.1-x86_64.cfg
创建组信息
[root@linux-node1 ~]#createrepo -g `ls /var/www/html/CentOS-7.1-x86_64/repodata/*-comps.xml`/var/www/html/CentOS-7.1-x86_64/
Cobbler
可以解决Kickstart繁琐的工作,实现自动化
安装需要的包
[root@linux-node1 ~]#yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd -y [root@linux-node1 ~]#/etc/init.d/httpd restart [root@linux-node1 ~]#/etc/init.d/cobblerd start
检查
[root@linux-node1 ~]#cobbler check The following arepotential configuration items that you may want to fix:
Step 1 + 2
vim/etc/cobbler/settings server: 10.0.0.7 next_server:10.0.0.7 ###PXE的东西放置在那里 manage_dhcp: 1 ##修改成1 ,cobbler管理dhcp
Step 3
cobbler get-loaders
Step 4
[root@linux-node1 ~]#vim /etc/xinetd.d/rsync change 'disable' to'no' [root@linux-node1 ~]#/etc/init.d/xinetd restart
Step 5
vim/etc/cobbler/settings openssl passwd -1-salt 'reid' 'reid' ###第一个reid是加严,第二个是密码 default_password_crypted:"$1$reid$fXF8f078vI9J/q9XyXA8e/" [root@linux-node1 ~]#/etc/init.d/cobblerd restart ##修改settings重启 [root@linux-node1 ~]#cobbler check ###修改完需要check
Step 6
修改dchp.template,因为已经由cobbler修改
vim /etc/cobbler/dhcp.template subnet 10.0.0.0netmask 255.255.255.0 { option routers 10.0.0.2; option domain-name-servers 10.0.0.2; option subnet-mask 255.255.255.0; range dynamic-bootp 10.0.0.100 10.0.0.200; [root@linux-node1 ~]#cobbler sync ##修改完需要同步
Step 7
导入镜像
[root@linux-node1 ~]#cobbler import --path=/mnt/ --name=CentOS-7.1-x86_64 --arch=x86_64 /var/www/cobbler/ks_mirror/ ###镜像的存入位置 [root@linux-node1 ~]#cobbler list distros: ##创建一个仓库 CentOS-7.1-x86_64 profiles: ##创建一个配置 CentOS-7.1-x86_64 [root@linux-node1 ~]#cobbler profile report ##多个要指定—name Kickstart :/var/lib/cobbler/kickstarts/sample_end.ks Kernel Options : {} ###网卡要修改eth0,所以要修改kernal参数 KS文件放这里: cd /var/lib/cobbler/kickstarts/ [root@linux-node1kickstarts]# mv Cobbler-CentOS-7.1-x86_64.cfg CentOS-7.1-x86_64.cfg
添加内核参数
cobbler profile edit--name=CentOS-7.1-x86_64--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.1-x86_64.cfg cobbler profile edit--name=CentOS-7.1-x86_64 --kopts='net.ifnames=0 biosdevname=0' ##添加内核参数 cobbler sync
修改Cobbler提示
vim /etc/cobbler/pxe/pxedefault.template
用MAC地址,这里可以设定自动安装不提示先把本地
cobbler system add--name=reid --mac=00:0C:29:22:E1:9C --profile=CentOS-7.1-x86_64 --ip-address=10.0.0.111--subnet=255.255.255.0 --gateway=10.0.0.2 --interface=eth0 --static=1--hostname=reid.example.com --name-servers="114.114.114.1148.8.8.8"
找一以新机器先设置BIOS:虚拟机----》电源-----》打开电源时进入固件----》boot----》Networkboot from Intel E1000(安装完再设置回HD)
安装成功
cobbler web介面
[root@linux-node1 ~]#cat /etc/httpd/conf.d/cobbler_web.conf https://10.0.0.7/cobbler_web ##新版默认是https username:cobbler passoword:cobbler
CentOS 7一些操作变化:
1.取消ifconfig(需要安装yum install net-tools),使用ip addr 查看IP地址。
2.使用firewalld 取代 iptables。
3.系统默认编码设置文件,由/etc/sysconfig/i18n 更改为 /etc/locale.conf