通過網(wǎng)絡(luò)去裝系統(tǒng),如何部署配置
成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)與策劃設(shè)計(jì),冠縣網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:冠縣等地區(qū)。冠縣做網(wǎng)站價(jià)格咨詢:13518219792前言
部署PXE遠(yuǎn)程安裝服務(wù)
實(shí)現(xiàn)Kickstart無人值守安裝
裸機(jī)插網(wǎng)卡,沒有IP地址,所以服務(wù)器要先運(yùn)行DHCP服務(wù),給客戶機(jī)分配地址,即服務(wù)端第一步先安裝引導(dǎo)程序
引導(dǎo)程序,指導(dǎo)客戶機(jī)去服務(wù)端下載相關(guān)安裝文件
引導(dǎo)程序放在TFTP服務(wù)器上,UDP協(xié)議69端口,傳輸速度快,文本小 第二步
映像文件放在VSFTPD上,tcp21和20端口 第三步
openstack
daiwops
[root@localhost pxelinux.cfg]# yum install tftp-sever -y '安裝tftp服務(wù)軟件'
[root@localhost pxelinux.cfg]# vim /etc/xinetd.d/tftp '修改tftp配置'
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
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
[root@localhost pxelinux.cfg]# yum install dhcp '安裝dhcp服務(wù)'
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.1 192.168.100.200;
option routers 192.168.100.100;
option domain-name-servers 8.8.8.8;
next-server 192.168.100.100; '指定TFTP服務(wù)器地址'
filename "pxelinux.0"; '指定要下載的引導(dǎo)程序文件'
}
[root@localhost pxelinux.cfg]# systemctl start dhcpd '開啟'
[root@localhost pxelinux.cfg]# systemctl enable dhcpd '自啟動(dòng)'
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default '編輯default'
default auto '默認(rèn)共享'
prompt 1 '啟動(dòng)時(shí)間'
label auto
kernel vmlinuz '內(nèi)核'
append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg
追加 進(jìn)程 初始化文件 方法 定位 kickstart 位置
label linux text '文本模式安裝'
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.100/centos7
label linux rescue '進(jìn)入救援模式'
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
root@localhost ~]# vim /var/ftp/ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL6,
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6qKSDsgs$eaNnQ18jrgccQjSX95B9Z.
# Use network installation
url --url="ftp://192.168.100.100/centos7" '網(wǎng)絡(luò)安裝源'
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=ens33
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=none
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=512
part /home --fstype="xfs" --size=4096
part swap --fstype="swap" --size=4096
part / --fstype="xfs" --grow --size=1
%packages '定制的軟件包組'
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
%end
root@localhost ~]# cp /root/ks.cfg /var/ftp/ks.cfg
root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default '編輯default'
default auto '默認(rèn)共享'
prompt 0 '取消用戶時(shí)間'
label auto
kernel vmlinuz '內(nèi)核'
append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg
追加 進(jìn)程 初始化文件 方法 定位 應(yīng)答文件kickstart 位置
思路:pxe自動(dòng)部署
DHCP
為客戶機(jī)自動(dòng)獲取IP地址,引導(dǎo)定位TFTP文件位置
命令:
next-server TFTP的IP
fliename “pxelinux.0”
TFTP 安裝tftp-server包,第一個(gè)安裝syslinux(包含pxelinux.0)' 引導(dǎo)程序
? 第二個(gè)壓縮內(nèi)核 vmlinxuz (iso鏡像文件中獲?。?/p>
? 第三個(gè)初始化文件 initrd.img (iso鏡像文件中獲?。?/p>
? 第四個(gè)默認(rèn)配置文件 default (自建文件:三個(gè)模式,默認(rèn)是auto,指引FTP鏡像系統(tǒng)文件位置)
vsftpd 系統(tǒng)鏡像 無人值守安裝配置模板 (ks.cfg)
新加一塊網(wǎng)卡,設(shè)置僅主機(jī)模式,主機(jī)網(wǎng)卡用來安裝服務(wù)端去連接裸機(jī),NAT網(wǎng)卡用來下載軟件包
[root@localhost named]# ifconfig 查看網(wǎng)卡
ens33: flags=4163 mtu 1500
inet 192.168.139.131 netmask 255.255.255.0 broadcast 192.168.139.255 '可以上網(wǎng)的網(wǎng)卡'
inet6 fe80::413b:c9ad:e0e:1afc prefixlen 64 scopeid 0x20
ether 00:0c:29:d6:c0:8a txqueuelen 1000 (Ethernet)
RX packets 638059 bytes 939850586 (896.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 157948 bytes 9731567 (9.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens36: flags=4163 mtu 1500 '新增加的網(wǎng)卡,需要重新配置'
inet6 fe80::351b:fad2:2b7c:7ac2 prefixlen 64 scopeid 0x20
ether 00:0c:29:d6:c0:94 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13 bytes 2334 (2.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost named]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens36
'把ens33的網(wǎng)卡作為模板復(fù)制修改為ens36'
[root@localhost named]# vim /etc/sysconfig/network-scripts/ifcfg-ens36
'修改配置'
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" '網(wǎng)卡設(shè)置為靜態(tài)'
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens36" '名稱改為36'
DEVICE="ens36"
ONBOOT="yes"
IPADDR=192.168.100.100 '配置IP地址'
NETMASK=255.255.255.0 '配置子網(wǎng)掩碼'
GATEWAY=192.168.100.1 '配置網(wǎng)關(guān)'
[root@localhost named]# systemctl restart network '重啟網(wǎng)卡'
[root@localhost named]# ifconfig '再次查看'
ens33: flags=4163 mtu 1500
inet 192.168.139.131 netmask 255.255.255.0 broadcast 192.168.139.255
ens36: flags=4163 mtu 1500
inet 192.168.100.100 netmask 255.255.255.0
'成功'
1.
[root@localhost named]# systemctl stop firewalld.service 關(guān)閉防火墻
[root@localhost named]# setenforce 0 '關(guān)閉增強(qiáng)'
[root@localhost named]# rpm -q dhcp '查看dhcp是否安裝'
dhcp-4.2.5-77.el7.centos.x86_64
[root@localhost named]# yum install dhcp -y '沒有安裝的使用這個(gè)命令'
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.zju.edu.cn
* extras: mirrors.zju.edu.cn
* updates: mirrors.zju.edu.cn
軟件包 12:dhcp-4.2.5-77.el7.centos.x86_64 已安裝并且是最新版本
無須任何處理
[root@localhost named]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
'復(fù)制模板到/etc/dhcp.dhcpd下'
[root@localhost named]# vim /etc/dhcp/dhcpd.conf '編輯'
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.1 192.168.100.200;
option routers 192.168.100.100;
option domain-name-servers 8.8.8.8;
next-server 192.168.100.100; '指定TFTP服務(wù)器'
filename "pxelinux.0"; '指定要下載的引導(dǎo)程序文件目錄'
}
2.安裝tftp服務(wù)
[root@localhost named]# yum install tftp-server -y '安裝TFTPd服務(wù)'
[root@localhost named]# rpm -ql tftp-server '查看tftp服務(wù)的所有文件'
/etc/xinetd.d/tftp '需要配置'
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot
[root@localhost named]# vim /etc/xinetd.d/tftp '編輯/etc/xinetd.d/tftp'
14 disable = no '雙重否定為啟用'
[root@localhost named]# vim /var/lib/tftpboot 'tftpboot站點(diǎn)'
[root@localhost named]# cd /var/lib/tftpboot
[root@localhost tftpboot]# ls
[root@localhost tftpboot]#
[root@localhost tftpboot]# yum install syslinux -y '安裝syslinux'
[root@localhost tftpboot]# rpm -ql syslinux | grep pxelinux.0
/usr/share/syslinux/gpxelinux.0
/usr/share/syslinux/pxelinux.0 '把pxelinux.0復(fù)制到tftpboot內(nèi)'
[root@localhost tftpboot]#
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost tftpboot]# ls /var/lib/tftpboot
pxelinux.0
[root@localhost tftpboot]# yum install vsftpd -y '安裝vsftpd服務(wù)'
[root@localhost tftpboot]# rpm -ql vsftpd |grep pub
/var/ftp/pub
[root@localhost tftpboot]# mkdir /var/ftp/centos7 '創(chuàng)建/var/ftp/centos7目錄'
[root@localhost tftpboot]# cd /var/ftp
[root@localhost ftp]# ls
centos7 pub
[root@localhost ftp]# ls centos7/
[root@localhost ftp]#
開啟光驅(qū),使用對(duì)應(yīng)系統(tǒng)的鏡像文件
[root@localhost ftp]# mount /dev/sr0 /var/ftp/centos7 '把鏡像文件掛載到centos7上'
mount: /dev/sr0 寫保護(hù),將以只讀方式掛載
[root@localhost ftp]# ls centos7
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@localhost ftp]# cd centos7/images '切換到鏡像文件下的images目錄'
[root@localhost images]# ls
efiboot.img pxeboot TRANS.TBL
[root@localhost images]# cd pxeboot '切換到pxeboot目錄'
[root@localhost pxeboot]# ls
initrd.img TRANS.TBL vmlinuz
[root@localhost pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot '把里面的兩個(gè)文件復(fù)制到var/lib/tftpboot'
[root@localhost pxeboot]# ls /var/lib/tftpboot
initrd.img pxelinux.0 vmlinuz
[root@localhost pxeboot]# cd /var/lib/tftpboot '切換到tfpboot目錄'
[root@localhost tftpboot]# mkdir pxelinux.cfg '創(chuàng)建pxelinux.cfg目錄'
[root@localhost tftpboot]# cd pxelinux.cfg
[root@localhost pxelinux.cfg]# vim default '在pxelinux.cfg目錄下創(chuàng)建default文件'
[root@localhost pxelinux.cfg]# ls
default
[root@localhost pxelinux.cfg]#
defalut auto '默認(rèn)為自適應(yīng)'
prompt 1 '等待時(shí)間'
label auto '標(biāo)簽自適應(yīng)'
kernel vmlinuz '內(nèi)核'
append initrd=initrd.img method=ftp://192.168.100.100/centos7
'追加初始化進(jìn)程' '路徑方法'
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.100/centos7
label linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
[root@localhost pxelinux.cfg]# systemctl start dhcpd '開啟dhcpd'
[root@localhost pxelinux.cfg]# systemctl start vsftpd '開啟vsftpd'
[root@localhost pxelinux.cfg]# systemctl start tftp '開啟tftp'
測(cè)試
此時(shí)測(cè)試的虛擬機(jī)的網(wǎng)卡需要是僅主機(jī)模式
進(jìn)入4
boot 敲回車
自動(dòng)引導(dǎo)結(jié)束
3.無人值守安裝
[root@localhost ~]# yum install system-config-kickstart -y '安裝系統(tǒng)配置工具kickstart'
[root@localhost ~]# cd /var/ftp '切換到/var/ftp目錄'
[root@localhost ftp]# ls
centos7 ks.cfg pub
[root@localhost ftp]# vim ks.cfg '修改ks.cfg配置文件'
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$6qKSDsgs$eaNnQ18jrgccQjSX95B9Z.
# Use network installation
url --url="ftp://192.168.100.100/centos7"
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=ens33
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=none
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=512
part /home --fstype="xfs" --size=4096
part swap --fstype="swap" --size=4096
part / --fstype="xfs" --grow --size=1
[root@localhost ftp]# cd ~ '切換到root的家目錄'
[root@localhost ~]# ls
anaconda-ks.cfg 公共 視頻 文檔 音樂
initial-setup-ks.cfg 模板 圖片 下載 桌面
[root@localhost ~]# vim anaconda-ks.cfg '把里面的anaconda.ks.cfg文件內(nèi)的'
#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$lZy/ZqchdBxv/dZ0$RUyTDADN9e2H0hJlb9J757GyZ0nxWhPKY1sDdyCtvBR2/Asw/CPCAFFIfJB.kO7qbicMQx1LeoP53Xq/YXJeC0
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
user --name=gsy --password=$6$4r65p5GBvUZhGlnz$Cs.RsqZdbDij5eQeIxWRi3f4VERzZFsp1TSkgaURI3d0Beafr8TT//iBETmpgEsW//yoHoqfvL9k2BwmGQlx51 --iscrypted --gecos="gsy"
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
bootloader --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel
%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
~
[root@localhost ~]# vim /var/ftp/ks.cfg
%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
%end
[root@localhost ~]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# ls
initrd.img pxelinux.0 pxelinux.cfg vmlinuz
[root@localhost tftpboot]# cd pxelinux.cfg
[root@localhost pxelinux.cfg]# ls
default
[root@localhost pxelinux.cfg]# vim default
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg
[root@localhost pxelinux.cfg]# systemctl restart dhcpd
[root@localhost pxelinux.cfg]# systemctl restart tftp
[root@localhost pxelinux.cfg]# systemctl restart vsftpd
再次驗(yàn)證
選擇第四個(gè),然后回車
systemctl stop firewalld.service
setenforce 0
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.1 192.168.100.200;
option routers 192.168.100.100; '在局域網(wǎng)絡(luò)配置裝機(jī)服務(wù)時(shí),把網(wǎng)關(guān)指向自己'
option domain-name-servers 8.8.8.8;
next-server 192.168.100.100; '指定FTP服務(wù)器'
filename "pxelinux.0"; '指定要下載的引導(dǎo)程序文件目錄'
}
配置tftpd服務(wù)的配置文件/etc/xinetd.d/tftp
disable 改為no '開啟'
initrd.img和vmlinuz文件來源于鏡像文件:把鏡像文件下的images/pxeboot/目錄下的兩個(gè)initrd.img、vmlinuz文件拷貝到/var/lib/tftpboot目錄下
pxelinux.0文件:需要先安裝syslinux軟件,在其/usr/share/syslinux目錄下,把pxelinux.0文件直接復(fù)制到var/lib/tftpboot/目錄下
pxelinux.cfg目錄為新創(chuàng)建的目錄,然后再var/lib/tftpboot/pxelinux.cfg/目錄下新建default文件
? pxelinux.cfg/default文件配置
default auto '默認(rèn)共享'
prompt 1 '啟動(dòng)時(shí)間'
label auto
kernel vmlinuz '內(nèi)核'
append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg
追加 進(jìn)程 初始化文件 方法 定位 kickstart 位置
label linux text '文本模式安裝'
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.100/centos7
label linux rescue '進(jìn)入救援模式'
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
然后開啟所有服務(wù)
systemctl start dhcpd '開啟dhcpd'
systemctl start vsftpd '開啟vsftpd'
systemctl start tftp '開啟tftp'
先安裝system-config-kickstart 系統(tǒng)配置kickstart軟件
然后再圖形化界面配置
安裝方法FTP 服務(wù)器ftp://192.168.100.100/
目錄centos7
引導(dǎo)裝載程序選開啟
分區(qū)設(shè)置,/boot512M /home 4096M swap 4096M / 剩余的所有都給他
添加網(wǎng)卡ens33
禁用防火墻
然后保存在vsftpd服務(wù)的/var/ftp/目錄下
腳本可以把~/anaconda.cfg中的數(shù)據(jù)%pac
kages到%end 復(fù)制到/var/ftp/ks.cfg中
此時(shí)再次重啟即可
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。