在CentOS7中 部署cobbler自動裝機
阿新 • • 發佈:2018-05-17
cobbler自動裝機centos7 cobbler web登錄 在CentOS7中 部署cobbler Cobbler是一個Linux安裝服務器,它允許快速安裝網絡安裝環境。它聚合並自動化了許多相關的Linux任務,因此在部署新系統時,不必在許多不同的命令和應用程序之間跳躍,在某些情況下,還需要更改現有的系統。Cobbler可以幫助配置、管理DNS和DHCP、包更新、電源管理、配置管理業務流程等等。
實驗需要的安裝包: cobbler(linux安裝服務器) cobbler-web(前端界面管理 可以通過網頁形式進行管理) dhcp(自動分配IP) tftp-server (文件傳輸協議 用於放壓縮內核和引導文件) pykickstart(用於閱讀和編寫kickstart文件) rsync(數據鏡像備份工具,遠程同步管理和支持本地復制) xinetd(網絡守護進程服務程序 用於管理rsync 和 tftp) httpd (這裏用於檢查cobbler文件安裝 和web管理)
.
實驗的系統環境 虛擬機:centos7系統 (網卡選用NET模式 選定dhcp 可以實現訪問網絡) # vim /etc/sysconfig/network-scripts/ifcfg-ens33 //編輯網卡 ONBOOT=yes (修改成yes) # systemctl restart network.service //重啟網絡服務 # mount.cifs //192.168.198.128/gx /opt/ //掛載共享文件到/opt # rpm -ivh /opt/epel-release-latest-7.noarch.rpm //安裝epel-release-latest-7.noarch.rpm # mount /dev/sr0 /mnt //掛載cdrom # yum list //加載yum (直接下載安裝包)
.
1:安裝 配置cobber # yum install cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd -y //安裝cobbler cobbler-web dhcp tftp-server pykickstart httpd rsync xinetd #vim /etc/cobbler/settings //編輯cobbler主配置文件 next_server: 192.168.235.129 //指定PXE位置 server: 192.168.235.129 manage_dhcp: 1 //管理dhcp啟動
2:重啟服務關閉防火墻
# systemctl restart httpd.service //重啟httpd服務
# systemctl start cobblerd.service //開啟cobbler服務
# systemctl stop firewalld.service //關閉防火墻
# setenforce 0 //關閉增強安全功能
# cobbler check //cobble 檢測
------------------------提示內容:需要優化--------------------------
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 : change ‘disable‘ to ‘no‘ in /etc/xinetd.d/tftp
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
8 : 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.
.
3:設置裝機後的根密碼
# openssl passwd -1 -salt ‘123456‘ ‘123456‘ //給密碼123456 鹽值加密
$1$123456$wOSEtcyiP2N/IfIl15W6Z0 (復制生成的密碼的加密代碼)
# vim /etc/cobbler/settings //修改配置文件
default_password_crypted: " $1$123456$wOSEtcyiP2N/IfIl15W6Z0 ." //粘貼上面復制代碼
4:下載引導操作系統文件、 啟動rsncd服務 、編輯tftp
# cobbler get-loaders //下載引導操作系統文件
# systemctl start rsyncd.service //啟動服務
# vim /etc/xinetd.d/tftp //編輯tftp
disable = no //啟用
# systemctl restart xinetd.service //重啟服務
5:配置dhcp
# vim /etc/cobbler/dhcp.template //cobbler控制的dhcp服務模板
subnet 192.168.198.0 netmask 255.255.255.0 {
option routers 192.168.198.1; //修改網關
option domain-name-servers 192.168.198.2; //修改DNS
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.198.100 192.168.198.200; //修改地址池
# cobbler sync //幫助同步生成DHCP配置文件
# systemctl restart dhcpd.service //啟動dhcpd服務
6:使用cobbler check再次檢查
# cobbler check //cobble 檢測
下面三條可以忽略不去處理
7:導入鏡像
# cobbler import --path=/mnt/ --name=CentOS-7-x86_64 --arch=x86_64 //導入iso鏡像
# cobbler list //查看導入結果
# cobbler distro list //查看發行版本
# yum install tree -y //安裝tree
# tree /var/lib/tftpboot/images //查看內核和初始化文件在tftp server 共享目錄
8:服務全重啟一遍
# systemctl restart cobblerd.service
# systemctl restart dhcpd.service
# systemctl restart xinetd.service
# systemctl restart httpd.service
# cobbler profile report //查看cobbler概要報告
.
9:新建虛擬機測試安裝
選擇稍後安裝
虛擬機為centos 64位
網絡選擇和服務器一樣的NAT網卡
內存2G 硬盤40G
然後開啟虛擬機 進入安裝
10:選擇Centos-7-x86_64 進入自動安裝
安裝完成
11:進入web管理cobbler
# htdigest -c /etc/cobbler/users.digest Cobbler cbadmin
//創建Cobbler類型的用戶cbadmin 寫到users.digest文件中
輸入兩次確認密碼 例如:123456
# systemctl restart cobblerd.service //重啟cobbler 服務
# systemctl restart httpd.service //重啟 httpd 服務
在宿主機瀏覽器打開 https://192.168.198.128/cobbler_web
輸入 賬戶為 cbadmin 密碼為 123456
12:通過pam認證 進入web管理cobbler
# vim /etc/cobbler/modules.conf
[authentication]
module = authn_pam //修改pam認證
[authorization]
module = authz_ownership //在users.conf指定訪問權限
useradd webuser //創建用戶webuser
# passwd webuser //設置密碼123456
# vim /etc/cobbler/users.conf //編輯user.conf
[admins]
admin = ""
cobbler = ""
webuser = "" //添加該行
systemctl restart cobblerd.service //重啟cobbler 服務
# systemctl restart httpd.service //重啟 httpd 服務
在宿主機瀏覽器打開 https://192.168.198.128/cobbler_web
輸入 賬戶為 webuser 密碼為 123456
在CentOS7中 部署cobbler自動裝機