震驚!!!是什么讓程式員痛哭流涕!!!
- 實驗題
- PXE
- 設定成主機模式,修改網卡
- 重啟網卡
- 配置本地yum源倉庫
- 安裝TFPT
- 安裝DHCP并啟動服務
- 準備 Linux 內核、初始化鏡像檔案
- 準備 PXE 引導程式
- 安裝FTP,準備CentOS7安裝源
- 配置啟動選單檔案
- 關閉防火墻
- 新建虛擬機
- 在Windows中選用DHCP自動分配獲取地址
- DNS
- 開啟httpd服務,httpd服務適用于域名的,開啟了才能用網址
- 安裝bind包
- 配置主組態檔
- 配置區域組態檔
- 配置區域資料組態檔
- 重啟服務,關閉防火墻
- 添加DNS服務器地址
- 測驗DNS決議
- Windows中測驗
- NFS
- 檔案服務器(可用PXE自動安裝的虛擬機,DHCP分配IP為172.16.100.103)
- 停止行程
- 因為沒有配置yum倉庫本地源,所以安裝不了
- 安裝yum源倉庫
- 配置共享目錄
- 設定輸出的各項配置:物件,權限等
- 啟動 NFS 服務程式
- 創建檔案、配置內容
- 發布并查看共享
- 最后記得關防火墻
- 客戶機IP:172.16.100.100
- 安裝 nfs-utils、rpcbind 軟體包
- 關閉防火墻
- 因為在檔案服務器中沒有關閉防火墻所以獲取不到
- 關閉后即可獲取
- 掛載
- 查看發現已經實時共享
- Windows中web服務顯示
實驗題
1)準備3臺虛擬機,一臺Windows虛擬機PC1(不限制win7或者win10)、一臺Linux服務器server1(IP是172.16.100.100/24)和一臺空虛擬機server2,虛擬機網路使用僅主機模式,(10分)
2)server1提供DHCP服務給PC1和server2分配對應網段的IP地址,(10分)
3)server1提供PXE服務,能夠使server2可以自動安裝Centos7 Linux作業系統,(10分)
4)在server1安裝和啟動httpd服務對外提供Web服務,并搭建DNS服務負責決議地址www.kgc.com,使得PC1能夠使用域名www.kgc.com訪問Web服務器,(10分)
5)在server2安裝NFS服務,提供共享目錄/share
,在/share目錄中創建檔案index.html,檔案內容自定義,把server2的/share目錄通過NFS掛載到server1的/var/www/html目錄下,使得PC1訪問Web服務時能夠顯示自定義的內容,(10分)
PXE
在PXE裝機中因為使用的是172.16.100.100,使用主機模式,要將DHCP關閉,如果不關閉所在DHCP服務器網段為192.168.30.0和題目要求的172.16.100.0不在同一網段,分配時就看客戶機先分配到誰,就會得到哪個網段


設定成主機模式,修改網卡
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

重啟網卡
[root@localhost ~]# systemctl restart network
[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 寫保護,將以只讀方式掛載
配置本地yum源倉庫
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir repos.bak
[root@localhost yum.repos.d]# mv *.repo repos.bak
[root@localhost yum.repos.d]# cd repos.bak/
[root@localhost repos.bak]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@localhost repos.bak]# cd -
/etc/yum.repos.d
[root@localhost yum.repos.d]# vim local.repo

[root@localhost yum.repos.d]# yum clean all && yum makecache
安裝TFPT
[root@localhost yum.repos.d]# cd ~
[root@localhost ~]# yum -y install tftp-server xinetd
[root@localhost ~]# vim /etc/xinetd.d/tftp

[root@localhost ~]# systemctl start tftp
[root@localhost ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@localhost ~]# systemctl start xinetd
[root@localhost ~]# systemctl enable xinetd
安裝DHCP并啟動服務
[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:是否覆寫"/etc/dhcp/dhcpd.conf"? y
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf #修改DHCP組態檔

[root@localhost ~]# systemctl start dhcpd
[root@localhost ~]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
準備 Linux 內核、初始化鏡像檔案
[root@localhost ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 寫保護,將以只讀方式掛載
mount: /dev/sr0 已經掛載或 /mnt 忙
/dev/sr0 已經掛載到 /run/media/root/CentOS 7 x86_64 上
/dev/sr0 已經掛載到 /mnt 上
[root@localhost ~]# cd /mnt/images/pxeboot
[root@localhost pxeboot]# cp vmlinuz /var/lib/tftpboot/ #將Linux內核檔案復制到tftp根目錄下
[root@localhost pxeboot]# cp initrd.img /var/lib/tftpboot/ #將初始化鏡像檔案(linux引導加載模塊)復制到TFTP根目錄下
[root@localhost pxeboot]# ls /var/lib/tftpboot/
initrd.img vmlinuz
準備 PXE 引導程式
PXE引導程式由軟體包 syslinux 提供所以安裝syslinux
[root@localhost pxeboot]# yum -y install syslinux
復制PXE引導程式到tftp根目錄下
[root@localhost pxeboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost pxeboot]# ls /var/lib/tftpboot/
initrd.img pxelinux.0 vmlinuz
安裝FTP,準備CentOS7安裝源
[root@localhost pxeboot]# yum -y install vsftpd
[root@localhost pxeboot]# mkdir /var/ftp/centos7 #創建安裝源目錄
[root@localhost pxeboot]# cp -rf /mnt/* /var/ftp/centos7/ 將鏡像檔案全部復制到安裝源目錄

[root@localhost pxeboot]# systemctl start vsftpd
[root@localhost pxeboot]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
配置啟動選單檔案
[root@localhost pxeboot]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost pxeboot]# vim /var/lib/tftpboot/pxelinux.cfg/default

關閉防火墻
[root@localhost pxeboot]# systemctl stop firewalld.service
[root@localhost pxeboot]# setenforce 0
新建虛擬機


在Windows中選用DHCP自動分配獲取地址


DNS
開啟httpd服務,httpd服務適用于域名的,開啟了才能用網址
[root@localhost ~]# yum install -y httpd
[root@localhost ~]# systemctl start httpd.service
安裝bind包
[root@localhost ~]# yum -y install bind
[root@localhost ~]# rpm -qc bind
/etc/logrotate.d/named
/etc/named.conf
/etc/named.iscdlv.key
/etc/named.rfc1912.zones
/etc/named.root.key
/etc/rndc.conf
/etc/rndc.key
/etc/sysconfig/named
/var/named/named.ca
/var/named/named.empty
/var/named/named.localhost
/var/named/named.loopback
配置主組態檔
[root@localhost ~]# vim /etc/named.conf


配置區域組態檔
[root@localhost ~]# vim /etc/named.rfc1912.zones

[root@localhost ~]# cd /var/named/
[root@localhost named]# cp -p named.localhost xyw.com 復制模板
[root@localhost named]# ls #檔案已復制
data named.ca named.localhost slaves
dynamic named.empty named.loopback xyw.com
配置區域資料組態檔
[root@localhost named]# vim /var/named/xyw.com

重啟服務,關閉防火墻
[root@localhost named]# systemctl start named
[root@localhost named]# systemctl stop firewalld
[root@localhost named]# setenforce 0
添加DNS服務器地址
[root@localhost named]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

[root@localhost named]# systemctl restart network
測驗DNS決議
[root@localhost named]# host www.kgc.com
www.kgc.com has address 172.16.100.100
[root@localhost named]# nslookup www.kgc.com
Server: 172.16.100.100
Address: 172.16.100.100#53
Name: www.kgc.com
Address: 172.16.100.100

Windows中測驗

NFS
檔案服務器(可用PXE自動安裝的虛擬機,DHCP分配IP為172.16.100.103)

[root@localhost ~]# rpm -q rpcbind nfs-utils
rpcbind-0.2.0-42.el7.x86_64
nfs-utils-1.3.0-0.48.el7.x86_64
停止行程
[root@localhost ~]# yum -y install nfs-utils rpcbind
已加載插件:fastestmirror, langpacks
/var/run/yum.pid 已被鎖定,PID 為 4226 的另一個程式正在運行,
Another app is currently holding the yum lock; waiting for it to exit...
另一個應用程式是:PackageKit
記憶體: 26 M RSS (437 MB VSZ)
已啟動: Mon Dec 14 22:43:48 2020 - 00:03之前
狀態 :睡眠中,行程ID:4226
Another app is currently holding the yum lock; waiting for it to exit...
另一個應用程式是:PackageKit
記憶體: 26 M RSS (437 MB VSZ)
已啟動: Mon Dec 14 22:43:48 2020 - 00:05之前
狀態 :睡眠中,行程ID:4226
^C
Exiting on user cancel.
[root@localhost ~]# kill -9 4226
因為沒有配置yum倉庫本地源,所以安裝不了
[root@localhost ~]# yum -y install nfs-utils rpcbind
已加載插件:fastestmirror, langpacks
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的錯誤"
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
安裝yum源倉庫
[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /dev/sr0 寫保護,將以只讀方式掛載
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir repos.bak
[root@localhost yum.repos.d]# mv *.repo repos.bak
[root@localhost yum.repos.d]# vim local.repo
[root@localhost yum.repos.d]# yum clean all && yum makecache
[root@localhost yum.repos.d]# yum -y install nfs-utils rpcbind
配置共享目錄
[root@localhost yum.repos.d]# cd ~
[root@localhost ~]# mkdir -p /opt/share
[root@localhost ~]# chmod 777 /opt/share/
設定輸出的各項配置:物件,權限等
[root@localhost ~]# cd /etc/exports
bash: cd: /etc/exports: 不是目錄
[root@localhost ~]# cd /etc/
[root@localhost etc]# ls
exports nfs.conf system-release
exports.d nfsmount.conf system-release-cpe
[root@localhost etc]# vim /etc/exports

啟動 NFS 服務程式
手動加載NFS共享服務時,應該先啟動rpcbind,再啟動nfs
[root@localhost etc]# systemctl start rpcbind
[root@localhost etc]# systemctl start nfs
[root@localhost etc]# systemctl enable rpcbind
[root@localhost etc]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
[root@localhost etc]# netstat -anpt | grep 111

創建檔案、配置內容
[root@localhost etc]# cd /opt/share
[root@localhost share]# touch indel.html
[root@localhost share]# ls
indel.html index.html
[root@localhost share]# vim index.html

發布并查看共享
[root@localhost etc]# exportfs -rv
exporting 172.16.100.100/24:/opt/share
[root@localhost etc]# showmount -e
Export list for localhost.localdomain:
/opt/share 172.16.100.100/24
最后記得關防火墻
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
客戶機IP:172.16.100.100
安裝 nfs-utils、rpcbind 軟體包
[root@localhost named]# cd ~
[root@localhost ~]# rpm -q rpcbind nfs-utils
rpcbind-0.2.0-42.el7.x86_64
nfs-utils-1.3.0-0.48.el7.x86_64
[root@localhost ~]# yum -y install nfs-utils rpcbind
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
軟體包 1:nfs-utils-1.3.0-0.48.el7.x86_64 已安裝并且是最新版本
軟體包 rpcbind-0.2.0-42.el7.x86_64 已安裝并且是最新版本
無須任何處理
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl enable rpcbind
關閉防火墻
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
因為在檔案服務器中沒有關閉防火墻所以獲取不到
[root@localhost ~]# showmount -e 172.16.100.103
clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
關閉后即可獲取
[root@localhost html]# showmount -e 172.16.100.103
Export list for 172.16.100.103:
/opt/share 172.16.100.0/24
掛載
[root@localhost html]# mount 172.16.100.103:/opt/share /var/www/html/
查看發現已經實時共享
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
indel.html index.html
[root@localhost html]# vim index.html

Windows中web服務顯示

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/234854.html
標籤:其他
