频道栏目
首页 > 资讯 > Linux > 正文

cobbler实现批量部署Linux服务器(rhel6.5)

17-09-12        来源:[db:作者]  
收藏   我要投稿
linux安装系统的方法(传统):

1,光盘 把iso镜像刻录(windows下有类似nero这类软件)到光盘里,通过光驱,再修改BIOS第一启动顺序为光驱进行安装

2,u盘    把iso镜像刻录(windows下有类似nero这类软件)到U盘里(具体过程请上网自已查),通过USB接口,再修改BIOS第一启动顺序为U盘进行安装

3,硬盘   在linux硬盘上有iso镜像,可以通过grub进行硬盘安装第二个操作系统,或者重装系统(只重格根分区,不要重格iso所在的分区)

4,网络

实验环境:rhel6.5、

拓扑图:

cobbler server ------- client 192.168.100.2/24

安装前准备: (这里特别要注意一点:你的虚拟机的cobbler-server的/var目录空间最少要有4G以上空间) 1,关闭iptables,selinux 2,配置静态IP 3,设置主机名 4,时间同步 5,配置本地iso镜像里的yum仓库 我这里直接把宿主机里的镜像/share/iso/rhel-server-6.5-x86_64-dvd.iso直接放到cobbler server虚拟机的光驱里 # mkdir /yum # mount /dev/cdrom /yum

第一大步:在cobbler server上安装cobbler

确认配置好yum后,直接下面一条命令把相关软件包全安装上(基本的yum源就好) # yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart

第二大步:基本配置 # cobbler check --查看cobbler潜在的需要修改的选项(有可能因为你的httpd启不来,而选成无法显示下面的结果;按报错去解决它) 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment: https://github.com/cobbler/cobbler/wiki/Selinux 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync 6 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 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. --说明:上面我这里是有9个需求(不同的机器和环境可能会不一样,按照它的说明去解决就可以了) 解决需求1,需求2,需求8: # openssl passwd -1 -salt 'werwqerwqr' '123456' --123456为密码(这是自动安装客户端系统成功后的root登录密码),werwqerwqr为随机字节干扰码(随便写) $1$werwqerw$.prcfrYFbwuvkD8XspayN. # vim /etc/cobbler/settings (前面的数字为行数) 384 server: 192.168.100.2 --换成cobbler服务器端的IP 272 next_server: 192.168.100.2 --同上 101 default_password_crypted: "$1$werwqerw$.prcfrYFbwuvkD8XspayN." --把密码字符串换成你上面产生的字符串(此密码为客户机安装后的root登录密码) # /etc/init.d/cobblerd restart --修改后重启 解决需求3 关闭selinux # vim /etc/selinux/config --把下面的改成disabled,然后reboot你的系统 SELINUX=disabled --如果真的要完全关闭,必须按上面的操作并重启生效;如果你觉得麻烦,可以使用setenforce 0暂时代替 解决需求5 # vim /etc/xinetd.d/rsync disable = no --yes改为no 解决需求6 # /etc/init.d/iptables stop # chkconfig iptables off 或者开启iptables,但要开放69, 80/443, 25151这几个端口 解决需求9 # yum install fence-agents 解决了上面的问题后,再次cobbler check # cobbler check --解决了上面的问题,只余下两个问题了(问题1可以使用cobbler get-loaders解决,但需要有外网和外网的yum源;问题2是关于debian系统的,我们这里可以忽略) 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 Restart cobblerd and then run 'cobbler sync' to apply changes. 第三大步:导入镜像 # ls /var/www/cobbler/ks_mirror/ config # cobbler import --path=/yum/ --name=rhel6.5-x86-64 --将挂载的镜像目录/yum位置导入到cobbler,name后面接的是你取的一个名称 。。。。。。 *** TASK COMPLETE *** # ls /var/www/cobbler/ks_mirror/ --导入完后,这里会多了刚导入的镜像目录 config rhel6.5-x86-64 # cobbler distro list --列表你cobbler导入的镜像 rhel6.5-64-x86_64 # cobbler profile list --列表你的cobbler自动安装方案(从这里看到你导入一个镜像会默认做一个与它同名的安装方案) rhel6.5-64-x86_64 --cobbler可以实现多种不同的iso镜像导入,并且每个iso镜像还可以对应多种不同安装方法(也就是说一个distro可以对应多个profile) 第四大步: 修改dhcp,让cobbler来管理dhcp,并进行cobbler配置同步 修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板(不需要象kickstart那样去修改/etc/dhcp/dhcpd.conf,修改了也没用,它会在后面做cobbler sync时把/etc/cobbler/dhcp.template拷过去覆盖/etc/dhcp/dhcpd.conf文件,并启动dhcp) 只修改下面这一段,改成你自己对应的IP和网段就可以了 # vim /etc/cobbler/dhcp.template subnet 192.168.100.0 netmask 255.255.255.0 { --改你分配的网段,掩码 option routers 192.168.100.2; --改你分配的网关 option domain-name-servers 192.168.100.2; --改你分配的DNS指向 option subnet-mask 255.255.255.0; --改你分配的IP的掩码 range dynamic-bootp 192.168.100.200 192.168.100.254; --改你分配的IP的范围(到时装机的client) 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"; } } } # vim /etc/cobbler/settings --再去修改这个配置文件,改成dhcp服务由cobbler来管理 242 manage_dhcp: 1 --把0改为1 # /etc/init.d/cobblerd restart --保存后,再重启此服务 # cobbler sync --同步cobbler配置,并初始化,帮你启动dhcp等 。。。。。。 *** TASK COMPLETE *** # /etc/init.d/xinetd restart --把xinetd服务重启一下 第五大步: 测试验证:新建一个vmnet1网段(因为我前面配置的是这个网段)的虚拟机,然后启动,会出现cobbler的引导安装界面,选择并自动安装(这里自动安装的系统没有图形界面,默认只安装417个包而已) ====================================================================================

欢迎评论区交流!(常年在线!)

1,光盘 把iso镜像刻录(windows下有类似nero这类软件)到光盘里,通过光驱,再修改BIOS第一启动顺序为光驱进行安装

2,u盘    把iso镜像刻录(windows下有类似nero这类软件)到U盘里(具体过程请上网自已查),通过USB接口,再修改BIOS第一启动顺序为U盘进行安装

3,硬盘   在linux硬盘上有iso镜像,可以通过grub进行硬盘安装第二个操作系统,或者重装系统(只重格根分区,不要重格iso所在的分区)

4,网络

实验环境:rhel6.5、

拓扑图:

cobbler server ------- client 192.168.100.2/24

安装前准备: (这里特别要注意一点:你的虚拟机的cobbler-server的/var目录空间最少要有4G以上空间) 1,关闭iptables,selinux 2,配置静态IP 3,设置主机名 4,时间同步 5,配置本地iso镜像里的yum仓库 我这里直接把宿主机里的镜像/share/iso/rhel-server-6.5-x86_64-dvd.iso直接放到cobbler server虚拟机的光驱里 # mkdir /yum # mount /dev/cdrom /yum

第一大步:在cobbler server上安装cobbler

确认配置好yum后,直接下面一条命令把相关软件包全安装上(基本的yum源就好) # yum install cobbler cobbler-web tftp* rsync xinetd http* syslinux dhcp* pykickstart

第二大步:基本配置 # cobbler check --查看cobbler潜在的需要修改的选项(有可能因为你的httpd启不来,而选成无法显示下面的结果;按报错去解决它) 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 : SELinux is enabled. Please review the following wiki page for details on ensuring cobbler works correctly in your SELinux environment: https://github.com/cobbler/cobbler/wiki/Selinux 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 : change 'disable' to 'no' in /etc/xinetd.d/rsync 6 : since iptables may be running, ensure 69, 80/443, and 25151 are unblocked 7 : debmirror package is not installed, it will be required to manage debian deployments and repositories 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. --说明:上面我这里是有9个需求(不同的机器和环境可能会不一样,按照它的说明去解决就可以了) 解决需求1,需求2,需求8: # openssl passwd -1 -salt 'werwqerwqr' '123456' --123456为密码(这是自动安装客户端系统成功后的root登录密码),werwqerwqr为随机字节干扰码(随便写) $1$werwqerw$.prcfrYFbwuvkD8XspayN. # vim /etc/cobbler/settings (前面的数字为行数) 384 server: 192.168.100.2 --换成cobbler服务器端的IP 272 next_server: 192.168.100.2 --同上 101 default_password_crypted: "$1$werwqerw$.prcfrYFbwuvkD8XspayN." --把密码字符串换成你上面产生的字符串(此密码为客户机安装后的root登录密码) # /etc/init.d/cobblerd restart --修改后重启 解决需求3 关闭selinux # vim /etc/selinux/config --把下面的改成disabled,然后reboot你的系统 SELINUX=disabled --如果真的要完全关闭,必须按上面的操作并重启生效;如果你觉得麻烦,可以使用setenforce 0暂时代替 解决需求5 # vim /etc/xinetd.d/rsync disable = no --yes改为no 解决需求6 # /etc/init.d/iptables stop # chkconfig iptables off 或者开启iptables,但要开放69, 80/443, 25151这几个端口 解决需求9 # yum install fence-agents 解决了上面的问题后,再次cobbler check # cobbler check --解决了上面的问题,只余下两个问题了(问题1可以使用cobbler get-loaders解决,但需要有外网和外网的yum源;问题2是关于debian系统的,我们这里可以忽略) 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 Restart cobblerd and then run 'cobbler sync' to apply changes. 第三大步:导入镜像 # ls /var/www/cobbler/ks_mirror/ config # cobbler import --path=/yum/ --name=rhel6.5-x86-64 --将挂载的镜像目录/yum位置导入到cobbler,name后面接的是你取的一个名称 。。。。。。 *** TASK COMPLETE *** # ls /var/www/cobbler/ks_mirror/ --导入完后,这里会多了刚导入的镜像目录 config rhel6.5-x86-64 # cobbler distro list --列表你cobbler导入的镜像 rhel6.5-64-x86_64 # cobbler profile list --列表你的cobbler自动安装方案(从这里看到你导入一个镜像会默认做一个与它同名的安装方案) rhel6.5-64-x86_64 --cobbler可以实现多种不同的iso镜像导入,并且每个iso镜像还可以对应多种不同安装方法(也就是说一个distro可以对应多个profile) 第四大步: 修改dhcp,让cobbler来管理dhcp,并进行cobbler配置同步 修改/etc/cobbler/dhcp.template,此文件是cobbler管理dhcp的模板(不需要象kickstart那样去修改/etc/dhcp/dhcpd.conf,修改了也没用,它会在后面做cobbler sync时把/etc/cobbler/dhcp.template拷过去覆盖/etc/dhcp/dhcpd.conf文件,并启动dhcp) 只修改下面这一段,改成你自己对应的IP和网段就可以了 # vim /etc/cobbler/dhcp.template subnet 192.168.100.0 netmask 255.255.255.0 { --改你分配的网段,掩码 option routers 192.168.100.2; --改你分配的网关 option domain-name-servers 192.168.100.2; --改你分配的DNS指向 option subnet-mask 255.255.255.0; --改你分配的IP的掩码 range dynamic-bootp 192.168.100.200 192.168.100.254; --改你分配的IP的范围(到时装机的client) 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"; } } } # vim /etc/cobbler/settings --再去修改这个配置文件,改成dhcp服务由cobbler来管理 242 manage_dhcp: 1 --把0改为1 # /etc/init.d/cobblerd restart --保存后,再重启此服务 # cobbler sync --同步cobbler配置,并初始化,帮你启动dhcp等 。。。。。。 *** TASK COMPLETE *** # /etc/init.d/xinetd restart --把xinetd服务重启一下 第五大步: 测试验证:新建一个vmnet1网段(因为我前面配置的是这个网段)的虚拟机,然后启动,会出现cobbler的引导安装界面,选择并自动安装(这里自动安装的系统没有图形界面,默认只安装417个包而已) ====================================================================================

欢迎评论区交流!(常年在线!)
相关TAG标签
上一篇:lxc的简单介绍和使用
下一篇:Python基础学习<七>
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站