配置dhcp服务
[root@node1 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
[root@node1 ~]# vim /etc/dhcp/dhcpd.conf
......
......
subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.10 192.168.3.254;
option routers 192.168.3.1;
option broadcast-address 192.168.3.31;
default-lease-time 3600;
max-lease-time 7200;
next-server 192.168.3.10; #指向pxe服务器
filename "pxelinux.0";
}检查配置,启动服务:
[root@node1 ~]# service dhcpd configtest
Syntax: OK
[root@node1 ~]# service dhcpd start
Starting dhcpd: [ OK ]
[root@node1 ~]# ss -tunl | grep 67
udp UNCONN 0 0 *:67 *:*
启动tftp和rsync
[root@node1 ~]# chkconfig tftp on
[root@node1 ~]# chkconfig rsync on
[root@node1 ~]# service xinetd start
[root@node1 ~]# ss -tunl | grep 69
udp UNCONN 0 0 *:69 *:*
启动cobbler服务
在启动cobbler之前首先需要启动httpd服务。
[root@node1 ~]# service httpd start
[root@node1 ~]# service cobblerd start 然后使用cobbler check检查cobbler的运行环境,第一次运行可能会存在如下错误():
[root@node1 ~]# 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 : 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.
4 : debmirror package is not installed, it will be required to manage debian deployments and repositories
5 : ksvalidator was not found, install pykickstart
6 : 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
7 : 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)设置server参数为cobbler服务器的IP地址
# vim /etc/cobbler/settings
# server: 192.168.3.10
2)设置next_server为pxe服务器的IP地址
# vim /etc/cobbler/settings
# next_server: 192.168.3.10
3)若仅为x86/x86_64架构的服务器提供服务,安装syslinux即可
# yum install syslinux
4)这一项可以忽略
5)安装ksvalidator
# yum install -y pykickstart
6)为default_password_crypted参数设置新密码
# openssl passwd -1 -salt `openssl rand -hex 6`
# default_password_crypted: "passwd"
7)install cman or fence-agents(可不装) 修改完成后,重启服务:
[root@node1 ~]# cobbler sync
[root@node1 ~]# service cobblerd restart
添加distro
挂载光盘镜像
[root@node3 ~]# mount /dev/cdrom /mnt/flash/ 添加一个distro(若有光盘镜像,推荐直接导入光盘镜像)