點擊返回架構師成長之路html
Cobbler是一個Linux服務器安裝的服務,能夠經過網絡啓動(PXE)的方式來快速安裝、重裝物理服務器和虛擬機,同時還能夠管理DHCP,DNS等。python
Cobbler 使用 Python 開發,小巧輕便。( 號稱是補鞋匠都能學會的工具 )linux
Cobbler可使用命令行方式管理,也提供了基於Web的界面管理工具(cobbler-web),還提供了API接口,能夠方便二次開發使用。web
Cobbler是較早前的kickstart的升級版,優勢是比較容易配置,還自帶web界面比較易於管理。shell
Cobbler內置了一個輕量級配置管理系統,但它也支持和其它配置管理系統集成,如Puppet,暫時不支持SaltStack。api
使用Cobbler,您無需進行人工干預便可安裝機器。Cobbler設置一個PXE引導環境(它還可使用yaboot支持PowerPC),並 控制與安裝相關的全部方面,好比網絡引導服務(DHCP和TFTP)與存儲庫鏡像。當但願安裝一臺新機器時,Cobbler能夠:安全
2.1 關閉關閉 SELinux 、iptables服務器
必定要關閉,不然安裝必定會出問題。網絡
vi /etc/selinux/config #將SELINUX=enforcing改成SELINUX=disabled 設置後須要重啓才能生效
firewall-cmd --state #查看默認防火牆狀態,關閉後顯示not running,開啓後顯示running systemctl stop firewalld.service #臨時關閉firewall systemctl disable firewalld.service #禁止firewall開機啓動
2.2 支撐環境安裝架構
rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum -y install cobbler httpd rsync tftp-server xinetd dhcp pykickstart fence-agents
安裝完成後將在/etc/yum.repos.d 下面生成一個epel.repo文件
[epel] name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo] name=Extra Packages for Enterprise Linux 7 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1 [epel-source] name=Extra Packages for Enterprise Linux 7 - $basearch - Source #baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch failovermethod=priority enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 gpgcheck=1
此時安裝cobbler-web會在生成/etc/httpd/conf.d/生成cobbler.conf文件
# This configuration file allows cobbler data # to be accessed over HTTP. AliasMatch ^/cblr(?!/svc/)(.*)?$ "/var/www/cobbler$1" #別名匹配 AliasMatch ^/cobbler_track(.*)?$ "/var/www/cobbler$1" #AliasMatch ^/cobbler(.*)?$ "/var/www/cobbler$1" Alias /cobbler /var/www/cobbler #設置別名 Alias /cobbler_webui_content /var/www/cobbler_webui_content #設置別名 WSGIScriptAliasMatch ^/cblr/svc/([^/]*) /var/www/cobbler/svc/services.py <Directory "/var/www/cobbler"> #設置目錄 SetEnv VIRTUALENV Options Indexes FollowSymLinks Order allow,deny Allow from all </Directory> ProxyRequests off ProxyPass /cobbler_api http://127.0.0.1:25151/ #設置代理,本機代理 ProxyPassReverse /cobbler_api http://127.0.0.1:25151/ BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On # the webui is now part of the "cobbler-web" package # and is visited at http://.../cobbler_web not this URL. # this is only a pointer to the new page. <Directory "/var/www/cobbler/web/"> Options Indexes FollowSymLinks Order allow,deny Allow from all </Directory> <IfVersion >= 2.4> <Location /cblr> Require all granted </Location> </IfVersion>
2.3 啓動http與cobbler,,, 檢查cobbler
systemctl start httpd systemctl start cobblerd
cobbler check #檢查cobbler,告訴你完成cobbler須要完成如下7步驟
The following are potential configuration items that you may want to fix: 1 : The 'server' field in /etc/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it. 2 : For PXE to be functional, the 'next_server' field in /etc/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network. 3 : change 'disable' to 'no' in /etc/xinetd.d/tftp 4 : Some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely. Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements. 5 : enable and start rsyncd.service with systemctl 6 : debmirror package is not installed, it will be required to manage debian deployments and repositories 7 : 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. # 最後一步很重要不要忘記
2.4 如今安裝以上步驟一步一步安裝cobbler
第一步:
vi /etc/cobbler/settings
第二步:
第三步:
vi /etc/xinetd.d/tftp
第四步:
cobbler get-loaders
第五步:
systemctl start rsyncd
第六步: 不須要
第七步:
openssl passwd -1 -salt 'coble' 'cobler' # 運行會生成一串隨機密碼
vi /etc/cobbler/settings #將101行default_password_crypted後面的密碼更換成上面的隨機密碼
重啓一下,並cobbler check一下:
2.5 設置DHCP
第一步:
vi /etc/cobbler/settings #將242行manage_dhcp:0 變成 1
第二步:
vi /etc/cobbler/dhcp.template # 修改模板文件
systemctl restart cobblerd cobbler sync
task started: 2018-11-15_230808_sync task started (id=Sync, time=Thu Nov 15 23:08:08 2018) running pre-sync triggers cleaning trees removing: /var/lib/tftpboot/grub/images copying bootloaders trying hardlink /var/lib/cobbler/loaders/pxelinux.0 -> /var/lib/tftpboot/pxelinux.0 trying hardlink /var/lib/cobbler/loaders/menu.c32 -> /var/lib/tftpboot/menu.c32 trying hardlink /var/lib/cobbler/loaders/yaboot -> /var/lib/tftpboot/yaboot trying hardlink /usr/share/syslinux/memdisk -> /var/lib/tftpboot/memdisk trying hardlink /var/lib/cobbler/loaders/grub-x86.efi -> /var/lib/tftpboot/grub/grub-x86.efi trying hardlink /var/lib/cobbler/loaders/grub-x86_64.efi -> /var/lib/tftpboot/grub/grub-x86_64.efi copying distros to tftpboot copying images generating PXE configuration files generating PXE menu structure rendering DHCP files generating /etc/dhcp/dhcpd.conf rendering TFTPD files generating /etc/xinetd.d/tftp cleaning link caches running post-sync triggers running python triggers from /var/lib/cobbler/triggers/sync/post/* running python trigger cobbler.modules.sync_post_restart_services running: dhcpd -t -q received on stdout: received on stderr: running: service dhcpd restart received on stdout: received on stderr: Redirecting to /bin/systemctl restart dhcpd.service running shell triggers from /var/lib/cobbler/triggers/sync/post/* running python triggers from /var/lib/cobbler/triggers/change/* running python trigger cobbler.modules.scm_track running shell triggers from /var/lib/cobbler/triggers/change/* *** TASK COMPLETE ***
2.6 導入鏡像
.....