Press "Enter" to skip to content

Tag: centos

CentOS虚拟化实验环境搭建

为了准备RHCE考试,我把一台i7-2600k、16G内存、120Gssd的闲置主机刷成了CentOS7.下面是具体环境搭建的细节。


首先是系统的准备工作

su

yum update -y
yum install -y epel-release
yum makecache

yum install -y bash-completion network-tool sysfsutils 
yum install -y htop vim ctags curl wget mlocate lftp
curl https://raw.githubusercontent.com/wklken/vim-for-server/master/vimrc > ~/.vimrc

配置虚拟化环境

#安装kvm
yum -y install qemu-kvm libvirt virt-install bridge-utils
yum -y install libguestfs-tools virt-top

#启动虚拟化管理服务
systemctl start libvirtd
systemctl enable libvirtd

#开启kvm嵌套
echo "options kvm-intel nested=1" >> /etc/modprobe.d/kvm-intel.conf

#重新加载kvm模块
modprobe -r kvm_intel
modprobe kvm_intel

#关闭防火墙
systemctl stop firewalld
systemctl disable firewalld

#关闭selinux
vi /etc/selinux/config 
>SELINUX=disabled

reboot

Ubuntu下网络部署CentOS

首先安装DHCP服务

sudo apt install vsftp isc-dhcp-server pxelinux tftpd-hpa

增加DHCP服务指定网卡

sudo vi /etc/default/isc-dhcp-server 
interface="enp0s25"

添加DHCP作用域

sudo vi /etc/dhcp/dhcpd.conf
 subnet 172.16.66.0 netmask 255.255.255.0{
     range 172.16.66.10 172.16.66.100;
     option subnet-mask 255.255.255.0;
     option routers 172.16.66.6;
     option broadcast-address 172.16.66.255;
     filename "pxelinux.0";                                                  
     next-Server 172.16.66.6;
 } 

启动DHCP服务

sudo service isc-dhcp-server start
sudo systemctl status isc-dhcp-server

配置tftp服务

sudo vi /etc/default/tftpd-hpa
#在文件行末添加
RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot" 
#然后启动tftp服务
sudo service tftpd-hpa start
sudo systemctl status tftpd-hpa

复制安装文件

cd /var/lib/tftpboot/
sudo mkdir ubuntu centos pxelinux.cfg
cd /usr/lib/syslinux/modules/bios/
sudo cp vesamenu.c32 ldlinux.c32 libutil.c32 /var/lib/tftpboot
cd -
sudo cp /usr/lib/PXELINUX/pxelinux.0 ./

将相应iso解压至/srv/ftp/centos目录
将/srv/ftp/centos/images/pxeboot/目录复制到/var/lib/tftpboot/目录下。
编辑pxelinux.cfg/default文件

default vesamenu.c32
timeout 100
prompt localboot
noescape 1

menu title ##### PXE Deploy Menu #####

Label 1
    menu label ^1 Install CentOS 7.3
    kernel centos/vmlinuz
    initrd centos/initrd.img quiet
    append repo=ftp://172.16.66.6/centos devfs=nomount

Label 2                                                                    
     menu label ^2 Boot from LocalDrive
     localboot


Tips:
1. 需要注意的是centos7版本以前的需要使用method来制定安装源,现在要使用repo来指定,否则会报错。
2. 不需要安装inetutils-inetd和配置xinetd服务了,同时启动xinet和tftpd会出现占用IP Address的报错导致tftp无法启动。