实验环境Centos7
需安装包:
httpd :提供传输安装系统所需文件,根目录挂载安装光盘
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 /*由系统安装光盘里的pxelinux提供,是系统安装程序组件
├── kickstarts
│ └── centos7.cfg /*ks文件,自动化安装系统的安装配置在选择菜单界面选择项引用
├── mboot.c32 /*由 syslinux 软件包提供,与选择菜单有关
├── memdisk /*由 syslinux 软件包提供,与选择菜单有关
├── menu.c32 /*由 syslinux 软件包提供,与选择菜单有关
├── pxelinux.0 /*由 syslinux 软件包提供,与选择菜单有关
├── pxelinux.cfg
│ └── default /*是系统安装光盘里的isolinux提供,与选择菜单界面选择项有关
└── vmlinuz /*由系统安装光盘里的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 /*是系统安装光盘里的isolinux提供,与选择菜单界面选择项有关
├── initrd.img /*由系统安装光盘里的pxelinux提供,是系统安装程序组件
├── pxelinux.0 /*由 syslinux 软件包提供,与选择菜单有关
├── pxelinux.cfg /*由 syslinux 软件包提供,与选择菜单有关
│ └── default /*是系统安装光盘里的isolinux提供,与选择菜单界面选择项有关
├── splash.jpg /*是系统安装光盘里的isolinux提供,与选择菜单界面选择项有关
├── vesamenu.c32 /*是系统安装光盘里的isolinux提供,与选择菜单界面选择项有关
└── vmlinuz /*由系统安装光盘里的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 /*目录挂载