分类: 系统运维
2015-04-28 11:55:49
点击(此处)折叠或打开
1
2
3
4
|
[root@node2 ~]# yum install -y ntp
[root@node2 ~]# ntpdate 202.120.2.101
4 Nov 13:49:41 ntpdate[1190]: step time server 202.120.2.101 offset 388653.714776 sec
[root@node2 ~]# hwclock -w
|
1
2
3
4
|
[root@node2 ~]# service iptables stop
[root@node2 ~]# chkconfig iptables off
[root@node2 ~]# getenforce
Disabled
|
1
|
[root@node2 ~]# yum install -y cobbler tftp dhcp httpd cman pykickstart debmirror
|
1
|
[root@node2 ~]# yum install -y ed patch perl perl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
|
1
2
3
4
5
6
7
8
9
10
|
[root@node2 ~]# chkconfig httpd on
[root@node2 ~]# chkconfig dhcpd on
[root@node2 ~]# chkconfig xinetd on
[root@node2 ~]# chkconfig cobblerd on
[root@node2 ~]#
[root@node2 ~]# service httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using node2.test.com for ServerName
[确定]
[root@node2 ~]# service cobblerd start
Starting cobbler daemon: [确定]
|
1
2
3
4
5
6
|
[root@node2 ~]# vim /etc/httpd/conf/httpd.conf
#增加一行
ServerName localhost:80
[root@node2 ~]# service httpd restart
停止 httpd: [确定]
正在启动 httpd: [确定]
|
1
2
3
4
5
6
7
8
9
10
|
[root@node2 ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : comment out 'dists' on /etc/debmirror.conf for proper debian support
6 : comment out 'arches' on /etc/debmirror.conf for proper debian support
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
Restart cobblerd and then run 'cobbler sync' to apply changes.
|
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
server: 192.168.18.202
|
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
next_server: 192.168.18.202
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@node2 ~]# cobbler get-loaders
task started: 2013-11-04_143149_get_loaders
task started (id=Download Bootloader Content, time=Mon Nov 4 14:31:49 2013)
downloading http://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README
downloading http://www.cobblerd.org/loaders/COPYING.elilo to /var/lib/cobbler/loaders/COPYING.elilo
downloading http://www.cobblerd.org/loaders/COPYING.yaboot to /var/lib/cobbler/loaders/COPYING.yaboot
downloading http://www.cobblerd.org/loaders/COPYING.syslinux to /var/lib/cobbler/loaders/COPYING.syslinux
downloading http://www.cobblerd.org/loaders/elilo-3.8-ia64.efi to /var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://www.cobblerd.org/loaders/yaboot-1.3.14-12 to /var/lib/cobbler/loaders/yaboot
downloading http://www.cobblerd.org/loaders/pxelinux.0-3.61 to /var/lib/cobbler/loaders/pxelinux.0
downloading http://www.cobblerd.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32
downloading http://www.cobblerd.org/loaders/grub-0.97-x86.efi to /var/lib/cobbler/loaders/grub-x86.efi
downloading http://www.cobblerd.org/loaders/grub-0.97-x86_64.efi to /var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
|
1
2
3
4
|
[root@node2 ~]# vim /etc/xinetd.d/tftp
disable = no
[root@node2 ~]# vim /etc/xinetd.d/rsync
disable = no
|
1
2
|
[root@node2 ~]# service xinetd start
正在启动 xinetd: [确定]
|
1
2
3
4
|
[root@node2 ~]# vim /etc/debmirror.conf
#注释掉@dists="sid"与@arches="i386即可
#@dists="sid";
#@arches="i386";
|
1
2
|
[root@node2 ~]# openssl passwd -1 -salt 'hahaha' '123456'
$1$hahaha$hSxFjZSHRoiEn4DYrrGUI.
|
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$hahaha$hSxFjZSHRoiEn4DYrrGUI."
|
1
2
3
4
5
|
[root@node2 ~]# service cobblerd restart
Stopping cobbler daemon: [确定]
Starting cobbler daemon: [确定]
[root@node2 ~]# cobbler check
No configuration problems found. All systems go.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@node2 ~]# netstat -ntulp
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 1011/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1087/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1126/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 1607/sshd
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 12677/python
tcp 0 0 :::80 :::* LISTEN 1696/httpd
tcp 0 0 :::22 :::* LISTEN 1011/sshd
tcp 0 0 ::1:25 :::* LISTEN 1087/master
tcp 0 0 ::1:6010 :::* LISTEN 1126/sshd
tcp 0 0 ::1:6011 :::* LISTEN 1607/sshd
tcp 0 0 :::873 :::* LISTEN 12747/xinetd
udp 0 0 0.0.0.0:69 0.0.0.0:* 12747/xinetd
|
manage_dhcp:1
manage_dns:1
manage_tftpd:1
restart_dhcp:1
restart_dns:1
pxe_just_once:1
next_server:<服务器的 IP 地址>
server:<服务器的 IP 地址>
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
manage_dhcp: 1
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@node2 ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.18.0 netmask 255.255.255.0 {
option routers 192.168.18.254;
option domain-name-servers 8.8.8.8;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.18.221 192.168.18.225;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
|
1
2
3
|
[root@node2 ~]# service cobblerd restart
Stopping cobbler daemon: [确定]
Starting cobbler daemon: [确定]
|
1
2
|
[root@node2 ~]# vim /etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
|
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@node2 ~]# cobbler sync
task started: 2013-11-04_164727_sync
task started (id=Sync, time=Mon Nov 4 16:47:27 2013)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.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: 关闭 dhcpd:[确定]
正在启动 dhcpd:[确定]
received on stderr:
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 ***
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
[root@node2 ~]# cobbler
usage
=====
cobbler <distro|profile|system|repo|image|mgmtclass|package|file> ...
[add|edit|copy|getks*|list|remove|rename|report] [options|--help]
cobbler <aclsetup|buildiso|import|list|replicate|report|reposync|sync|validateks|version> [options|--help]
注,大家可以在上面的显示中可以看到cobbler命令有很多的选项,想获得相关选项的帮助只需要加--help即可。
[root@node2 ~]# cobbler profile --help
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report
[root@node2 ~]# cobbler profile add --help
Usage: cobbler [options]
Options:
-h, --help show this help message and exit
--name=NAME Name (Ex: F10-i386-webserver)
--uid=UID
--owners=OWNERS Owners (Owners list for authz_ownership (space
delimited))
--distro=DISTRO Distribution (Parent distribution)
--parent=PARENT Parent Profile
--enable-gpxe=ENABLE_GPXE
Enable gPXE? (Use gPXE instead of PXELINUX for
advanced booting options)
--enable-menu=ENABLE_MENU
Enable PXE Menu? (Show this profile in the PXE menu?)
--kickstart=KICKSTART
Kickstart (Path to kickstart template)
--kopts=KERNEL_OPTIONS
Kernel Options (Ex: selinux=permissive)
--kopts-post=KERNEL_OPTIONS_POST
Kernel Options (Post Install) (Ex: clocksource=pit
noapic)
--ksmeta=KS_META Kickstart Metadata (Ex: dog=fang agent=86)
--proxy=PROXY Proxy (Proxy URL)
--repos=REPOS Repos (Repos to auto-assign to this profile)
--comment=COMMENT Comment (Free form text description)
--virt-auto-boot=VIRT_AUTO_BOOT
Virt Auto Boot (Auto boot this VM?)
--virt-cpus=VIRT_CPUS
Virt CPUs (integer)
--virt-file-size=VIRT_FILE_SIZE
Virt File Size(GB)
--virt-disk-driver=VIRT_DISK_DRIVER
Virt Disk Driver Type (The on-disk format for the
virtualization disk)
--virt-ram=VIRT_RAM Virt RAM (MB)
--depth=DEPTH
--virt-type=VIRT_TYPE
Virt Type (Virtualization technology to use) (valid
options: xenpv,xenfv,qemu,kvm,vmware,openvz)
--virt-path=VIRT_PATH
Virt Path (Ex: /directory OR VolGroup00)
--virt-bridge=VIRT_BRIDGE
Virt Bridge
--dhcp-tag=DHCP_TAG DHCP Tag (See manpage or leave blank)
--server=SERVER Server Override (See manpage or leave blank)
--ctime=CTIME
--mtime=MTIME
--name-servers=NAME_SERVERS
Name Servers (space delimited)
--name-servers-search=NAME_SERVERS_SEARCH
Name Servers Search Path (space delimited)
--mgmt-classes=MGMT_CLASSES
Management Classes (For external configuration
management)
--mgmt-parameters=MGMT_PARAMETERS
Management Parameters (Parameters which will be handed
to your management application (Must be valid YAML
dictionary))
--boot-files=BOOT_FILES
TFTP Boot Files (Files copied into tftpboot beyond the
kernel/initrd)
--fetchable-files=FETCHABLE_FILES
Fetchable Files (Templates for tftp or wget)
--template-files=TEMPLATE_FILES
Template Files (File mappings for built-in config
management)
--redhat-management-key=REDHAT_MANAGEMENT_KEY
Red Hat Management Key (Registration key for RHN,
Spacewalk, or Satellite)
--redhat-management-server=REDHAT_MANAGEMENT_SERVER
Red Hat Management Server (Address of Spacewalk or
Satellite Server)
--template-remote-kickstarts=TEMPLATE_REMOTE_KICKSTARTS
--clobber allow add to overwrite existing objects
--in-place edit items in kopts or ksmeta without clearing the
other items
|
cobbler check #检查cobbler配置
cobbler sync #同步配置到dhcp/pxe和数据目录
cobbler list #列出所有的cobbler元素
cobbler import #导入安装的系统镜像
cobbler report #列出各元素的详细信息
cobbler distro #查看导入的发行版系统信息
cobbler profile #查看配置信息
cobbler system #查看添加的系统信息
cobbler reposync #同步yum仓库到本地
1
2
|
[root@node2 ~]# cobbler check
No configuration problems found. All systems go.
|
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@node2 ~]# cobbler sync
task started: 2013-11-11_133827_sync
task started (id=Sync, time=Mon Nov 11 13:38:27 2013)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.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: 关闭 dhcpd:[确定]
正在启动 dhcpd:[确定]
received on stderr:
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 ***
|
1
2
3
4
5
6
7
8
9
|
[root@node2 ~]# cobbler list
distros: #导入的发行版本
profiles: #安装的配置信息
systems: #增加的系统信息
repos: #yum仓库
images: #存储所有导入发行版的Kernel和initrd镜像用于远程网络启动
mgmtclasses:
packages:
files:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@node2 ~]# cobbler import --help
Usage: cobbler [options]
Options:
-h, --help show this help message and exit
--arch=ARCH OS architecture being imported
--breed=BREED the breed being imported
--os-version=OS_VERSION
the version being imported
--path=PATH local path or rsync location
--name=NAME name, ex 'RHEL-5'
--available-as=AVAILABLE_AS
tree is here, don't mirror
--kickstart=KICKSTART_FILE
assign this kickstart file
--rsync-flags=RSYNC_FLAGS
pass additional flags to rsync
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@node2 ~]# cobbler report
distros:
==========
profiles:
==========
systems:
==========
repos:
==========
images:
==========
mgmtclasses:
==========
packages:
==========
files:
==========
|
1
2
3
4
5
6
7
8
9
10
11
|
[root@node2 ~]# cobbler distro
usage
=====
cobbler distro add
cobbler distro copy
cobbler distro edit
cobbler distro find
cobbler distro list
cobbler distro remove
cobbler distro rename
cobbler distro report
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@node2 ~]# cobbler profile
usage
=====
cobbler profile add
cobbler profile copy
cobbler profile dumpvars
cobbler profile edit
cobbler profile find
cobbler profile getks
cobbler profile list
cobbler profile remove
cobbler profile rename
cobbler profile report
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@node2 ~]# cobbler system
usage
=====
cobbler system add
cobbler system copy
cobbler system dumpvars
cobbler system edit
cobbler system find
cobbler system getks
cobbler system list
cobbler system poweroff
cobbler system poweron
cobbler system powerstatus
cobbler system reboot
cobbler system remove
cobbler system rename
cobbler system report
|
1
2
3
4
5
6
7
8
9
|
[root@node2 ~]# cobbler system add --name=desktop-xfce-1 \
--profile=Fedora17-xfce \
--mac=52:54:00:b8:5e:8f \
--ip-address=192.168.122.10
[root@node2 ~]# cobbler system add --name=desktop-gnome-1 \
--profile=Fedora17-gnome \
--mac=52:54:00:88:f3:44 \
--ip-address=192.168.122.11
[root@node2 ~]# cobbler system report
|
1
2
3
4
5
6
|
[root@node2 ~]# cobbler reposync
task started: 2013-11-11_144127_reposync
task started (id=Reposync, time=Mon Nov 11 14:41:27 2013)
hello, reposync
run, reposync, run!
*** TASK COMPLETE ***
|
CentOS-5.5-x86_64-bin-DVD-1of2.iso
CentOS-6.4-x86_64-bin-DVD1.iso
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
|
[root@node2 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@node2 ~]# cd /mnt/
[root@node2 mnt]# ls
CentOS RELEASE-NOTES-cs RELEASE-NOTES-en_US RELEASE-NOTES-ja RELEASE-NOTES-ro
EULA RELEASE-NOTES-cs.html RELEASE-NOTES-en_US.html RELEASE-NOTES-ja.html RELEASE-NOTES-ro.html
GPL RELEASE-NOTES-de RELEASE-NOTES-es RELEASE-NOTES-nl repodata
images RELEASE-NOTES-de.html RELEASE-NOTES-es.html RELEASE-NOTES-nl.html RPM-GPG-KEY-beta
isolinux RELEASE-NOTES-en RELEASE-NOTES-fr RELEASE-NOTES-pt_BR RPM-GPG-KEY-CentOS-5
NOTES RELEASE-NOTES-en.html RELEASE-NOTES-fr.html RELEASE-NOTES-pt_BR.html TRANS.TBL
(5).使用cobbler import命令导入镜像
[root@node2 mnt]# cobbler import --help
Usage: cobbler [options]
Options:
-h, --help show this help message and exit
--arch=ARCH OS architecture being imported
--breed=BREED the breed being imported
--os-version=OS_VERSION
the version being imported
--path=PATH local path or rsync location
--name=NAME name, ex 'RHEL-5'
--available-as=AVAILABLE_AS
tree is here, don't mirror
--kickstart=KICKSTART_FILE
assign this kickstart file
--rsync-flags=RSYNC_FLAGS
pass additional flags to rsync
|
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@node2 ~]# cobbler import --path=/mnt/ --name=CentOS-5.5 --arch=x86_64
task started: 2013-11-11_154941_import
task started (id=Media import, time=Mon Nov 11 15:49:41 2013)
Found a candidate signature: breed=redhat, version=rhel5
Found a matching signature: breed=redhat, version=rhel5
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64:
creating new distro: CentOS-5.5-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64 -> /var/www/cobbler/links/CentOS-5.5-x86_64
creating new profile: CentOS-5.5-x86_64
creating new distro: CentOS-5.5-xen-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64 -> /var/www/cobbler/links/CentOS-5.5-xen-x86_64
creating new profile: CentOS-5.5-xen-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64 for CentOS-5.5-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/repodata/*comps*.xml
running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/repodata/comps.xml /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64
received on stdout: Spawning worker 0 with 3392 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
received on stderr:
starting descent into /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64 for CentOS-5.5-xen-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/repodata/*comps*.xml
*** TASK COMPLETE ***
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@node2 cobbler]# cobbler list
distros:
CentOS-5.5-x86_64
CentOS-5.5-xen-x86_64
profiles:
CentOS-5.5-x86_64
CentOS-5.5-xen-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
[root@node2 ks_mirror]# cobbler report
distros:
==========
Name : CentOS-5.5-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-5.5-x86_64'}
Management Classes : []
OS Version : rhel5
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
Name : CentOS-5.5-xen-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/xen/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/xen/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-5.5-xen-x86_64'}
Management Classes : []
OS Version : rhel5
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
profiles:
==========
Name : CentOS-5.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-5.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
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
Name : CentOS-5.5-xen-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-5.5-xen-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
Parent Profile :
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 : xenpv
systems:
==========
repos:
==========
images:
==========
mgmtclasses:
==========
packages:
==========
files:
==========
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
[root@node2 ~]# cobbler check
No configuration problems found. All systems go.
[root@node2 ~]# cobbler sync
task started: 2013-11-11_170434_sync
task started (id=Sync, time=Mon Nov 11 17:04:34 2013)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-5.5-x86_64
removing: /var/www/cobbler/images/CentOS-5.5-xen-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/images/CentOS-5.5-x86_64
removing: /var/lib/tftpboot/images/CentOS-5.5-xen-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: CentOS-5.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-5.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-5.5-x86_64/initrd.img
copying files for distro: CentOS-5.5-xen-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/xen/vmlinuz -> /var/lib/tftpboot/images/CentOS-5.5-xen-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/xen/initrd.img -> /var/lib/tftpboot/images/CentOS-5.5-xen-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-5.5-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-5.5-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-5.5-x86_64/initrd.img
Writing template files for CentOS-5.5-x86_64
copying files for distro: CentOS-5.5-xen-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/xen/vmlinuz -> /var/www/cobbler/images/CentOS-5.5-xen-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-5.5-x86_64/images/xen/initrd.img -> /var/www/cobbler/images/CentOS-5.5-xen-x86_64/initrd.img
Writing template files for CentOS-5.5-xen-x86_64
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: 关闭 dhcpd:[确定]
正在启动 dhcpd:[确定]
received on stderr:
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 ***
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@node2 mnt]# netstat -ntulp
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 1031/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1108/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1143/sshd
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 2015/python
tcp 0 0 :::80 :::* LISTEN 2030/httpd
tcp 0 0 :::22 :::* LISTEN 1031/sshd
tcp 0 0 ::1:25 :::* LISTEN 1108/master
tcp 0 0 ::1:6010 :::* LISTEN 1143/sshd
tcp 0 0 :::873 :::* LISTEN 1990/xinetd
udp 0 0 0.0.0.0:67 0.0.0.0:* 1974/dhcpd
udp 0 0 0.0.0.0:69 0.0.0.0:* 1990/xinetd
udp 0 0 0.0.0.0:69 0.0.0.0:* 1905/in.tftpd
|
PXE 服务
DHCP服务管理
DNS服务管理
HTTP服务管理
TFTP服务管理
Kickstart服务
yum仓库管理
电源管理
1
2
3
4
5
6
7
8
9
10
|
[root@node2 ~]# vim /etc/cobbler/dhcp.conf
subnet 192.168.18.0 netmask 255.255.255.0 {
option routers 192.168.18.254;
option domain-name-servers 192.168.18.254;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.18.221 192.168.18.225;
filename "/pxelinux.0"; #指定的网络引导程序
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server; #指定的TFTP服务器的地址
|
path 是镜像所挂载的目录
name 是导入到cobbler里面显示的名字
arch 是32位系统还是64位系统
name是表示添加的ks 的名字,用cobbler report可以看到这个名字
distro 是用哪个镜像,list的distros里面选择一个,需要版本相对应
kickstart 是具体的 ks 文件路径
删除指定 distro , 也就是镜像
删除指定的 profile 文件,也就是 ks
1
2
3
4
5
6
|
[root@node2 cobbler]# ls /etc/cobbler/
auth.conf cobblerd.service dnsmasq.template mongodb.conf rsync.exclude users.conf
cheetah_macros cobbler_web.conf import_rsync_whitelist named.template rsync.template users.digest
cobbler_bash completions iso power secondary.template version
cobbler.conf dhcp.template ldap pxe settings zone.template
cobblerd_rotate distro_signatures.json modules.conf reporting tftpd.template zone_templates
|
/etc/cobbler/settings cobbler主配置文件
/etc/cobbler/iso/ iso模板配置文件
/etc/cobbler/pxe pxe模板文件
/etc/cobbler/power 电源的配置文件
/etc/cobbler/users.conf Web 服务授权配置文件
/etc/cobbler/users.digest 用于web访问的用户名密码配置文件
/etc/cobbler/dhcp.template DHCP服务的配置模板
/etc/cobbler/dnsmasq.template DNS服务的配置模板
/etc/cobbler/tftpd.template tftp服务的配置模板
/etc/cobbler/modules.conf Cobbler模块配置文件
1
2
3
4
5
6
7
|
[root@node2 cobbler]# ls /var/lib/cobbler/
config distro_signatures.json kickstarts loaders lock scripts snippets triggers web.ss
[root@node2 config]# ls
distros.d files.d images.d mgmtclasses.d packages.d profiles.d repos.d systems.d
[root@node2 loaders]# ls
COPYING.elilo COPYING.yaboot grub-x86_64.efi menu.c32 README
COPYING.syslinux elilo-ia64.efi grub-x86.efi pxelinux.0 yaboot
|
/var/lib/cobbler/config/ 用于存放distros、systems、profiles等信息配置文件
/var/lib/cobbler/triggers 用于存放用户定义的cobbler 命令
/var/lib/cobbler/kickstarts/ 默认存放kickstart文件
/var/lib/cobbler/loaders 存放的各种引导程序
1
2
|
[root@node2 cobbler]# ls
aux images ks_mirror links localmirror pub rendered repo_mirror svc
|
/var/www/cobbler/ks_mirror/ 导入的发行版系统的所有数据
/var/www/cobbler/images/ 导入发行版的Kernel和initrd镜像用于远程网络启动
/var/www/cobbler/repo_mirror/ yum仓库存储目录
1
2
3
4
5
|
[root@node2 cobbler]# ls
anamon cobbler.log install.log kicklog syslog tasks
[root@node2 cobbler]# cat install.log
profile CentOS-5.5-x86_64 192.168.18.222 start 1384219313.49
profile CentOS-5.5-x86_64 192.168.18.222 stop 1384219512.05
|
/var/log/cobbler/install.log 客户端的安装系统日志
/var/log/cobbler/cobbler.log cobbler日志
1
2
3
4
5
|
[root@node2 kickstarts]# cd /var/lib/cobbler/kickstarts/
[root@node2 kickstarts]# ls
default.ks legacy.ks sample_end.ks sample_esxi5.ks sample.seed
esxi4-ks.cfg pxerescue.ks sample_esx4.ks sample.ks
esxi5-ks.cfg sample_autoyast.xml sample_esxi4.ks sample_old.seed
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
[root@node2 ~]# cobbler report
#上面部分内容省略
profiles:
==========
Name : CentOS-5.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-5.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
[root@node2 ~]# cat /var/lib/cobbler/kickstarts/sample.ks
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5 #用户登录认证
# System bootloader configuration
bootloader --location=mbr #mbr引导
# Partition clearing information
clearpart --all --initlabel #默认清除所以分区
# Use text mode install
text #默认以文本模式安装
# Firewall configuration
firewall --enabled #防火墙默认开启
# Run the Setup Agent on first boot
firstboot --disable #禁用启动代理
# System keyboard
keyboard us #默认英文键盘
# System language
lang en_US #默认语言英文
# Use network installation
url --url=$tree #网络安装路径
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza #默认的yum仓库
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot #安装完成后重启
#Root password
rootpw --iscrypted $default_password_crypted #密码是我们/etc/cobbler/settings设置密码
# SELinux configuration
selinux --disabled #默认关闭selinux
# Do not configure the X Window System
skipx #默认没有安装图形界面
# System timezone
timezone America/New_York #默认时区是美国/纽约
# Install OS instead of upgrade
install #定义的是安装系统而不是升级系统
# Clear the Master Boot Record
zerombr #默认清空所有的mbr
# Allow anaconda to partition the system as needed
autopart #默认自动分区
#下面就是Cobbler自定执行的一些脚本,我就不解释了。
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%packages
$SNIPPET('func_install_if_enabled')
$SNIPPET('puppet_install_if_enabled')
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('puppet_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
|
手动的修改已有的Kickstart文件
用system-config-kickstart工具生成Kickstart文件
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
|
[root@node2 ~]# cat anaconda-ks.cfg
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
cdrom
lang zh_CN.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted $6$rLcXd8hdqBw35VJ4$xMY155kcD1IULRuOW5AllU48obFbIgp11OBg72nPAE575mo8oC9Eqo8tGzJgtM2HkrDSciAGVUtCMXTjiIdaG.
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --none
#part /boot --fstype=ext4 --size=200
#part / --fstype=ext4 --size=10000
#part /data --fstype=ext4 --size=5000
#part swap --size=1000
repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
%packages
@chinese-support
@core
@development
@server-policy
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
[root@node2 ~]# cat /var/lib/cobbler/kickstarts/sample.ks
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone America/New_York
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
autopart
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%packages
$SNIPPET('func_install_if_enabled')
$SNIPPET('puppet_install_if_enabled')
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('puppet_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
[root@node2 ~]# cd /var/lib/cobbler/kickstarts/
[root@node2 kickstarts]# cp sample.ks centos.ks
[root@node2 kickstarts]# cat centos.ks
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --service=ssh #开启动防火墙但开放ssh服务
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone --utc Asia/Shanghai #时区修改为亚洲/上海
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
#下面定义的是默认分区,这个分区大小可以自己定义,单位为MB。由于我这里是虚拟机只有20的硬盘空间,所以我是这样划分的/boot 200MB、/ 10G 、/data 5G、swap 1G。
part /boot --fstype=ext4 --size=200
part / --fstype=ext4 --size=10000
part /data --fstype=ext4 --size=5000
part swap --size=1000
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%packages #这里增加了默认安装的软件包,包括对中文的支持与开发组件。
$SNIPPET('func_install_if_enabled')
$SNIPPET('puppet_install_if_enabled')
@chinese-support
@core
@development
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('puppet_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
|
1
|
[root@node2 ~]# yum install -y system-config-kickstart
|
1
|
[root@node2 ~]# system-config-kickstart
|
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
39
40
41
42
43
44
45
46
47
48
49
|
[root@node2 ~]# ls
anaconda-ks.cfg install.log install.log.syslog ks.cfg
[root@node2 ~]# cat ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.18.202/cobbler/ks_mirror/CentOS-5.5-x86_64/"
# Root password
rootpw --iscrypted $1$lNz9giZK$b.1VPUVpxYkCYd/Su.E5r1
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="ext4" --size=256
part / --fstype="ext4" --size=10000
part /data --fstype="ext4" --size=5000
part swap --fstype="swap" --size=1000
%packages
@chinese-support
@development
git
-ibus-table-cangjie
-ibus-table-erbi
-ibus-table-wubi
%end
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@node2 ~]# cobbler list
distros:
CentOS-5.5-x86_64
CentOS-5.5-xen-x86_64
profiles:
CentOS-5.5-x86_64
CentOS-5.5-xen-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
[root@node2 ~]# cobbler report
注,上面一些内容省略。
profiles:
==========
Name : CentOS-5.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-5.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata : {}
Management Classes : []
Management Parameters : <<inherit>>
Name Servers : []
Name Servers Search Path : []
Owners : ['admin']
……
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@node2 ~]# cobbler profile edit --name=CentOS-5.5-x86_64 --distro=CentOS-5.5-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos.ks
[root@node2 ~]# cobbler report
注,上面一些内容省略。
profiles:
==========
Name : CentOS-5.5-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-5.5-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/centos.ks
……
|
1
2
3
4
5
|
[root@node2 ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.N9dqlP: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
|
1
2
3
4
|
[root@node2 ~]# yum install -y ntp
[root@node2 ~]# ntpdate 202.120.2.101
13 Nov 15:14:52 ntpdate[1174]: step time server 202.120.2.101 offset -28799.776629 sec
[root@node2 ~]# hwclock -w
|
1
|
[root@node2 ~]# yum install -y cobbler tftp dhcp httpd cman pykickstart debmirror
|
1
|
[root@node2 ~]# yum install -y ed patch perl perl-Compress-Zlib perl-Digest-SHA1 perl-LockFile-Simple perl-libwww-perl
|
1
2
3
4
|
[root@node2 ~]# chkconfig httpd on
[root@node2 ~]# chkconfig dhcpd on
[root@node2 ~]# chkconfig xinetd on
[root@node2 ~]# chkconfig cobblerd on
|
1
2
3
4
5
6
|
[root@node2 ~]# vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1:80
[root@node2 ~]# service httpd start
正在启动 httpd: [确定]
[root@node2 ~]# netstat -ntulp | grep :80
tcp 0 0 :::80 :::* LISTEN 1525/httpd
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@node2 ~]# service cobblerd start
Starting cobbler daemon: [确定]
[root@node2 ~]# 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync
5 : comment out 'dists' on /etc/debmirror.conf for proper debian support
6 : comment out 'arches' on /etc/debmirror.conf for proper debian support
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
Restart cobblerd and then run 'cobbler sync' to apply changes.
|
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
server: 192.168.18.202
|
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
next_server: 192.168.18.202
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@node2 ~]# cobbler get-loaders
task started: 2013-11-04_143149_get_loaders
task started (id=Download Bootloader Content, time=Mon Nov 4 14:31:49 2013)
downloading http://www.cobblerd.org/loaders/README to /var/lib/cobbler/loaders/README
downloading http://www.cobblerd.org/loaders/COPYING.elilo to/var/lib/cobbler/loaders/COPYING.elilo
downloading http://www.cobblerd.org/loaders/COPYING.yaboot to/var/lib/cobbler/loaders/COPYING.yaboot
downloading http://www.cobblerd.org/loaders/COPYING.syslinux to/var/lib/cobbler/loaders/COPYING.syslinux
downloading http://www.cobblerd.org/loaders/elilo-3.8-ia64.efi to/var/lib/cobbler/loaders/elilo-ia64.efi
downloading http://www.cobblerd.org/loaders/yaboot-1.3.14-12 to/var/lib/cobbler/loaders/yaboot
downloading http://www.cobblerd.org/loaders/pxelinux.0-3.61 to/var/lib/cobbler/loaders/pxelinux.0
downloading http://www.cobblerd.org/loaders/menu.c32-3.61 to /var/lib/cobbler/loaders/menu.c32
downloading http://www.cobblerd.org/loaders/grub-0.97-x86.efi to/var/lib/cobbler/loaders/grub-x86.efi
downloading http://www.cobblerd.org/loaders/grub-0.97-x86_64.efi to/var/lib/cobbler/loaders/grub-x86_64.efi
*** TASK COMPLETE ***
|
1
2
3
4
|
[root@node2 ~]# vim /etc/xinetd.d/tftp
disable = no
[root@node2 ~]# vim /etc/xinetd.d/rsync
disable = no
|
1
2
|
[root@node2 ~]# service xinetd start
正在启动 xinetd: [确定]
|
1
2
3
4
|
[root@node2 ~]# vim /etc/debmirror.conf
#注释掉@dists="sid"与@arches="i386即可
#@dists="sid";
#@arches="i386";
|
1
2
|
[root@node2 ~]# openssl passwd -1 -salt 'hahaha' '123456'
$1$hahaha$hSxFjZSHRoiEn4DYrrGUI.
|
1
2
|
[root@node2 ~]# vim /etc/cobbler/settings
default_password_crypted: "$1$hahaha$hSxFjZSHRoiEn4DYrrGUI."
|
1
2
3
4
5
6
7
|
[root@node2 ~]# service cobblerd restart
Stopping cobbler daemon: [确定]
Starting cobbler daemon: [确定]
[root@node2 ~]# cobbler check
The following are potential configuration items that you may want to fix:
1 : service dhcpd is not running
Restart cobblerd and then run 'cobbler sync' to apply changes.
|
1
2
3
4
5
6
7
8
9
10
|
[root@node2 ~]# vim /etc/cobbler/dhcp.template
subnet 192.168.18.0 netmask 255.255.255.0 {
option routers 192.168.18.254;
option domain-name-servers 192.168.18.254;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.18.221 192.168.18.225;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
|
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
39
40
41
42
43
|
[root@node2 ~]# cobbler sync
task started: 2013-11-13_153610_sync
task started (id=Sync, time=Wed Nov 13 15:36:10 2013)
running pre-sync triggers
cleaning trees
mkdir: /var/lib/tftpboot/pxelinux.cfg
mkdir: /var/lib/tftpboot/grub
mkdir: /var/lib/tftpboot/s390x
mkdir: /var/lib/tftpboot/ppc
mkdir: /var/lib/tftpboot/etc
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_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.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: 正在启动 dhcpd:[确定]
received on stderr:
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@node2 ~]# cobbler check
No configuration problems found. All systems go.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@node2 ~]# service xinetd restart
停止 xinetd: [确定]
正在启动 xinetd:
[确定]
[root@node2 ~]# netstat -ntulp
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 1010/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1087/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1125/sshd
tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 1478/sshd
tcp 0 0 127.0.0.1:25151 0.0.0.0:* LISTEN 1643/python
tcp 0 0 :::80 :::* LISTEN 1525/httpd
tcp 0 0 :::22 :::* LISTEN 1010/sshd
tcp 0 0 ::1:25 :::* LISTEN 1087/master
tcp 0 0 ::1:6010 :::* LISTEN 1125/sshd
tcp 0 0 ::1:6011 :::* LISTEN 1478/sshd
tcp 0 0 :::873 :::* LISTEN 1777/xinetd
udp 0 0 0.0.0.0:67 0.0.0.0:* 1715/dhcpd
udp 0 0 0.0.0.0:69 0.0.0.0:* 1777/xinetd
udp 0 0 0.0.0.0:69 0.0.0.0:* 1618/in.tftpd
|
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
39
40
41
42
43
44
45
46
|
[root@node2 ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@node2 ~]# cd /mnt/
[root@node2 mnt]# ls
CentOS_BuildTag GPL Packages RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Testing-6
EFI images RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Debug-6 TRANS.TBL
EULA isolinux repodata RPM-GPG-KEY-CentOS-Security-6
[root@node2 ~]# cobbler import --path=/mnt/ --name=CentOS-6.4 --arch=x86_64
task started: 2013-11-13_154155_import
task started (id=Media import, time=Wed Nov 13 15:41:55 2013)
Found a candidate signature: breed=redhat, version=rhel6
Found a matching signature: breed=redhat, version=rhel6
Adding distros from path /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64:
creating new distro: CentOS-6.4-x86_64
trying symlink: /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64 -> /var/www/cobbler/links/CentOS-6.4-x86_64
creating new profile: CentOS-6.4-x86_64
associating repos
checking for rsync repo(s)
checking for rhn repo(s)
checking for yum repo(s)
starting descent into /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64 for CentOS-6.4-x86_64
processing repo at : /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64
need to process repo/comps: /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64
looking for /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/repodata/*comps*.xml
running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/repodata/2727fcb43fbe4c1a3588992af8c19e4d97167aee2f6088959221fc285cab6f72-c6-x86_64-comps.xml /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64
received on stdout: Spawning worker 0 with 3955 pkgs
Workers Finished
Gathering worker results
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
received on stderr:
*** TASK COMPLETE ***
[root@node2 ~]# cobbler list
distros:
CentOS-6.4-x86_64
profiles:
CentOS-6.4-x86_64
systems:
repos:
images:
mgmtclasses:
packages:
files:
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
[root@node2 ~]# cobbler report
distros:
==========
Name : CentOS-6.4-x86_64
Architecture : x86_64
TFTP Boot Files : {}
Breed : redhat
Comment :
Fetchable Files : {}
Initrd : /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/images/pxeboot/initrd.img
Kernel : /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/images/pxeboot/vmlinuz
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart Metadata : {'tree': 'http://@@http_server@@/cblr/links/CentOS-6.4-x86_64'}
Management Classes : []
OS Version : rhel6
Owners : ['admin']
Red Hat Management Key : <<inherit>>
Red Hat Management Server : <<inherit>>
Template Files : {}
profiles:
==========
Name : CentOS-6.4-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.4-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 :
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
systems:
==========
repos:
==========
images:
==========
mgmtclasses:
==========
packages:
==========
files:
==========
|
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
[root@node2 ~]# cd /var/lib/cobbler/kickstarts/
[root@node2 kickstarts]# cp sample_end.ks centos6.ks
[root@node2 kickstarts]# vim centos6.ks
# kickstart template for Fedora 8 and later.
# (includes %end blocks)
# do not use with earlier distros
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --service=ssh
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
url --url=$tree
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
$yum_repo_stanza
# Network information
$SNIPPET('network_config')
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $default_password_crypted
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
timezone --utc Asia/Shanghai
# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
part /boot --fstype=ext4 --size=200
part / --fstype=ext4 --size=10000
part /data --fstype=ext4 --size=5000
part swap --size=1000
%pre
$SNIPPET('log_ks_pre')
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
# Enable installation monitoring
$SNIPPET('pre_anamon')
%end
%packages
@chinese-support
@development
$SNIPPET('func_install_if_enabled')
%end
%post
$SNIPPET('log_ks_post')
# Start yum configuration
$yum_config_stanza
# End yum configuration
$SNIPPET('post_install_kernel_options')
$SNIPPET('post_install_network_config')
$SNIPPET('func_register_if_enabled')
$SNIPPET('download_config_files')
$SNIPPET('koan_environment')
$SNIPPET('redhat_register')
$SNIPPET('cobbler_register')
# Enable post-install boot notification
$SNIPPET('post_anamon')
# Start final steps
$SNIPPET('kickstart_done')
# End final steps
%end
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
[root@node2 ~]# cobbler profile edit --name=CentOS-6.4-x86_64 --distro=CentOS-6.4-x86_64 --kickstart=/var/lib/cobbler/kickstarts/centos6.ks
[root@node2 ~]# cobbler report
注,上面部分省略。
profiles:
==========
Name : CentOS-6.4-x86_64
TFTP Boot Files : {}
Comment :
DHCP Tag : default
Distribution : CentOS-6.4-x86_64
Enable gPXE? : 0
Enable PXE Menu? : 1
Fetchable Files : {}
Kernel Options : {}
Kernel Options (Post Install) : {}
Kickstart : /var/lib/cobbler/kickstarts/centos6.ks
|
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
39
40
41
42
43
44
45
46
47
|
[root@node2 ~]# cobbler sync
task started: 2013-11-13_163907_sync
task started (id=Sync, time=Wed Nov 13 16:39:07 2013)
running pre-sync triggers
cleaning trees
removing: /var/www/cobbler/images/CentOS-6.4-x86_64
removing: /var/lib/tftpboot/pxelinux.cfg/default
removing: /var/lib/tftpboot/grub/grub-x86_64.efi
removing: /var/lib/tftpboot/grub/images
removing: /var/lib/tftpboot/grub/efidefault
removing: /var/lib/tftpboot/grub/grub-x86.efi
removing: /var/lib/tftpboot/images/CentOS-6.4-x86_64
removing: /var/lib/tftpboot/s390x/profile_list
copying bootloaders
trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi
trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi
copying distros to tftpboot
copying files for distro: CentOS-6.4-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/images/pxeboot/vmlinuz -> /var/lib/tftpboot/images/CentOS-6.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/images/pxeboot/initrd.img -> /var/lib/tftpboot/images/CentOS-6.4-x86_64/initrd.img
copying images
generating PXE configuration files
generating PXE menu structure
copying files for distro: CentOS-6.4-x86_64
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/images/pxeboot/vmlinuz -> /var/www/cobbler/images/CentOS-6.4-x86_64/vmlinuz
trying hardlink /var/www/cobbler/ks_mirror/CentOS-6.4-x86_64/images/pxeboot/initrd.img -> /var/www/cobbler/images/CentOS-6.4-x86_64/initrd.img
Writing template files for CentOS-6.4-x86_64
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: 关闭 dhcpd:[确定]
正在启动 dhcpd:[确定]
received on stderr:
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 ***
|
[size=0.76em]Cobbler 更简单:Web 界面 [size=0.76em]您可能希望轻松地可视化 Cobbler 对象,并为每天的重复任务重用对象值。Cobbler 提供了一个很有用的 Web 界面,您可以通过该界面实现此目的。要使用这个界面,首先需要安装它的程序包: [size=0.76em]安装该程序包后,配置 Cobbler 授权和身份验证系统,以便您可以登录。配置位于文件 /etc/cobbler/modules.conf 中,类似于清单 9 中的代码: 清单 9. 默认的 Cobbler 授权和身份验证系统配置 [size=0.76em]清单 9 中的帮助注释表明,可使用 LDAP、PAM 和配置文件等身份验证选项。因为 PAM 非常常见,所以使用它执行身份验证。在授权一节中,定义哪些用户拥有使用该工具的官方许可。将 module 值设置为 authz_ownership,以便您可在 users.conf 文件中指定谁能够访问 Web 界面。配置类似于清单 10 中的代码: 清单 10. Cobbler Web 界面的身份验证和授权配置 [size=0.76em]保存该文件。接下来,您需要一个名为 myuser 的系统用户(如果没有,可使用 useradd myuser && passwd myuser 创建)。然后,打开文件 /etc/cobbler/users.conf 并将 myuser 添加到 admins 组(这个组拥有对象的完整访问权),如清单 11 所示: 清单 11. 将 myuser 添加到授权文件中的 admins 组 [size=0.76em]配置已完成。现在,重新启动 Cobbler 和 Apache 服务以应用更改: [size=0.76em]Web 界面很简单(参见图 2):左侧的菜单显示了配置类(比如存储库、系统、发行版和配置文件)、资源(用于配置管理)和操作(导入、同步)。单击一个配置类,就会在屏幕右侧列出所有对象。可通过每一项旁边的按钮(Edit、Copy、Rename、Delete)应用列表过滤器和执行不同操作。 图 2. Cobbler Web 界面 |
前言:这篇文章是系统运维www.osyunwei.com的作品,我只是根据实践了一下,出于对原作者的尊重附原文链接如下:
原文链接:http://www.osyunwei.com/archives/7606.html
根据文章的说明是可以完成所属功能的,不过原文章有点小问题,在本文中我已经修改过了,仅供大家参考,有问题大家交流,E-mail:lianglianghelloworld@yahoo.com
Cobbler服务器系统:CentOS5.10 64位
IP地址:192.168.21.128
需要安装部署的Linux系统:
eth0(第一块网卡,用于外网)IP地址段:192.168.21.160-192.168.21.200
eth1(第二块网卡,用于内网)IP地址段:10.0.0.160-10.0.0.200
子网掩码:255.255.255.0
网关:192.168.21.2
DNS:8.8.8.8 8.8.4.4
所有服务器均支持PXE网络启动
实现目的:通过配置Cobbler服务器,全自动批量安装部署Linux系统
具体操作步骤如下:
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
开启TCP:80端口、TCP:25151端口、UDP:69端口
vi /etc/sysconfig/iptables #编辑
-A RH-Firewall-1-INPUT -m state --state NEW-m tcp -p tcp --dport 80 -j ACCEPT #http服务需要此端口
-A RH-Firewall-1-INPUT -m state --state NEW-m udp -p udp --dport 69 -j ACCEPT #tftp服务需要此端口
-A RH-Firewall-1-INPUT -m state --state NEW-m tcp -p tcp --dport 25151 -j ACCEPT #cobbler需要此端口
:wq! #保存退出
/etc/init.d/iptables restart #最后重启防火墙使配置生效
cd /usr/local/src
wgethttp://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm #CentOS5.x 64位
rpm -ivh epel-release-5-4.noarch.rpm#企业版 Linux 附加软件包(以下简称 EPEL)
备注:
wgethttp://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm #CentOS5.x 32位
wgethttp://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm #CentOS6.x64位
wgethttp://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm #CentOS6.x32位
yum install cobbler tftp tftp-serverxinetd dhcp httpd rsync #安装cobbler
yum install pykickstart debmirror python-ctypes cman #安装运行cobbler需要的软件包
1、设置http服务
vi /etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_modulemodules/mod_wsgi.so #取消前面的注释
:wq! #保存退出
chkconfig httpd on #设置开机启动
service httpd start #启动
2、设置tftp服务开机启动
vi /etc/cobbler/tftpd.template #编辑
service tftp
{
disable =no #修改为no
socket_type= dgram
protocol= udp
wait= yes
user= root
server= /usr/sbin/in.tftpd
server_args = -B 1380 -v -s /tftpboot
per_source= 11
cps= 100 2
flags = IPv4
}
:wq! #保存退出
3、设置rsync服务开机启动
vi /etc/xinetd.d/rsync #编辑配置文件,设置开机启动rsync
service rsync
{
disable = no #修改为no
socket_type= stream
wait= no
user= root
server= /usr/bin/rsync
server_args= --daemon
log_on_failure+= USERID
}
:wq! #保存退出
/etc/init.d/xinetd start #启动(CentOS中是以xinetd 来管理Rsync和tftp服务的)
4、配置cobbler相关参数
vi /etc/debmirror.conf #注释掉 @dists 和 @arches 两行
#@dists="sid";
#@arches="i386";
:wq! #保存退出
openssl passwd -1 -salt 'osyunwei' '123456' #生成默认模板下系统安装完成之后root账号登录密码
$1$osyunwei$sEV8iwXXuR4CqzLXyLnzm0 #记录下这行,下面会用到
vi /etc/cobbler/settings #编辑,修改
default_password_crypted:"$1$osyunwei$sEV8iwXXuR4CqzLXyLnzm0"
next_server: 192.168.21.128
server: 192.168.21.128
manage_dhcp: 1
default_kickstart:/var/lib/cobbler/kickstarts/default.ks
:wq! #保存退出
系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容©版权所有,转载请注明出处及原文链接
5、配置dhcp服务器
vi /etc/cobbler/dhcp.template #编辑,修改
subnet 192.168.21.0 netmask 255.255.255.0{ #设置网段
option routers 192.168.21.2; #设置网关
option domain-name-servers 8.8.8.8,8.8.4.4; #设置dns服务器地址
option subnet-mask 255.255.255.0; #设置子网掩码
range dynamic-bootp 192.168.21.160192.168.21.200; #设置dhcp服务器IP地址租用的范围
default-lease-time 21600; #默认租约时间
max-lease-time 43200; #最大租约时间
next-server $next_server;
class "pxeclients" {
match if substring (optionvendor-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";
}
}
}
:wq! #保存退出
vi /etc/sysconfig/dhcpd #指定DHCP服务的网络接口
DHCPDARGS=eth0
:wq! #保存退出
dhcpd #测试dhcp服务器配置是否正确
chkconfig dhcpd on #设置开机启动
chkconfig cobblerd on #设置开机启动
cobbler get-loaders #安装cobbler相关工具包,否则检查cobbler配置会报错
service cobblerd start #启动cobbler
cobbler sync #同步配置文件到dhcp服务器
service dhcpd start #启动dhcp服务
6、设置cobbler相关服务启动脚本
vi /etc/rc.d/init.d/cobbler #编辑,添加以下代码
#!/bin/sh
# chkconfig: - 80 90
# description:cobbler
case $1 in
start)
/etc/init.d/httpd start
/etc/init.d/xinetd start
/etc/init.d/dhcpd start
/etc/init.d/cobblerd start
;;
stop)
/etc/init.d/httpd stop
/etc/init.d/xinetd stop
/etc/init.d/dhcpd stop
/etc/init.d/cobblerd stop
;;
restart)
/etc/init.d/httpd restart
/etc/init.d/xinetd restart
/etc/init.d/dhcpd restart
/etc/init.d/cobblerd restart
;;
status)
/etc/init.d/httpd status
/etc/init.d/xinetd status
/etc/init.d/dhcpd status
/etc/init.d/cobblerd status
;;
sync)
cobbler sync
;;
*)
echo "Input error,please in put'start|stop|restart|status|sync'!";
exit 2>&1 >/dev/null &
;;
esac
:wq! #保存退出
chmod +x /etc/rc.d/init.d/cobbler #添加脚本执行权限
chkconfig cobbler on #添加开机启动
service cobbler restart #重启cobbler
cobbler check #检查cobbler配置,出现下面的提示,SELinux和防火墙前面已经设置过了,不用理会
The following are potential configurationitems that you may want to fix:
1 : SELinux is enabled. Please review thefollowing wiki page for details on ensuring cobbler works correctly in your SELinuxenvironment:
https://github.com/cobbler/cobbler/wiki/Selinux
2 : since iptables may be running, ensure69, 80/443, and 25151 are unblocked
Restart cobblerd and then run 'cobblersync' to apply changes
=====================================================================================
上传系统安装镜像文件CentOS-5.10-x86_64-bin-DVD-1of2.iso到/usr/local/src/目录
mkdir -p/var/www/html/os/CentOS-5.10-x86_64 #创建挂载目录
mount -t iso9660 -o loop/usr/local/src/CentOS-5.10-x86_64-bin-DVD-1of2.iso /var/www/html/os/CentOS-5.10-x86_64 #挂载系统镜像
vi /etc/fstab #添加以下代码。实现开机自动挂载
/usr/local/src/CentOS-5.10-x86_64-bin-DVD-1of2.iso /var/www/html/os/CentOS-5.10-x86_64 iso9660 defaults,ro,loop 0 0
:wq! #保存退出
备注:iso9660使用df -T查看设备卸载:umount /var/www/html/os/CentOS-5.10-x86_64
重复上面的操作,把自己需要安装的CentOS系统镜像文件都挂载到/var/www/html/os/目录下
例如:
CentOS-5.10-x86_64-bin-DVD-1of2.iso
CentOS-6.5-x86_64-bin-DVD1.iso
cd /var/lib/cobbler/kickstarts #进入默认Kickstart模板目录
vi/var/lib/cobbler/kickstarts/CentOS-5.10-x86_64.ks #创建CentOS-5.10-x86_64安装脚本
# Kickstart file automatically generated byanaconda.
install
url--url=http://192.168.21.128/cobbler/ks_mirror/CentOS-5.10-x86_64/
lang en_US.UTF-8
zerombr yes
key --skip
keyboard us
network --device eth0 --bootprotodhcp --onboot on
#network --device eth0 --bootproto static--ip 192.168.21.250 --netmask 255.255.255.0 --gateway 192.168.21.2 --nameserver8.8.8.8 --hostname CentOS5.10
rootpw --iscrypted$1$QqobZZ1g$rYnrawi9kYlEeUuq1vcRS/
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda
# The following is the partitioninformation you requested
# Note that any partitions you deleted arenot expressed
# here so unless you clear all partitionsfirst, this is
# not guaranteed to work
#clearpart --linux
clearpart --all --initlabel
part / --bytes-per-inode=4096--fstype="ext3" --size=2048
part /boot --bytes-per-inode=4096--fstype="ext3" --size=128
part swap --bytes-per-inode=4096--fstype="swap" --size=500
part /data --bytes-per-inode=4096--fstype="ext3" --grow --size=1
reboot
%packages
ntp
@base
@core
@dialup
@editors
@text-internet
keyutils
trousers
fipscheck
device-mapper-multipath
%post
#同步系统时间
ntpdate cn.pool.ntp.org
hwclock --systohc
echo -e "0 1 * * * root/usr/sbin/ntpdate cn.pool.ntp.org > /dev/null" >>/etc/crontab
service crond restart
#添加用户组
groupadd maintain
groupadd develop
mkdir -p /home/maintain
mkdir -p /home/develop
#添加用户
useradd -g maintain user01 -d/home/maintain/user01 -m
echo "123456"|passwd user01--stdin
useradd -g maintain user02 -d/home/maintain/user02 -m
echo "123456"|passwd user02--stdin
useradd -g maintain user03 -d/home/maintain/user03 -m
echo "123456"|passwd user03--stdin
useradd -g maintain user04 -d/home/maintain/user04 -m
echo "123456"|passwd user04--stdin
#禁止root用户直接登录系统
sed -i "s/#PermitRootLoginyes/PermitRootLogin no/g" '/etc/ssh/sshd_config'
service sshd restart
#禁止开机启动的服务
chkconfig acpid off
chkconfig atd off
chkconfig autofs off
chkconfig bluetooth off
chkconfig cpuspeed off
chkconfig firstboot off
chkconfig gpm off
chkconfig haldaemon off
chkconfig hidd off
chkconfig ip6tables off
chkconfig isdn off
chkconfig messagebus off
chkconfig nfslock off
chkconfig pcscd off
chkconfig portmap off
chkconfig rpcgssd off
chkconfig rpcidmapd off
chkconfig yum-updatesd off
chkconfig sendmail off
#允许开机启动的服务
chkconfig crond on
chkconfig kudzu on
chkconfig network on
chkconfig readahead_early on
chkconfig sshd on
chkconfig syslog on
#禁止使用Ctrl+Alt+Del快捷键重启服务器
sed -i"s/ca::ctrlaltdel:\/sbin\/shutdown -t3 -rnow/#ca::ctrlaltdel:\/sbin\/shutdown -t3 -r now/g" '/etc/inittab'
telinit q
#优化系统内核
echo -e "ulimit -cunlimited" >> /etc/profile
echo -e "ulimit -sunlimited" >> /etc/profile
echo -e "ulimit -SHn 65535" >> /etc/profile
source /etc/profile
sed -i "s/net.ipv4.ip_forward =0/net.ipv4.ip_forward = 1/g" '/etc/sysctl.conf'
echo -e "net.core.somaxconn =262144" >> /etc/sysctl.conf
echo -e "net.core.netdev_max_backlog =262144" >> /etc/sysctl.conf
echo -e "net.core.wmem_default =8388608" >> /etc/sysctl.conf
echo -e "net.core.rmem_default =8388608" >> /etc/sysctl.conf
echo -e "net.core.rmem_max =16777216" >> /etc/sysctl.conf
echo -e "net.core.wmem_max =16777216" >> /etc/sysctl.conf
echo -e"net.ipv4.netfilter.ip_conntrack_max = 131072" >> /etc/sysctl.conf
echo -e"net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180" >> /etc/sysctl.conf
echo -e "net.ipv4.route.gc_timeout =20" >> /etc/sysctl.conf
echo -e "net.ipv4.ip_conntrack_max =819200" >> /etc/sysctl.conf
echo -e "net.ipv4.ip_local_port_range= 10024 65535" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_retries2 =5" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_fin_timeout =30" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_syn_retries =1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_synack_retries =1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_timestamps =0" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_tw_recycle =1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_tw_len =1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_tw_reuse =1" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_keepalive_time =120" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_keepalive_probes= 3" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_keepalive_intvl= 15" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_tw_buckets =36000" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_orphans =3276800" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_max_syn_backlog= 262144" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_wmem = 8192131072 16777216" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_rmem = 32768131072 16777216" >> /etc/sysctl.conf
echo -e "net.ipv4.tcp_mem = 94500000915000000 927000000" >> /etc/sysctl.conf
/sbin/sysctl -p
#执行外部脚本
cd /root
wgethttp://192.168.21.128/cobbler/ks_mirror/config/autoip.sh
sh /root/autoip.sh
:wq! #保存退出
vi/var/www/cobbler/ks_mirror/config/autoip.sh #创建脚本,自动设置Linux系统静态IP地址、DNS、网关、计算机名称
#!/bin/sh
ROUTE=$(route -n|grep"^0.0.0.0"|awk '{print $2}')
BROADCAST=$(/sbin/ifconfig eth0|grep -ibcast|awk '{print $3}'|awk -F":" '{print $2}')
HWADDR=$(/sbin/ifconfig eth0|grep -iHWaddr|awk '{print $5}')
IPADDR=$(/sbin/ifconfig eth0|grep"inet addr"|awk '{print $2}'|awk -F":" '{print $2}')
NETMASK=$(/sbin/ifconfig eth0|grep"inet addr"|awk '{print $4}'|awk -F":" '{print $2}')
cat >/etc/sysconfig/network-scripts/ifcfg-eth0<<EOF
DEVICE=eth0
BOOTPROTO=static
BROADCAST=$BROADCAST
HWADDR=$HWADDR
IPADDR=$IPADDR
NETMASK=$NETMASK
GATEWAY=$ROUTE
ONBOOT=yes
EOF
IPADDR1=$(echo $IPADDR|awk -F"."'{print $4}')
cat>/etc/sysconfig/network-scripts/ifcfg-eth1<<EOF
DEVICE=eth1
BOOTPROTO=static
BROADCAST=10.0.0.255
HWADDR=$(/sbin/ifconfig eth1|grep -iHWaddr|awk '{print $5}')
IPADDR=10.0.0.$IPADDR1
NETMASK=255.255.255.0
ONBOOT=yes
EOF
HOSTNAME=OsYunWei_HZ_$(echo $IPADDR|awk-F"." '{print $4}')
cat >/etc/sysconfig/network<<EOF
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=$HOSTNAME
GATEWAY=$ROUTE
EOF
echo "127.0.0.1 $HOSTNAME">> /etc/hosts
hostname=$HOSTNAME
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4">> /etc/resolv.conf
:wq! #保存退出
cobbler import--path=/var/www/html/os/CentOS-5.10-x86_64 --name=CentOS-5.10-x86_64 --arch=x86_64 #导入系统镜像文件,需要一段时间
cd /var/www/cobbler/ks_mirror #进入系统镜像导入目录
命令格式:cobbler import --path=镜像路径 -- name=安装引导名 --arch=32位或64位
重复上面的操作,把其他的系统镜像文件导入到cobbler
按照操作系统版本分别关联系统镜像文件和kickstart自动安装文件
在第一次导入系统镜像时,cobbler会给安装镜像指定一个默认的kickstart自动安装文件
例如:CentOS-5.10-x86_64版本的kickstart自动安装文件为:/var/lib/cobbler/kickstarts/sample.ks
cobbler profile report --name CentOS-5.10-x86_64 #查看profile设置
cobbler distro report --nameCentOS-5.10-x86_64 #查看安装镜像文件信息
cobbler profile remove--name=CentOS-5.10-x86_64 #移除profile
cobbler profile add--name=CentOS-5.10-x86_64 --distro=CentOS-5.10-x86_64--kickstart=/var/lib/cobbler/kickstarts/CentOS-5.10-x86_64.ks #添加
cobbler profile edit--name=CentOS-5.10-x86_64 --distro=CentOS-5.10-x86_64--kickstart=/var/lib/cobbler/kickstarts/CentOS-5.10-x86_64.ks #编辑
命令:cobbler profile add|edit|remove --name=安装引导名 --distro=系统镜像名 --kickstart=kickstart自动安装文件路径
--name:自定义的安装引导名,注意不能重复
--distro:系统安装镜像名,用cobblerdistro list可以查看
--kickstart:与系统镜像文件相关联的kickstart自动安装文件
#查看Cobbler列表
cobbler list
cobbler report
cobbler profile report
cobbler distro list
#通过profile查找对应的kickstart自动安装文件文件
例如:
ksfile=$( cobbler profile report --name CentOS-5.10-x86_64|grep -E '^Kickstart' |head -n 1|cut -d ':' -f 2 );cat$ksfile;
重复上面的操作,把其他的系统镜像文件和kickstart自动安装文件关联起来
注意:
1、kickstart自动安装文件需要预先配置好
2、每次修改完配置文件,需要执行一次同步操作:cobbler sync 配置才能生效
3、kickstart自动安装文件可以用工具生成(需要用到图形界面操作)
yum install system-config-kickstart #安装
yum groupinstall "X WindowSystem" #安装X Window图形界面
system-config-kickstart #运行kickstart配置
service cobbler sync #与cobbler sync作用相同
service cobbler restart #重启cobbler
开机之后,如下图所示,根据需要选择相应的系统版本进行安装,安装完成之后,系统会自动重启
在需要重装系统的服务器上安装koan
wget http://dl.fedoraproject.org/pub/epel/5/x86_64/koan-2.4.4-1.el5.noarch.rpm #CentOS5.X
rpm -ivh koan-2.4.0-1.el5.noarch.rpm #安装koan
http://dl.fedoraproject.org/pub/epel/6/x86_64/koan-2.4.0-1.el6.noarch.rpm #CentOS6.X
yum install cobbler debmirror pykickstart python-ctypes cman #安装koan运行依赖包(需要设置epel源)
koan --list=profiles --server=192.168.21.128 #查看Cobbler服务器系统镜像列表
koan --replace-self --server=192.168.21.128--profile=CentOS-5.10-x86_64 #选择要重装的系统
reboot #重新启动系统进行自动安装
Cobbler目录说明:
1、Cobbler配置文件目录:/etc/cobbler
/etc/cobbler/settings #cobbler主配置文件
/etc/cobbler/dhcp.template #DHCP服务的配置模板
/etc/cobbler/tftpd.template #tftp服务的配置模板
/etc/cobbler/rsync.template #rsync服务的配置模板
/etc/cobbler/iso #iso模板配置文件
/etc/cobbler/pxe #pxe模板文件
/etc/cobbler/power #电源的配置文件
/etc/cobbler/users.conf #Web服务授权配置文件
/etc/cobbler/users.digest #用于web访问的用户名密码配置文件
/etc/cobbler/dnsmasq.template #DNS服务的配置模板
/etc/cobbler/modules.conf #Cobbler模块配置文件
2、Cobbler数据目录:/var/lib/cobbler
/var/lib/cobbler/config #配置文件
/var/lib/cobbler/triggers #Cobbler命令
/var/lib/cobbler/kickstarts #默认存放kickstart文件
/var/lib/cobbler/loaders #存放的各种引导程序
3、系统安装镜像目录:/var/www/cobbler
/var/www/cobbler/ks_mirror #导入的系统镜像列表
/var/www/cobbler/images #导入的系统镜像启动文件
/var/www/cobbler/repo_mirror #yum源存储目录
4、日志目录:/var/log/cobbler
/var/log/cobbler/install.log #客户端系统安装日志
/var/log/cobbler/cobbler.log #cobbler日志
至此,Cobbler全自动批量安装部署Linux系统完成。
在安装过程当中会有各种惊人的问题,我遇到的问题已经记录在我的博客中,建议遇到问题的时候去搜索吧,这样快一点。
文中不再使用原作者的图片,请原作者谅解,用我自己的图片也说明我是一步一步脚踏实地的按照原作者的文章来做事可以成功的嘛,欢迎大家批评指正。