通過 Windows 命令提示符(cmd)在桌面新建文件夾,并在該文件夾中編譯、運行一段 Java 程序段
876
2025-03-31
公司購買了一推二手服務器,得裝系統,測試各個硬件的可用性,裝系統,要是這一切要用U盤裝的話廢了
有的服務器是裝完系統進不去,反復的網絡啟動,有的磁盤有問題,有的網卡有問題,有的主板和CPU有問題的,總算裝系統測試一周搞出來了,這一切沒有cobbler的話真的的廢了
cobbler:是自動化裝系統的工具,是PXE的升級版,PXE不能一下多臺的服務器,不然會卡死,cobbler批量化很好
準備:
導入yum源 curl?-O?http://mirrors.aliyun.com/repo/Centos-7.repo curl?-O?http://mirrors.aliyun.com/repo/epel-7.repo yum??clean?all yum?makecache 關閉selinux 關閉firewall
Cobbler:安裝
前提:cobbler由epel源提供,故此需要事先配置指向epel的yum源方可進行類似下面的安裝過程。
[root@k8s-master1?yum.repos.d]#?yum?install?cobbler?cobbler-web?pykickstart?debmirror[root@k8s-master1?yum.repos.d]#?yum?install?cobbler?pykickstart?debmirror?httpd?syslinux???dhcp??tftp?xinetd?rsync?cobbler-web
TypeScript
[root@localhost?~]#?rpm?-ql?cobbler??#?查看安裝的文件,下面列出部分。/etc/cobbler??????????????????#?配置文件目錄/etc/cobbler/settings?????????#?cobbler主配置文件,這個文件是YAML格式,Cobbler是python寫的程序。/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模塊配置文件/var/lib/cobbler??????????????#?Cobbler數據目錄/var/lib/cobbler/config???????#?配置文件/var/lib/cobbler/kickstarts???#?默認存放kickstart文件/var/lib/cobbler/loaders??????#?存放的各種引導程序/var/www/cobbler??????????????#?系統安裝鏡像目錄/var/www/cobbler/ks_mirror????#?導入的系統鏡像列表/var/www/cobbler/images???????#?導入的系統鏡像啟動文件/var/www/cobbler/repo_mirror??#?yum源存儲目錄/var/log/cobbler??????????????#?日志目錄/var/log/cobbler/install.log??#?客戶端系統安裝日志/var/log/cobbler/cobbler.log??#?cobbler日志
啟動服務:
[root@k8s-master1?~]#?systemctl?start?httpd[root@k8s-master1?~]#?systemctl?enable?httpd.service[root@k8s-master1?~]#?systemctl?start?cobblerd.service[root@k8s-master1?~]#?systemctl?enable?cobblerd.service
檢查cobbler存在的問題
[root@k8s-master1?~]#?cobbler?check執行“cobbler?check命令檢查存的問題,而后逐一按提示解決之。常見的問題如下所示: 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?'dists'?on?/etc/debmirror.conf?for?proper?debian?support 6?:?comment?'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 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.
解決部分:
如上各問題的解決方法如下所示:1、修改/etc/cobbler/settings文件中的server參數的值為提供cobbler服務的主機相應的IP地址或主機名,如172.16.100.15;2、修改/etc/cobbler/settings文件中的next_server參數的值為提供PXE服務的主機相應的IP地址,如172.16.100.16;3、如果當前節點可以訪問互聯網,執行“cobbler?get-loaders”命令即可;否則,需要安裝syslinux程序包,而后復制/usr/share/syslinux/{pxelinux.0,memu.c32}等文件至/var/lib/cobbler/loaders/目錄中;4、執行“systemctl?start?rsyncd.service,systemctl?enable?rsyncd.service”命令即可;5、注釋/etc/debmirror.conf文件中的“@dists="sid";”一行;6、注釋/etc/debmirror.conf文件中的“@arches="i386";”一行;7、執行“openssl?passwd?-1?-salt?'random-phrase-here'?'123456'”生成密碼,并用其替換/etc/cobbler/settings文件中default_password_crypted參數的值;8、執行“yum?install?cman?fence-agents”命令安裝相應的程序包即可;
systemctl?restart?cobblerd.service 接著重啟cobblerd,而后執行“cobbler?sync?;?cobbler???check?”同步新的配置至cobbler。 No?configuration?problems?found.??All?systems?go.?????#顯示這個就成功了
二、配置及啟動cobbler所依賴的各服務
cobbler的運行依賴于dhcp、tftp、rsync及dns服務。
其中dhcp可由dhcpd(isc)提供,也可由dnsmasq提供;
tftp可由tftp-server程序包提供,也可由cobbler自帶的tftp功能提供;
rsync由rsync程序包提供;
dns可由bind提供,也可由dnsmasq提供。
cobbler可自行管理這些服務中的部分甚至是全部,但需要配置/etc/cobbler/settings文件中的“manage_dhcp”、“manage_tftpd”、“manage_rsync”和“manage_dns”分別進行定義。另外,由于每種服務都有著不同的實現方式,如若需要進行自定義,需要通過修改/etc/cobbler/modules.conf配置文件中各服務的模塊參數的值來實現。
通過cobbler來管理dns,tftp,dhcp配置:
vim?/etc/cobbler/settings?????????#用cobbler管理時不用去配置dhcp配置文件,是去配置cobbler的模板文件/vim?/etc/cobbler/dhcp.template????????? manage_dhcp:?1 vim?/etc/xinetd.d/tftp ?disable?????????????????=?no
vim?/etc/cobbler/dhcp.template???????#配置dhcp模板文件ddns-update-style?interim;allow?booting;allow?bootp;ignore?client-updates;set?vendorclass?=?option?vendor-class-identifier;option?pxe-system-type?code?93?=?unsigned?integer?16;subnet?192.168.100.0?netmask?255.255.255.0?{ ?????option?routers?????????????192.168.100.2; ?????option?domain-name-servers?8.8.8.8; ?????option?subnet-mask?????????255.255.255.0; ?????range?dynamic-bootp????????192.168.100.100?192.168.100.110; ?????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?if?option?pxe-system-type?=?00:09?{ ??????????????????filename?"grub/grub-x86_64.efi"; ??????????}?else?{ ??????????????????filename?"pxelinux.0"; ??????????} ?????}}systemctl?restart?cobblerd cobbler?sync??????????#同步一下
到此為止服務部署好了
cobbler?distro???#定義cobbler的系統cobbler?profile???#定義kicstart文件????路徑/var/lib/cobbler/kickstarts/
掛載好系統鏡像
mount?/dev/cdrom?/mnt/
cobbler里導入鏡像文件
cobbler?import?--path=/mnt/?--name=CentOS-7.3-X86_64?--arch=x86_64 ????--path=/mnt/??????#鏡像路徑 ????--name=CentOS-7.3-X86_64?????#鏡像名稱 ????--arch=x86_64??????????#系統平臺管理profile(kickstart)
cobbler使用profile來為特定的需求類別提供所需要安裝配置,即在distro的基礎上通過提供kickstart文件來生成一個特定的系統安裝配置。distro的profile可以出現在PXE的引導菜單中作為安裝的選擇之一。
導入kicstart文件寫入kicstart文件profile的指定
vim?/var/lib/cobbler/kickstarts/CentOS-7.3-X86_64.cfg http://www.90geek.com/post/cobbler%E7%9A%84kickstart%E6%96%87%E4%BB%B6.html 把文件加入到profile里 cobbler?profile?add?--name=CentOS-7.3-X86_64-x86_64?--distro=CentOS-7.3-X86_64-x86_64?--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.3-X86_64.cfg
可使用“cobbler profile list”查看已經創建的profile。
[root@k8s-master1?www]#?cobbler?distro?list????#查看鏡像 ???CentOS-7.3-X86_64-x86_64[root@k8s-master1?www]#?cobbler?profile?list????#查看kicstart文件 ???CentOS-7.3-X86_64-x86_64??? [root@k8s-master1?www]#?cobbler?profile?report??#查看這個profile文件Kickstart??????????????????????:?/var/lib/cobbler/kickstarts/sample_end.ks????#kicstart文件改成自己的剛才定義的[root@k8s-master1?www]#?cobbler?profile?edit?--name=CentOS-7.3-X86_64-x86_64?--kickstart=/var/lib/cobbler/kickstarts/CentOS-7.3-X86_64.cfg[root@k8s-master1?www]#?cobbler?profile?report????#再檢查
CentOS7 系統網卡名是eno..? 為了統一標準修改為常用的et0管理才執行下一步
[root@k8s-master1?www]#?cobbler?profile?edit?--name=CentOS-7.3-X86_64-x86_64?--kopts='net.ifnames=0?biosdevname=0'[root@k8s-master1?www]#?cobbler?sync???#同步
使用cobbler_web
配置cobbler_web的認證功能
cobbler_web支持多種認證方式,如authn_configfile、authn_ldap或authn_pam等,默認為authn_denyall,即拒絕所有用戶登錄。下面說明兩種能認證用戶登錄cobbler_web的方式。
1.1 使用authn_pam模塊認證cobbler_web用戶
首先修改modules中[authentication]段的module參數的值為authn_pam。
接著添加系統用戶,用戶名和密碼按需設定即可,例如下面的命令所示。
#?useradd?cblradmin#?echo?'cblrpass'?|?passwd?--stdin?cblradmin
而后將cblradmin用戶添加至cobbler_web的admin組中。修改/etc/cobbler/users.conf文件,將cblradmin用戶名添加為admin參數的值即可,如下所示。
[root@k8s-master1?www]#?vim?/etc/cobbler/users.conf[admins]admin?=?"cblradmin"
最后重啟cobblerd服務,通過https://192.168.163.130/cobbler_web訪問即可。
全部自動化,用cobbler的system功能來指定 (主機名及靜態ip地址,dns,網管地址)
不配置這個的話會讓你開機就出現個藍屏的選擇的步驟!!!
但是得提前知道該服務器網絡啟動的網卡的MAC地址!!!
[root@k8s-master1?www]#?cobbler?system?add?--name=006?--mac=2C:76:8a:5d:88:08??--profile=CentOS-7.3-X86_64-x86_64??--ip-address=192.168.100.16?--subnet=255.255.255.0?--gateway=192.168.100.2?--interface=eno1? --static=1?--hostname=006?--name-servers="233.5.5.5?233.6.6.6"
# --name 自定義,但不能重復
# 查看定義的列表
[root@k8s-master1?www]#?cobbler?system?list
[root@k8s-master1?www]#?cobbler?sync
到這里后可以服務器網卡啟動了,然后就自動裝上了,裝完看主機名地址都被配好的
部署一切完成
2。要是到哪臺服務器上給他重裝個系統的話不用把他重新啟動網卡啟動,直接是命令行重裝即可
yum?install?koan 查看server上的profile koan?--server=192.168.10.12?--list=profiles -?looking?for?Cobbler?at?http://192.168.10.12:80/cobbler_api CentOS-7.3-X86_64-x86_64 用上面返回的profile來重裝 koan?--replace-self?--server=192.168.10.12?--profile=CentOS-7.3-X86_64-x86_64 就開始給這臺服務器重裝系統了!!
3.圖形界面很好弄,這里不用寫了!!!
華為云APP
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。