Centos7使用pxe安装KVM虚拟机
Centos7使用pxe安装KVM虚拟机
一、安装服务所需的软件
[root@localhost ~]yum install nginx dhcp vsftpd syslinux -y
[root@localhost ~]mount -p loop -t iso9660 images/CentOS-7-x86_64-DVD-1804.iso /mnt #提前上传镜像
[root@localhost ~]systemctl start vsftpd
[root@localhost ~]systemctl enable vsftpd
二、安装DHCP服务器
[root@localhost ~]cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/ #复制示例配置文件
[root@localhost ~]cd /etc/dhcp/
[root@localhost dhcp]#rm -f dhcpd.conf
[root@localhost dhcp]#mv dhcpd.conf.example dhcpd.conf
[root@localhost dhcp]# egrep -v "^#|^$" dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 172.16.150.0 netmask 255.255.255.0 { #网段
range 172.16.150.230 172.16.150.232 ; #地址池
option routers 172.16.150.254; #网关
option domain-name-servers 172.16.160.20,172.16.160.21; #dns服务器
}
[root@localhost ~]cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/
[root@localhost ~]vi /etc/systemd/system/dhcpd.service
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid <your_interface_name(s)>
[root@localhost ~]systemctl --system daemon-reload
[root@localhost ~]systemctl restart dhcpd.service #启动服务
三、创建tftp相关目录和拷贝内核镜像及文件
[root@localhost ~]mkdir /var/tftp
[root@localhost ~]cp /mnt/images/pxeboot/initrd.img /var/tftp/
[root@localhost ~]cp /mnt/images/pxeboot/vmlinuz /var/tftp/
[root@localhost ~]rpm -ql syslinux | grep "pxelinux.0"
[root@localhost ~]cp /usr/share/syslinux/pxelinux.0 /var/tftp/
[root@localhost ~]mkdir /var/tftp/pxelinux.cfg/
四、创建菜单配置文件
[root@localhost ~]# vim /var/tftp/pxelinux.cfg/default
default linux
prompt 1
timeout 60
display boot.msg
label linux
kernel vmlinuz
append initrd=initrd.img text ks=http://172.16.150.32/ks.cfg net.ifnames=0 biosdevname=0 ksdevice=eth0
#172.16.150.32是http服务器地址,我们使用http的方式下载ks.cfg及软件包,因为7的网卡名称不在是eth0,1,2而改成enoxx的格式,新的方式不但长,而且难记。ksdevice=eth0表示所有网卡名称从eth0开始,如果有多快,依次增加
五、配置nginx下载、安装配置
[root@localhost ~]#cd /usr/share/nginx/html/
[root@localhost html]#mkdir Centos7_4 #创建软件包下载目录
[root@localhost html]#umont /mnt
[root@localhost html]#mount -p loop -t iso9660 /root/images/CentOS-7-x86_64-DVD-1804.iso /usr/share/nginx/html/Centos7_4/ [root@localhost html]# vim /usr/share/nginx/html/ks.cfg #具体自定义,文章结尾有份示例文件,也可以使用system-config-kickstart命令生成,命令可以通过yum安装
.....
url --url="http://172.16.150.32/Centos7_4" #在ks文件中指定下载的地址
.....
#如果想打开nginx目录浏览功能,可以添加如下配置:
[root@localhost html]# cat /etc/nginx/nginx.conf
.....
server {
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
.......
#如果想在线浏览ks文件,则添加如下配置
vim /etc/nginx/mime.types
text/plain cfg; #添加该行
六、注意事项
1.安装的系统内容不得小于2G,否则报如下错误:
dracut-initqueue[552]: /sbin/dmsquash-live-root: line 273: printf: write error: No space left on device
2.boot分区不得小于200M,否则或导致kickstart进程暂停,需要手动确认才会继续
#示例文件
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $$pTG9CQO9$MmB9KurbyQtyAeqJm7Hrbh.kl1IGUhQK35Ce027/lGYq6TkNYHyUd6WYqluhUVnEQoPzruTbqm7HFO8CyZB0r/ #root密码,加密方法参考http://clavinli.github.io/2014/11/14/linux-command-hash-root-password-in-kickstart/
user --groups=admin --name=admin
user --groups=log --name=log url --url="http://172.16.150.32/Centos7_4/" #软件包下载地址
# System language
lang zh_CN
# Firewall configuration
firewall --enabled --http --ftp --ssh --port=:tcp,:tcp,:tcp #可以禁用,或者开启需要放行的端口或者服务
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx # Network information
network --bootproto=dhcp --device=eth0 --gateway=172.16.150.254 --onboot=on
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size= #不得少于200M
part swap --fstype="swap" --size=
part / --fstype="xfs" --grow --size= #1代表使用所有的剩余磁盘空间
%packages #这段表示你要安装的软件包,@表示选择的包组,最前面使用横杠表示取反,即不选择的包或包组。@base和@core两个包组总是被默认选择,可以不在%packages中指定它们
@Base
curl
lrzsz
%end
%post --interpreter /bin/bash
/bin/curl http://172.16.150.32/System_initialize.sh -o /root/System_initialize.sh #安装后需要做的操作,也可以是命令或者打包到脚本中执行
/bin/bash /root/System_initialize.sh
%end
ks.cfg文件
virt-install --virt-type=kvm --name "zest_machine" --location=http://172.16.150.32/Centos7_4/ --memory=4096 --vcpus=1 --disk path=/var/lib/libvirt/images/zest_machine.img,size=60 --network bridge=br0 --os-type linux --os-variant rhel7 --extra-args="ks=http://172.16.150.32/ks.cfg --autostart console=tty0 " --force &
kvm安装脚本
Centos7使用pxe安装KVM虚拟机的更多相关文章
- (亲测成功)在centos7.5上安装kvm,通过VNC远程连接并创建多台ubuntu虚拟机(ubuntu server版本)
在centos7.5上安装kvm,通过VNC远程连接并创建多台ubuntu虚拟机 前提:服务器端安装桌面版的centos系统 CentOS Linux release 7.5.1804 (Core) ...
- (转)CentOS7安装KVM虚拟机详解
原文:https://github.com/jaywcjlove/handbook/blob/master/CentOS/CentOS7%E5%AE%89%E8%A3%85KVM%E8%99%9A%E ...
- centos7安装kvm虚拟机
一 centos7安装kvm虚拟机 1.验证CPU是否支持KVM 结果中有vmx(Intel)或svm(AMD)字样,就说明CPU的支持的. [root@centos ~]# egrep '(vmx| ...
- CentOS 7.5 安装KVM虚拟机(Windows)
一.KVM环境搭建1.检测系统是否支持cat /proc/cpuinfo | egrep 'vmx|svm' KVM是基于x86虚拟化扩展(Intel VT 或者 AMD-V)技术的虚拟机软件,所以查 ...
- vmware安装kvm虚拟机
1. 概述 本篇博客主要使用运行在win10专业版上的vmware workstation 15 pro虚拟化软件,安装centos7.7最小化系统,并在centos7上安装kvm虚拟机,实现快速创建 ...
- 6、安装kvm虚拟机
6.1.虚拟机开启虚拟化: 6.2.检查linux虚拟机cpu是否开启了虚拟化: egrep -o 'vmx|svm' /proc/cpuinfo vmx 6.3.安装kvm管理和安装kvm虚拟机的软 ...
- 11.安装KVM虚拟机
安装KVM虚拟机是一大难题,不按照虚拟机物理机128G内存和强劲的CPU无法充分利用.也不便于后面的jenkins自动部署.安装KVM虚拟机过程我是借鉴了网上下载的马哥linux KVM那块的内容 ...
- 命令行安装kvm虚拟机、桥接网络、用virt-manager管理
宿主机CentOS Linux release 7.2.1511 (Core),内核3.10.0-327.el7.x86_64 1.配置宿主机网络桥接 想让虚拟机有自己的ip且外网可访问,需要在安装虚 ...
- centos6.2安装kvm虚拟机
http://www.wenzizone.com/2012/03/06/centos_6-2_install_kvm.html KVM虚拟机简介 kernel-based Virtual Machin ...
随机推荐
- 为什么 PCB 生产时推荐出 Gerber 给工厂?
为什么 PCB 生产时推荐出 Gerber 给工厂? 事情是这样的,有一天电工王工,画了一块 PCB,发给 PCB 板厂. 过了几天 PCB 回来了,一看不对呀,这里的丝印怎么少了,那里怎么多了几条线 ...
- linux centos 安装php的memcache扩展
一.centos6.5 yum安装php的memcache扩展 搜索memcache yum search memcache 有了,现在可以安装了 yum -y install memcached m ...
- workerman的使用实践--并与solaris通信
Workerman与solarisTCP通信测试 1. 笔记本win7,tcp_test.php 2. solaris,test.c 编译命令: gcc test.c –o test –lsoc ...
- 高级java必会系列一:常用线程池和调度类
众所周知,开启线程2种方法:第一是实现Runable接口,第二继承Thread类.(当然内部类也算...)常用的,这里就不再赘述. 一.线程池 1.newCachedThreadPool (1)缓存型 ...
- 第一个appium的Demo
原文来自:一颗糖果 http://www.cnblogs.com/linglingyuese/articles/8418311.html 一.环境搭建 略(后期补) 二.创建一个测试apk包的项目 ...
- Python数据库编程
http://lizhenliang.blog.51cto.com/7876557/1874283 http://blog.itpub.net/22664653/list/1/?cid=86471
- system.Data.Entity.Infrastructure.DbUpdateConcurrencyException: Store update, insert, or delete statement affected an unexpected number of rows (0) 问题
页面控件没有做限制.提交后还可以继续点击,造成了在短时间内的多次请求.查看日志两次错误在200ms之内. 错误信息 system.Data.Entity.Infrastructure.DbUpdate ...
- Mysql 性能优化6【重要】 索引优化
b tree索引 myisam 是通过物理位置来查找引用行的 innodb 是通过主键来查找引用行的 索引优化策略 b-tree索引对数据长度有限制,所以text等比较长的列可以建立前缀索引 btre ...
- Socket.io各个发送消息的含义【发送对象范围】
Socket.io各个发送消息的含义 // send to current request socket client socket.emit('message', "this is a ...
- 数据仓库3NF基础理论和实例
一.引言 最近在梳理大数据模式下的数据仓库数据模型,花了点时间,系统的回顾一下传统数据仓库数据模型设计的理论,作为笔记分享给大家,很多资料来自互联网和读过的数据仓库理论和实践相关的熟悉,无剽窃之心,共 ...