概述
实验环境:
本次实验使用两台vmware虚拟机
kickstart服务器系统:RHEL7.0 64位
ip地址 192.168.10.20 子网掩码 255.255.255.0
网关: 192.168.10.254 dns服务器:192.168.10.254
实现的目的是:使用kickstart服务全自动安装RHEL7.0系统
具体实现过程如下
一、SELinux和防火墙
临时关闭 SELinux
[root@localhost ~]#setenforce 0
添加TCP端口80 和UDP端口69到firewalld防火墙例外
[root@localhost ~]# firewall-cmd --zone=public --add-service=http success
[root@localhost ~]# firewall-cmd --zone=public --add-service=tftp success
二、挂载iso镜像
先新建一个挂载光盘的目录
[root@localhost ~]# mkdir -p /var/www/html/os
挂载光盘
[root@localhost ~]# mount /dev/cdrom /var/www/html/os mount: /dev/sr0 is write-protected, mounting read-only
添加以下代码,实现开机自动挂载光盘
[root@localhost ~]# vim /etc/fstab /dev/cdrom /var/www/html/os iso9660 defaults 0 0
设置本地yum源,便于安装软件包
[root@localhost ~]# vim /etc/yum.repos.d/local-media.repo [Local] name=RHEL Software baseurl= gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
三、安装Web服务,并设置开机自启
[root@localhost ~]# yum -y install httpd [root@localhost ~]# systemctl enable httpd ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service' [root@localhost ~]# systemctl start httpd
访问网站测试
四、安装并配置tftp服务
安装tftp软件
[root@localhost ~]# yum -y install tftp tftp-server
修改tftp配置文件 disable 行yes改成no
[root@localhost ~]# vim /etc/xinetd.d/tftp
service tftp { socket_type = dgram protocol = udp wait = yes user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 }
重启tftp服务
[root@localhost ~]# systemctl restart xinetd [root@localhost ~]# cp /var/www/html/os/p_w_picpaths/pxeboot/vmlinuz /var/lib/tftpboot/ cp /var/www/html/os/p_w_picpaths/pxeboot/initrd.img /var/lib/tftpboot/ mkdir -p /var/lib/tftpboot/pxelinux.cfg
复制启动菜单
cp /var/www/html/os/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
修改启动菜单
default linux 此行需要修改 timeout 600 prompt 0 此行需要添加 display boot.msg menu clear menu background splash.png menu title Red Hat Enterprise Linux 7.0 menu vshift 8 menu rows 18 menu margin 8 menu helpmsgrow 15 menu tabmsgrow 13 menu color border * #00000000 #00000000 none menu color sel 0 #ffffffff #00000000 none menu color title 0 #ff7ba3d0 #00000000 none menu color tabmsg 0 #ff3a6496 #00000000 none menu color unsel 0 #84b8ffff #00000000 none menu color hotsel 0 #84b8ffff #00000000 none menu color hotkey 0 #ffffffff #00000000 none menu color help 0 #ffffffff #00000000 none menu color scrollbar 0 #ffffffff #ff355594 none menu color timeout 0 #ffffffff #00000000 none menu color timeout_msg 0 #ffffffff #00000000 none menu color cmdmark 0 #84b8ffff #00000000 none menu color cmdline 0 #ffffffff #00000000 none menu tabmsg Press Tab for full configuration options on menu items. menu separator # insert an empty line label linux menu label ^Install Red Hat Enterprise Linux 7.0 kernel vmlinuz append initrd=initrd.img ks=http://192.168.10.20/ks.cfg 设置ks应答文件的路径 label check menu label Test this ^media & install Red Hat Enterprise Linux 7.0 menu default kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0x20Server.x86_64 rd.live.check quiet menu separator # insert an empty line menu begin ^Troubleshooting menu title Troubleshooting label vesa menu indent count 5 menu label Install Red Hat Enterprise Linux 7.0 in ^basic graphics mode text help Try this option out if you're having trouble installing Red Hat Enterprise Linux 7.0. endtext kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0x20Server.x86_64 xdriver=vesa nomodeset quiet label rescue menu indent count 5 menu label ^Rescue a Red Hat Enterprise Linux system text help If the system will not boot, this lets you access files and edit config files to try to get it booting again. endtext kernel vmlinuz append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0x20Server.x86_64 rescue quiet label memtest menu label Run a ^memory test text help If your system is having issues, a problem with your system's memory may be the cause. Use this utility to see if the memory is working correctly. endtext kernel memtest menu separator # insert an empty line label local menu label Boot from ^local drive localboot 0xffff menu separator # insert an empty line menu separator # insert an empty line label returntomain menu label Return to ^main menu menu exit menu end
:wq! 强制保存
修改default文件的权限
[root@localhost ~]# chmod 644 /var/lib/tftpboot/pxelinux.cfg/default
安装syslinux软件包
[root@localhost ~]# yum -y install syslinux
复制引导程序到tftp的根目录
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
五、安装dhcp服务并配置
[root@localhost ~]# yum install dhcp
复制配置dhcp服务配置文件
[root@localhost ~]# cat /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example >/etc/dhcp/dhcpd.conf
修改dhcp服务的配置文件
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf ddns-update-style interim; log-facility local7; subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.50 192.168.10.60; option routers 192.168.10.254; option domain-name "mapsic.org"; option domain-name-servers 192.168.10.254; default-lease-time 6000; max-lease-time 12000; next-server 192.168.10.20; tftp服务器地址 filename "pxelinux.0"; tftp根目录下的文件名 }
使用dhcpd命令测试dhcp配置文件是否正确
[root@localhost ~]# dhcpd Internet Systems Consortium DHCP Server 4.2.5 Copyright 2004-2013 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file Wrote 0 leases to leases file. Listening on LPF/eno16777736/00:0c:29:9f:5d:69/192.168.10.0/24 Sending on LPF/eno16777736/00:0c:29:9f:5d:69/192.168.10.0/24 Sending on Socket/fallback/fallback-net There's already a DHCP server running. This version of ISC DHCP is based on the release available on ftp.isc.org. Features have been added and other changes have been made to the base software release in order to make it work better with this distribution. Please report for this software via the Red Hat Bugzilla site: http://bugzilla.redhat.com exiting.
设置dhcp服务开机自启,并启动dhcp服务
[root@localhost ~]# systemctl enable dhcpd ln -s '/usr/lib/systemd/system/dhcpd.service' '/etc/systemd/system/multi-user.target.wants/dhcpd.service' [root@localhost ~]# systemctl start dhcpd
六、配置kickstart服务
安装软件包
[root@localhost ~]# yum -y install system-config-kickstart
为简单操作,可以使用kickstart图形界面配置,并保存应答文件到网站根目录下
以下是ks应答文件(服务器最小化安装,防火墙允许http和ssh服务,设置root密码等)
[root@localhost ~]# vim ks.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Install OS instead of upgrade install # Keyboard layoutskeyboard 'us' # Reboot after installation reboot # Root password rootpw --iscrypted $1$TG26OsQl$I7Sv8CUE2ISkVXz.5mHWT0 # System timezone timezone Asia/Shanghai # Use network installationurl --url= # System language lang en_US # Firewall configuration firewall --enabled --http --ssh # Network information network --bootproto=dhcp --device=eth0 # System authorization information auth --useshadow --passalgo=sha512 # Use text mode install text firstboot --disable # SELinux configuration selinux --enforcing # System bootloader configuration bootloader --location=mbr # Clear the Master Boot Recordzerombr # Partition clearing information clearpart --all --initlabel # Disk partitioning information part /boot --fstype="xfs" --size=200 part / --fstype="xfs" --size=20480 part swap --fstype="swap" --size=2048 %packages @core %end
七、从网络安装服务器系统
虚拟化开机后按F2,设置从网卡启动,启动界面如下面
文本模式安装系统
安装完成后自动重启系统
以上是使用kickstart安装RHEL7的步骤,第一次在51cto上写博客,欢迎大家指点,谢谢!
转载于:https://blog.51cto.com/mapsic/1661438
最后
以上就是怕孤单棒球为你收集整理的使用kickstart服务全自动安装RHEL7.0系统的全部内容,希望文章能够帮你解决使用kickstart服务全自动安装RHEL7.0系统所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复