實驗環境Centos7
需安裝包:
httpd :提供傳輸安裝系統所需檔案,根目錄挂載安裝CD光牒
dhcpd :提供dhcp服務
tftp-server :與dhcpd一起提供初始化檔案傳輸服務
syslinux :提供部分必須檔案如:pxelinux
dhcp 服務:
主要配置
vim /etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.20;
filename "pxelinux.0"; /* 申明pxe檔案名
next-server 192.168.10.3; /* 申明pxe檔案所在的伺服器,tftp伺服器
}
tftp服務
服務根目錄
各個版本的安裝程式元件不可混用
CentOS7:
tree /var/lib/tftpboot/
├── chain.c32 /*由 syslinux 軟體包提供,與選擇菜單有關
├── initrd.img /*由系統安裝CD光牒裡的pxelinux提供,是系統安裝程式元件
├── kickstarts
│ └── centos7.cfg /*ks檔案,自動化安裝系統的安裝配置在選擇菜單界面選擇項引用
├── mboot.c32 /*由 syslinux 軟體包提供,與選擇菜單有關
├── memdisk /*由 syslinux 軟體包提供,與選擇菜單有關
├── menu.c32 /*由 syslinux 軟體包提供,與選擇菜單有關
├── pxelinux.0 /*由 syslinux 軟體包提供,與選擇菜單有關
├── pxelinux.cfg
│ └── default /*是系統安裝CD光牒裡的isolinux提供,與選擇菜單界面選擇項有關
└── vmlinuz /*由系統安裝CD光牒裡的pxelinux提供,是系統安裝程式元件
default檔案詳解:
default menu.c32
prompt 5
timeout 30
MENU TITLE CentOS 7 PXE Menu
LABEL linux
MENU LABEL Install CentOS 7 x86_64
KERNEL vmlinuz
APPEND initrd=initrd.img
LABEL linux
MENU LABEL Install CentOS 7 x86_64
KERNEL vmlinuz
APPEND initrd=initrd.img (ip=192.168.10.100 netmask=255.255.255.0)inst.repo=http://172.16.100.67/centos7 ks=http://172.16.100.67/centos7.cfg
CentOS6:
tree /var/lib/tftpboot/
├── boot.msg /*是系統安裝CD光牒裡的isolinux提供,與選擇菜單界面選擇項有關
├── initrd.img /*由系統安裝CD光牒裡的pxelinux提供,是系統安裝程式元件
├── pxelinux.0 /*由 syslinux 軟體包提供,與選擇菜單有關
├── pxelinux.cfg /*由 syslinux 軟體包提供,與選擇菜單有關
│ └── default /*是系統安裝CD光牒裡的isolinux提供,與選擇菜單界面選擇項有關
├── splash.jpg /*是系統安裝CD光牒裡的isolinux提供,與選擇菜單界面選擇項有關
├── vesamenu.c32 /*是系統安裝CD光牒裡的isolinux提供,與選擇菜單界面選擇項有關
└── vmlinuz /*由系統安裝CD光牒裡的pxelinux提供,是系統安裝程式元件
cobbler :有圖形界面--- 安裝包(cobbler-web)
cobbler是pxe的二次封裝是以依賴于以下服務
dhcp:解決方案(安裝包)
dnsmasq,dhcpd
tftp:解決方案(安裝包)
tftp-server
概念:
distro /linux 發行版系統 repository,标記一個發行版的最重要标記是,kernel ramdisk
profile /ks檔案 kickstarts
system /實際安裝好的系統 ip/mask
主配置檔案:
/etc/cobbler/settings
實作流程:
yum install cobbler /*安裝cobbler,基于epel源
systemctl start cobbler /*啟動服務
cobbler check /*檢查服務,根據服務的錯誤提示修改主配置檔案重新開機即可
cobbler sync /*修改完配置檔案後,同步配置到,tftp
cobbler import --name="CentOS7_x86_64-1503" --path=/media/cdrom /*導入發行版本,會生成最小安裝的配置檔案
指令:
cobbler distro [list|add|--help]
cobbler import --name="CentOS7_x86_64-1503" --path=/media/cdrom
實操流程:
1、安裝cobbler,基于epel源
yum install cobbler
2、啟動服務
systemctl start cobbler.service
3、運作cobbler check
cobbler check
系統提示:
httpd does not appear to be running and proxying cobbler, or SELinux is in the way. Original traceback:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cobbler/cli.py", line 251, in check_setup
s.ping()
File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1591, in __request
verbose=self.__verbose
File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1301, in single_request
self.send_content(h, request_body)
File "/usr/lib64/python2.7/xmlrpclib.py", line 1448, in send_content
connection.endheaders(request_body)
File "/usr/lib64/python2.7/httplib.py", line 1037, in endheaders
self._send_output(message_body)
File "/usr/lib64/python2.7/httplib.py", line 881, in _send_output
self.send(msg)
File "/usr/lib64/python2.7/httplib.py", line 843, in send
self.connect()
File "/usr/lib64/python2.7/httplib.py", line 824, in connect
self.timeout, self.source_address)
File "/usr/lib64/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
問題所在第一行,httpd服務沒有啟動。
1),rpm -qi httpd 顯示httpd 已在安裝cobbler時一起安裝了,啟動即可
systemctl start httpd
cobbler check
系統提示:
The following are potential configuration items that you may want to fix:
1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
3 : change 'disable' to 'no' in /etc/xinetd.d/tftp
4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.
5 : enable and start rsyncd.service with systemctl
6 : debmirror package is not installed, it will be required to manage debian deployments and repositories
7 : The default password used by the sample templates for newly installed machines (default_password_crypted in /etc/cobbler/settings) is still set to 'cobbler' and should be changed, try: "openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'" to generate new one
8 : fencing tools were not found, and are required to use the (optional) power management features. install cman or fence-agents to use them
Restart cobblerd and then run 'cobbler sync' to apply changes.
如上各問題的解決方法如下所示:
1、修改/etc/cobbler/settings檔案中的server參數的值為提供cobbler服務的主機相應的IP位址或主機名;
2、修改/etc/cobbler/settings檔案中的next_server參數的值為提供(cobbler)PXE服務的主機相應的IP位址;
3、如果目前節點可以通路網際網路,執行“cobbler get-loaders”指令即可;否則,需要安裝syslinux程式包, 而後複制/usr/share/syslinux/*等檔案至/var/lib/cobbler/loaders/目錄中;
4、執行“chkconfig rsync on”/systemctl start rsyncd.service指令即可;
5、注釋/etc/debmirror.conf檔案中的“@dists="sid";”一行,centos7忽略;
6、注釋/etc/debmirror.conf檔案中的“@arches="i386";”一行;centos7忽略;
7、執行“openssl passwd -1 -salt $(openssl rand -hex 4)”生成密碼,并用其替換/etc/cobbler/settings檔案中default_password_crypted參數的值;
8、執行“yum install cman fence-agents”指令安裝相應的程式包即可;
4,啟動tftp服務
systemctl start tftp
5,安裝dhcp服務并配置啟動
安裝:yum install -y dhcp
配置:vim /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.10 192.168.10.20;
filename="pxelinux.0";
next-server 192.168.10.2;
}
啟動:systemctl start dhcpd
6,接着重新開機cobblerd,而後執行“cobbler sync”同步新的配置至cobbler。
7,導入發行版本,會生成最小安裝的配置檔案,同步
cobbler import --name="CentOS7_x86_64-1503" --path=/media/cdrom
cobbler sync
額外指令:
mount --bind diretory diretory /*目錄挂載