hostnamectl set-hostname workstation.example.com(重新開機虛拟機可顯示修改後的主機名)
systemctl stop firewall
systemctl disable firewall
selinux:vi /etc/selinux/config
将selinux=enforcing改為selinux=disabled(也可通過setenforce 0直接設定)
右下角連接配接CD光牒
mkdir -p /var/ftp/pub
vim /etc/fstab
添加挂載:/dev/sr0 /var/ftp/pub iso9660 defaults 0 0
mount -a
編輯網卡配置:vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
将第二行改為bootproto="static"
并在後面添加ipaddr=192.168.46.134
neymask=255.255.255.0
gateway=192.168.46.2
dns1=8.8.8.8
重新開機網絡:systemctl restart network
yum repolist
配置yum源:vim /etc/yum.repos.d/epel.repo
在虛拟網絡編輯器裡選擇nat模式并設定不使用dhcp為虛拟機配置設定位址
安裝dhcp并編輯其配置檔案:yum -y install dhcp
vim /etc/dhcp/dhcpd.conf
在檔案裡添加subnet 192.168.46.0
netmask 255.255.255.0
{range dynamic-bootp 192.168.46.100 192.168.46.200;
option routers 192.168.46.2;
option domain-name-servers 8.8.8.8;
default-lease-time 21600;
max-lease-time 43200;next-server 192.168.46.134
filename "pxelinux.0"
}
重新開機dhcp:systemctl restart dhcpd
設定開機自啟:systemctl enable dhcpd
#安裝tftp服務
yum install xinetd -y
yum -y install tftp-server(tftp服務) tftp(tftp協定) syslinux-tftpboot(tftp可以啟動工具)
vim /etc/xinetd.d/tftp
#編輯tftp配置檔案
disable = yes 改為no
#複制pxeboot下的鏡像檔案,核心檔案到
cd /var/ftp/pub/p_w_picpaths/pxeboot
cp -a initrd.img /var/lib/tftpboot/
cp -a vmlinuz /var/lib/tftpboot/
#建立pxelinux.cfg目錄,并在其目錄下建立一個名為default的檔案
mkdir /var/lib/tftpboot/pxelinux.cfg
vim /var/lib/tftpboot/pxelinux.cfg/default
default linux //預設是linux
prompt 1
timeout 60 //逾時時間
display boot.msg //顯示開機圖檔
label linux //标簽
kernel vmlinuz//核心
append initrd=initrd.img text ks=http://192.168.40.100/ks/ks.cfg //鏡像所在路徑,通路格式,通路路徑
#重新開機xinetd服務
systemctl restart xinetd;systemctl enable xinetd
#安裝http服務
yum install httpd -y
#啟動http服務
systemctl restart httpd
systemctl enable httpd
#建立名在ks的目錄
mkdir /var/www/html/ks
#複制anaconda-ks.cfg到剛剛建立的ks目錄下
cp -a anaconda-ks.cfg /var/www/html/ks/ks.cfg
#編輯ks.cfg的檔案
vim /var/www/html/ks/ks.cfg
把cdrom改為
url --url=ftp://192.168.40.100/pub
install
#給剛建立的ks.cfg檔案賦予讀的權限
chmod +r /var/www/html/ks/ks.cfg
#安裝ftp服務
yum install vsftpd -y
#重新開機ftp服務
systemctl restart vsftpd;systemctl enable vsftpd
#驗證
#添加3台虛拟機,分别命名為server1,server2,database
#分别在剛建立的3台虛拟機上做如下操作
#關掉防火牆以及selinux
#配置靜态ip,ip位址分别為192.168.40.201 192.168.40.202 192.168.40.203
#添加epel yum源
scp /etc/yum.repos.d/epel.repo [email protected](202/203):/etc/yum.repos.d/
#分别在3台虛拟機上檢視剛添加的epel源
#更新為最新的yum源
yum update -y