标签:cobbler
Cobbler是一个快速网络安装linux的服务,而且在经过调整也可以支持网络安装windows。该工具使用python开发,小巧轻便(才15k行代码),使用简单的命令即可完成PXE网络安装环境的配置,同时还可以管理DHCP,DNS,以及yum包镜像。
Cobbler支持命令行管理,web界面管理,还提供了API接口,可以方便二次开发使用
# yum install cobbler 安装cobbler # service httpd start 文件服务器 [root@MinR dhcp]# service cobblerd start 启动cobbler [root@node3 ~]# cobbler check 检查cobbler环境是否正常 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 : debmirror package is not installed, it will be required to manage debian deployments and repositories 6 : ksvalidator was not found, install pykickstart 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
可以看到这里一共有8个报错,要挨个手动修复
[root@node3 ~]# vim /etc/cobbler/setting 编辑文件 server: 172.16.17.12 修改 next_server: 172.16.17.12 [root@node3 ~]# yum list syslinux 检查syslinux 是否已安装,这里已然安装 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Installed Packages syslinux.x86_64 4.02-8.el6 @base [root@node3 ~]# chkconfig rsync on 让rsync开机启动 [root@node3 ~]# yum install pykickstart 安装pykickstart 修改默认密码 [root@node3 ~]# openssl passwd -1 -salt `openssl rand -hex 4` Password: $1$28ad5f04$Q/rTKOO5LqSXaIXfuUTz31 把上面的字串复制替换默认的加密密码 default_password_crypted: "$1$28ad5f04$Q/rTKOO5LqSXaIXfuUTz31." [root@node3 ~]# service cobblerd restart Stopping cobbler daemon: [ OK ] Starting cobbler daemon: [ OK ] [root@node3 ~]# cobbler check The following are potential configuration items that you may want to fix: 1 : 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. 2 : debmirror package is not installed, it will be required to manage debian deployments and repositories 3 : 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@node3 syslinux]# cp -r ./* /var/lib/cobbler/loaders/ 复制所需文件 编辑 /etc/cobbler/setting不用自带的tftp manage_tftpd: 0 [root@node3 ~]# yum -y install dhcp 安装dhcp [root@node3 ~]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf 编辑dhcp的配置文件 [root@node3 ~]# vim /etc/dhcp/dhcpd.conf option domain-name "example.org"; option domain-name-servers 172.16.0.1; default-lease-time 43200; max-lease-time 86400; subnet 172.16.0.0 netmask 255.255.0.0 { range 172.16.100.101 172.16.100.200; option routers 172.16.17.12; } next-server 172.16.17.12; filename="pxelinux.0"; [root@node3 ~]# service dhcpd restart 启动dhcp Starting dhcpd: [ OK ] [root@node3 ~]# yum -y install tftp-server 安装tftp这里已经安装过 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Setting up Install Process Package tftp-server-0.49-7.el6.x86_64 already installed and latest version Nothing to do [root@node3 ~]# chkconfig tftp on 启动tftp [root@node3 ~]# service xinetd start Starting xinetd: [ OK ] [root@node3 ~]# cobbler distro –help disrto命令 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 [root@node3 ~]# mount -r /dev/cdrom /mnt 挂载镜像文件 [root@node3 ~]# cobbler import –help import命令 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 [root@node3 ~]# cobbler import --path=/mnt --name=centos-6.5-x86_64 创建yum源 task started: 2014-09-29_232236_import task started (id=Media import, time=Mon Sep 29 23:22:36 2014) 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.5-x86_64: creating new distro: centos-6.5-x86_64 trying symlink: /var/www/cobbler/ks_mirror/centos-6.5-x86_64 -> /var/www/cobbler/links/centos-6.5-x86_64 creating new profile: centos-6.5-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.5-x86_64 for centos-6.5-x86_64 processing repo at : /var/www/cobbler/ks_mirror/centos-6.5-x86_64 need to process repo/comps: /var/www/cobbler/ks_mirror/centos-6.5-x86_64 looking for /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/*comps*.xml running: createrepo -c cache -s sha --groupfile /var/www/cobbler/ks_mirror/centos-6.5-x86_64/repodata/b4e0b9342ef85d3059ff095fa7f140f654c2cb492837de689a58c581207d9632-c6-x86_64-comps.xml /var/www/cobbler/ks_mirror/centos-6.5-x86_64 received on stdout: Spawning worker 0 with 3995 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@node3 ~]# cobbler distro list centos-6.5-x86_64
下载和配置kickstart文件
[root@node3 ~]# wget http://172.16.0.1/centos6.x86_64.cfg --2014-09-29 23:37:30-- http://172.16.0.1/centos6.x86_64.cfg Connecting to 172.16.0.1:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2823 (2.8K) [text/plain] Saving to: “centos6.x86_64.cfg” 100%[=========================================================================>] 2,823 --.-K/s in 0s 2014-09-29 23:37:31 (62.8 MB/s) - “centos6.x86_64.cfg” saved [2823/2823] [root@node3 ~]# ksvalidator centos6.x86_64.cfg 验证是否有语法错误 [root@node3 ~]# cobbler profile add --name=centos-6.5-x86_64-basic --distro=centos-6.5-x86_64 --kickstart=/root/centos6.x86_64.cfg [root@node3 ~]# cobbler profile list centos-6.5-x86_64 centos-6.5-x86_64-basic [root@node3 ~]# cobbler sync 此时就可以实现自动给无操作系统的大规模主机安装操作系统了。 [root@node3 ~]# yum install cobbler-web [root@node3 ~]# cd /etc/cobbler/[root@node3 cobbler]# vim modules.conf [authentication]module = authn_pam [root@node3 cobbler]# useradd cobbleradmin 随便添加个用户[root@node3 cobbler]# passwd cobbleradmin 给用户设定密码Changing password for user cobbleradmin.New password: BAD PASSWORD: it is based on a dictionary wordBAD PASSWORD: is too simpleRetype new password: passwd: all authentication tokens updated successfully. [root@node3 cobbler]# vim users.conf [admins]admin = "cobbleradmin"cobbler = ""
浏览器中输入查看
标签:cobbler
原文地址:http://tliss.blog.51cto.com/6883268/1560770