1.阿里云源
1
2
3
|
[root@linux-node1 ~]
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@linux-node1 ~]
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@linux-node1 ~]
# yum clean all
|
2.操作系统(centos7.3 会有问题选择centos7.2或者7.1)
1
2
3
|
[root@linux-node1 ~]
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@linux-node1 ~]
#
|
3.安装需要的软件
1
|
[root@linux-node1 ~]
# yum install -y httpd dhcp tftp cobbler
|
4.启动httpd和cobblerd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
[root@linux-node1 ~]
# systemctl start httpd
[root@linux-node1 ~]
# systemctl enable httpd
Created
symlink
from
/etc/systemd/system/multi-user
.target.wants
/httpd
.service to
/usr/lib/systemd/system/httpd
.service.
[root@linux-node1 ~]
# systemctl start cobblerd
[root@linux-node1 ~]
# systemctl enable cobblerd
Created
symlink
from
/etc/systemd/system/multi-user
.target.wants
/cobblerd
.service to
/usr/lib/systemd/system/cobblerd
.service.
[root@linux-node1 ~]
#
检查是否启动
[root@linux-node1 ~]
# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID
/Program
name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 922
/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1580
/master
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 2820
/python2
tcp6 0 0 :::80 :::* LISTEN 2792
/httpd
tcp6 0 0 :::22 :::* LISTEN 922
/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1580
/master
[root@linux-node1 ~]
#
|
5.执行cobbler check检查需要配置的cobbler模块
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@linux-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 : 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 : ksvalidator was not found,
install
pykickstart
8 : 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
9 : 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.
[root@linux-node1 ~]
#
|
5.1 修改1和2
1
2
3
4
|
[root@linux-node1 ~]
# grep "192.168.56.13" /etc/cobbler/settings
next_server: 192.168.56.13
server: 192.168.56.13
[root@linux-node1 ~]
#
|
5.2修改3
1
2
3
|
[root@linux-node1 ~]
# grep "disable" /etc/xinetd.d/tftp
disable = no
[root@linux-node1 ~]
#
|
5.3修改4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@linux-node1 ~]
# cobbler get-loaders
task started: 2017-02-20_033851_get_loaders
task started (
id
=Download Bootloader Content,
time
=Mon Feb 20 03:38:51 2017)
downloading https:
//cobbler
.github.io
/loaders/README
to
/var/lib/cobbler/loaders/README
downloading https:
//cobbler
.github.io
/loaders/COPYING
.elilo to
/var/lib/cobbler/loaders/COPYING
.elilo
downloading https:
//cobbler
.github.io
/loaders/COPYING
.yaboot to
/var/lib/cobbler/loaders/COPYING
.yaboot
downloading https:
//cobbler
.github.io
/loaders/COPYING
.syslinux to
/var/lib/cobbler/loaders/COPYING
.syslinux
downloading https:
//cobbler
.github.io
/loaders/elilo-3
.8-ia64.efi to
/var/lib/cobbler/loaders/elilo-ia64
.efi
downloading https:
//cobbler
.github.io
/loaders/yaboot-1
.3.17 to
/var/lib/cobbler/loaders/yaboot
downloading https:
//cobbler
.github.io
/loaders/pxelinux
.0-3.86 to
/var/lib/cobbler/loaders/pxelinux
.0
downloading https:
//cobbler
.github.io
/loaders/menu
.c32-3.86 to
/var/lib/cobbler/loaders/menu
.c32
downloading https:
//cobbler
.github.io
/loaders/grub-0
.97-x86.efi to
/var/lib/cobbler/loaders/grub-x86
.efi
downloading https:
//cobbler
.github.io
/loaders/grub-0
.97-x86_64.efi to
/var/lib/cobbler/loaders/grub-x86_64
.efi
*** TASK COMPLETE ***
|
5.4修改5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@linux-node1 ~]
# systemctl start rsyncd
[root@linux-node1 ~]
# systemctl enable rsyncd
Created
symlink
from
/etc/systemd/system/multi-user
.target.wants
/rsyncd
.service to
/usr/lib/systemd/system/rsyncd
.service.
[root@linux-node1 ~]
# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID
/Program
name
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 2874
/rsync
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 922
/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1580
/master
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 2820
/python2
tcp6 0 0 :::873 :::* LISTEN 2874
/rsync
tcp6 0 0 :::80 :::* LISTEN 2792
/httpd
tcp6 0 0 :::22 :::* LISTEN 922
/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1580
/master
[root@linux-node1 ~]
#
|
5.5 修改7 ,6不用管
1
|
[root@linux-node1 ~]
# yum -y install install pykickstart
|
5.6 修改客户机的密码
1
2
3
4
5
6
|
[root@linux-node1 ~]
# openssl passwd -1 -salt '123123' '123123'
$1$123123$MAV.kVI
/b3swmFLErPD2b0
[root@linux-node1 ~]
# vim /etc/cobbler/settings
[root@linux-node1 ~]
# grep "default_password_crypted" /etc/cobbler/settings
default_password_crypted:
"$1$123123$MAV.kVI/b3swmFLErPD2b0"
[root@linux-node1 ~]
#
|
5.7 修改9
[root@linux-node1 ~]# yum -y install cman fence-agents
5.8校验
1
2
3
4
5
6
7
8
9
|
出现如下状况就可以了
[root@linux-node1 ~]
# systemctl restart cobblerd
[root@linux-node1 ~]
# cobbler check
The following are potential configuration items that you may want to fix:
1 : debmirror package is not installed, it will be required to manage debian deployments and repositories
Restart cobblerd and
then
run
'cobbler sync'
to apply changes.
[root@linux-node1 ~]
#
|
6 让cobbler管理dhcp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
[root@linux-node1 ~]
# grep "manage_dhcp" /etc/cobbler/settings
manage_dhcp: 1
# if using cobbler with manage_dhcp, put the IP address
# Note that if manage_dhcp and manage_dns are disabled, the respective
[root@linux-node1 ~]
#
[root@linux-node1 ~]
# vim /etc/cobbler/dhcp.template
subnet 192.168.56.0 netmask 255.255.255.0 {
option routers 192.168.56.2;
option domain-name-servers 192.168.56.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.56.100 192.168.56.254;
default-lease-
time
21600;
max-lease-
time
43200;
next-server $next_server;
class
"pxeclients"
{
match
if
substring (option vendor-class-identifier, 0, 9) =
"PXEClient"
;
if
option pxe-system-
type
= 00:02 {
filename
"ia64/elilo.efi"
;
}
else
if
option pxe-system-
type
= 00:06 {
filename
"grub/grub-x86.efi"
;
}
else
if
option pxe-system-
type
= 00:07 {
filename
"grub/grub-x86_64.efi"
;
}
else
{
filename
"pxelinux.0"
;
}
}
}
[root@linux-node1 ~]
# systemctl restart cobblerd
|
7.让配置文件生效
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
[root@linux-node1 ~]
# cobbler sync
task started: 2017-02-20_041326_sync
task started (
id
=Sync,
time
=Mon Feb 20 04:13:26 2017)
running pre-
sync
triggers
cleaning trees
removing:
/var/lib/tftpboot/grub/images
copying bootloaders
trying hardlink
/var/lib/cobbler/loaders/pxelinux
.0 ->
/var/lib/tftpboot/pxelinux
.0
trying hardlink
/var/lib/cobbler/loaders/menu
.c32 ->
/var/lib/tftpboot/menu
.c32
trying hardlink
/var/lib/cobbler/loaders/yaboot
->
/var/lib/tftpboot/yaboot
trying hardlink
/usr/share/syslinux/memdisk
->
/var/lib/tftpboot/memdisk
trying hardlink
/var/lib/cobbler/loaders/grub-x86
.efi ->
/var/lib/tftpboot/grub/grub-x86
.efi
trying hardlink
/var/lib/cobbler/loaders/grub-x86_64
.efi ->
/var/lib/tftpboot/grub/grub-x86_64
.efi
copying distros to tftpboot
copying images
generating PXE configuration files
generating PXE menu structure
rendering DHCP files
generating
/etc/dhcp/dhcpd
.conf
rendering TFTPD files
generating
/etc/xinetd
.d
/tftp
cleaning link caches
running post-
sync
triggers
running python triggers from
/var/lib/cobbler/triggers/sync/post/
*
running python trigger cobbler.modules.sync_post_restart_services
running: dhcpd -t -q
received on stdout:
received on stderr:
running: service dhcpd restart
received on stdout:
received on stderr: Redirecting to
/bin/systemctl
restart dhcpd.service
running shell triggers from
/var/lib/cobbler/triggers/sync/post/
*
running python triggers from
/var/lib/cobbler/triggers/change/
*
running python trigger cobbler.modules.scm_track
running shell triggers from
/var/lib/cobbler/triggers/change/
*
*** TASK COMPLETE ***
[root@linux-node1 ~]
#
|
8.上传镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@linux-node1 opt]
# ll
total 4228096
-rw-r--r-- 1 root root 4329570304 Feb 20 04:20 CentOS-7-x86_64-DVD-1511.iso
[root@linux-node1 opt]
# mount -o loop /opt/CentOS-7-x86_64-DVD-1511.iso /mnt
mount
:
/dev/loop0
is write-protected, mounting
read
-only
[root@linux-node1 opt]
#
导入镜像
[root@linux-node1 opt]
# cobbler import --path=/mnt --name=CentOS-7.2-x86_64 --arch=x86_64
task started: 2017-02-20_042242_import
task started (
id
=Media
import
,
time
=Mon Feb 20 04:22:42 2017)
。。。。。 此处比较慢
镜像导入这一步其实是,复制镜像的过程
[root@linux-node1 mnt]
# cd /var/www/cobbler/ks_mirror
[root@linux-node1 ks_mirror]
# ls
CentOS-7.2-x86_64 config
[root@linux-node1 ks_mirror]
#
|
9检查校验
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
[root@linux-node1 ks_mirror]
# cobbler list
distros:
CentOS-7.2-x86_64
profiles:
CentOS-7.2-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
[root@linux-node1 ks_mirror]
#
|
10上传配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@linux-node1 kickstarts]
# ll
total 56
-rw-r--r-- 1 root root 1355 Feb 18 15:39 CentOS-7-x86_64.cfg
#这个配置文件
-rw-r--r-- 1 root root 115 Nov 17 03:09 default.ks
-rw-r--r-- 1 root root 22 Nov 17 03:09 esxi4-ks.cfg
-rw-r--r-- 1 root root 22 Nov 17 03:09 esxi5-ks.cfg
drwxr-xr-x 2 root root 54 Feb 20 03:29 install_profiles
-rw-r--r-- 1 root root 1424 Nov 17 03:09 legacy.ks
-rw-r--r-- 1 root root 292 Nov 17 03:09 pxerescue.ks
-rw-r--r-- 1 root root 2916 Nov 17 03:09 sample_autoyast.xml
-rw-r--r-- 1 root root 1825 Nov 17 03:09 sample_end.ks
-rw-r--r-- 1 root root 0 Nov 17 03:09 sample_esx4.ks
-rw-r--r-- 1 root root 324 Nov 17 03:09 sample_esxi4.ks
-rw-r--r-- 1 root root 386 Nov 17 03:09 sample_esxi5.ks
-rw-r--r-- 1 root root 1784 Nov 17 03:09 sample.ks
-rw-r--r-- 1 root root 3419 Nov 17 03:09 sample_old.seed
-rw-r--r-- 1 root root 5879 Nov 17 03:09 sample.seed
[root@linux-node1 kickstarts]
# pwd
/var/lib/cobbler/kickstarts
#目录
[root@linux-node1 kickstarts]
#
|
11.查看profile
1
2
3
|
[root@linux-node1 kickstarts]
# cobbler profile list
CentOS-7.2-x86_64
[root@linux-node1 kickstarts]
#
|
12. 查看参数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
[root@linux-node1 kickstarts]
# cobbler profile report
Name : CentOS-7.2-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.2-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart :
/var/lib/cobbler/kickstarts/sample_end
.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : [
'admin'
]
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
Virt RAM (MB) : 512
Virt Type : kvm
[root@linux-node1 kickstarts]
#
|
13.修改内核参数
1
2
3
4
|
[root@linux-node1 kickstarts]
# cobbler profile edit --name=CentOS-7.2-x86_64 --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
[root@linux-node1 kickstarts]
# cobbler profile edit --name=CentOS-7.2-x86_64 --kopts='net.ifnames=0 biosdevname=0'
[root@linux-node1 kickstarts]
# cobbler profile report
Name : CentOS-7.2-x86_64
|
1
2
3
4
5
6
7
8
9
10
|
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-7.2-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {
'biosdevname'
:
'0'
,
'net.ifnames'
:
'0'
}
Kernel Options (Post Install) : {}
Kickstart :
/var/lib/cobbler/kickstarts/CentOS-7-x86_64
.cfg
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : [
'admin'
]
Parent Profile :
Internal proxy :
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Repos : []
Server Override : <<inherit>>
Template Files : {}
Virt Auto Boot : 1
Virt Bridge : xenbr0
Virt CPUs : 1
Virt Disk Driver Type : raw
Virt File Size(GB) : 5
Virt Path :
|
1
2
3
|
Virt RAM (MB) : 512
Virt Type : kvm
[root@linux-node1 kickstarts]
#
|
14 启动xinetd
1
2
3
|
[root@linux-node1 kickstarts]
# yum -y install xinetd
[root@linux-node1 kickstarts]
# systemctl start xinetd
[root@linux-node1 kickstarts]
# systemctl enable xinetd
|
15.配置文件接着生成
1
|
[root@linux-node1 kickstarts]
# cobbler sync
|
16.新建一台虚拟机(非克隆机) 关掉本地的dhcp服务
可以看出自动安装了
完毕安装
17.cobbler的web界面管理
1
2
3
|
yum -y
install
cobbler-web
htdigest
/etc/cobbler/users
.digest
"Cobbler"
cobbler
#让输入密码 给cobbler密码
systemctl restart httpd
|
18.对特定服务器的mac地址分配特定的IP
1
2
3
|
[root@linux-node1 kickstarts]
# cobbler system add --name=linux-node2 --mac=00:50:56:39:A9:37 --profile=CentOS-7.2-x86_64 --ip-address=192.168.56.112 --subnet=255.255.255.0 --gateway=192.168.56.2 --interface=eth0 --static=1 --hostname=linux-node2.com --name-servers="192.168.56.2" --kickstart=/var/lib/cobbler/kickstarts/CentOS-7-x86_64.cfg
[root@linux-node1 kickstarts]
# cobbler system list
linux-node2
|
再次启动刚所对应mac的服务器
本文转自 小小三郎1 51CTO博客,原文链接:http://blog.51cto.com/wsxxsl/1899308,如需转载请自行联系原作者