歡迎您光臨本站 註冊首頁

Ubuntu12.04的自動化部署工具MAAS學習筆記

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

Ubuntu12.04的自動化部署工具MAAS學習筆記

首先下載包mini.iso

http://mirrors.sohu.com/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/

和precise-ephemeral-maas-amd64.tar.gz

https://maas.ubuntu.com/images/ephemeral/releases/precise/release-20120424/ ,

這兩個是maas的工具,都是用來安裝系統的,當然如果你網速可以的話可以用工具自動下載,我這裡下載是因為要做實驗,不用每次都下載了。

說下MAAS吧,就是Ubuntu12.04開始推廣的一個自動化部署工具 ,可以打包設定系統工具,然後通過網路聯機的方式部署到其它機器,

MAAS分為兩種狀態,有DHCP服務的,和沒有DHCP服務的。

一、你不擁有網路的控制權

1、自動安裝
root@lapvc:/home/maas# apt-get install maas dnsmasq debmirror

我看別人的資料是不介意安裝dhcp和tftp,我這裡先留著,因為我要實現大量部署,應該需要這兩個東西。

2、設置並且安裝

為了只下載64位的系統,我們要修改配置文件,分別是/etc/maas/import_isos和/etc/maas/import_ephemerals

重點有一行,ARCHES單獨設置成"amd64",在一個文件中要設置TARBALL_CACHE_D,這個是工作目錄

把一開始下載的mini.iso做以下處理

root@lapvc:/home/maas# cp mini.iso /var/lib/cobbler/isos/precise-x86_64-mini.iso

然後開始下載:

root@lapvc:/home/maas# maas-import-isos

3、設置maas的web界面登錄帳號

root@lapvc:/etc/maas# maas createsuperuser

按照步驟設置完成即可

4、然後就可以訪問web了,地址是http://localhost/MAAS



二、你擁有網路的控制權
1、安裝12.04server版的ubuntu,下載地址http://gb.releases.ubuntu.com//precise/ubuntu-12.04-server-i386.iso

要選擇帶有MAAS的安裝,這樣的話伺服器會自動安裝apache2、dns、tftp、rabbitmq、dnsmasq,MAAS的界面用的是 Django 框架,它用本地資料庫來存儲所有管理結點,每個結點通過它的MAC唯一標識,大概介紹一下MAAS的工作流程:

a)把你當前虛擬機的MAC加入到MAAS

b)通過PXE啟動來控制你的結點

c)MAAS伺服器和結點之間通信

d)MAAS結點通過伺服器的DHCP伺服器獲取到一個ip地址,hostname(在web界面上可以看到)

e)MAAS結點選擇進入enlistment階段,這個階段伺服器要下載簡化的鏡像

f)這個階段會持續幾分鐘,然後這個結點會被關閉

g)然後PXE啟動會利用網路啟動,通過命令maas-import-isos可以下載,mini.iso直接被下載來放到Cobbler中,而其它的安裝文件通過網路或者是通過cache squid來獲取的

h)如果你機子上有wol(wake on lan)的話,通過MAAS就可以重啟結點,如果沒有的話需要手動,Cobbler將會載入配置文件preseed

i)接下來就是系統安裝,期間所有的日誌在/var/log/maas/rsyslog和/var/log/squid-deb-proxy/access.log中

這些是MAAS的主要工具,可以通過埠查看哪些進程沒有開啟:

* apache: 80
* squid: 8000//代理和web緩存
* dnsmasq: 53 & 67//dhcp
* sshd
* postgres: 5432 //資料庫
* mass-pserv: 5241
* maas-txlongpoll: 5432
* epmd: 4369
* rabbitmq:
* rsyslog: udp 514
* tftpd: 69
* cobbler: 25151

kickstart文件位置/var/lib/cobbler/kickstarts/maas.preseed
snippets文件位置/var/lib/cobbler/snippets/maas_disable_pxe //防止下次機子啟動時候依舊從PXE啟動

查看cobbler的幾個命令   23  cobbler repo list
   24  cobbler repo help
   25  cobbler repo report
   26  cobbler profile list
   27  cobbler profile repor

2、安裝完以後可以選擇更換網路設置,通過以下命令

root@lapvc:/etc/maas# sudo dpkg-reconfigure maas

3、創建管理者用戶
root@lapvc:/etc/maas# maas createsuperuser
4、安裝DHCP伺服器
root@lapvc:/etc/maas# apt-get install maas-dhcp
注意,服務中的dnsmasq為該服務,包括了DNS,DHCP的服務
5、下載安裝模板,下載前最好配置一下配置文件/etc/maas/import_ephemerals,配置方式如上面第一種方式裡面提到的一樣
root@lapvc:/etc/maas# maas-import-isos
6、登錄網頁http://hostname/MAAS,
7、添加結點

控制結點從網路啟動,類似通過上文提到的PXE啟動來安裝系統,總的來說有三種方式

a) 通過PXE安裝系統,然後加入到maas的dashboard中,PXE中介紹過了,就不多介紹了

b)通過MAAS的網路介面,直接把虛擬機加入到dashboard中,然後啟動,這個測試通過了

c)通過Ubuntu的伺服器,暫時沒做測試

注意:加入到dashboard列表后,不要給結點裝操作系統,一會juju會提示你如何自動啟動並安裝的,結點加入到MAAS后,會顯示成"Decleard"狀態,然後配置結點啟動方式為wol,然後accept&commssion該結點,再啟動結點,這時候結點會顯示成"Ready"狀態。

8、接下來就可以可以開始juju了,介紹下juju
juju的安裝 : root@ubuntu:/var/log/maas# apt-get install juju
編輯juju的配置文件: environments:root@ubuntu:~/maas# vim /root/.juju/environments.yaml
maas:
type: maas
maas-server: 'http://10.217.12.151:80/MAAS'
maas-oauth: 在你頁面上找的MAAS key

admin-secret: ''
default-series: precise
生成sshkey:root@ubuntu:~/maas# ssh-keygen//生成的公鑰放到dashboard中
重啟juju: root@ubuntu:~/maas# juju bootstrap//在這個過程中,將會為所有的node裝操作系統

root@ubuntu:/var/log# chmod 600 /root/.juju/environments.yaml



啟動選擇maas-enlist,配置文件:/var/lib/cobbler/config/profiles.d/maas-enlist.json

maas工程位置:/usr/share/maas/maas

maas代碼清單http://packages.ubuntu.com/zh-cn/precise/all/maas/filelist

參考文章
http://hi.baidu.com/chenshake/item/59c044fe49c3c6ef1b111ff8

https://wiki.edubuntu.org/SecurityTeam/TestingMAAS

http://www.sebastien-han.fr/blog/2012/05/04/maasive-round-2/

出現錯誤,有一個官網的錯誤中心,可以先到裡面看看:https://wiki.ubuntu.com/ServerTeam/MAAS/Troubleshooting

1、Unable to create Node: Commissioning script is missing: etc/maas/commissioning-user-data

從log中分析

File "/usr/lib/python2.7/dist-packages/maasserver/models.py", line 617, in start_commissioning
"Commissioning script is missing: %s" % path)

很明顯是參數path的路徑不存在,我在/etc/maas/下發現了相應文件,重啟后該問題自動解決了,有待細查

2、在VirtualBox中切換tty可以使用Ctrl+Alt+F2

3、直接安裝后的原文件中在tftpboot下的default文件中,所有路徑是絕對路徑,不知到什麼問題,然後就是Cobbler自帶的tftp伺服器如何重啟啊,糾結!

經過測試,可以通過tftp客戶端get到絕對路徑的文件,所以該路徑沒問題

4、虛擬機的默認登錄方式是ssh ubuntu@{address}、在這之前需要把本地的公鑰上傳到網站上用戶名下面的preferences的sshkey公鑰中(未解決)

參考問題9

5、通過回復模式進入裝系統的機子后,更改root密碼出現錯誤:passwd: Authentication token manipulation error

6、exceptions.TypeError: an integer is required
Unexpected TimeoutError interacting with provider: User timeout caused connection failure.
2012-07-20 18:44:51,950 ERROR Unexpected TimeoutError interacting with provider: User timeout caused connection failure.

這個錯誤是因為在juju的配置文件中,maas-server的ip地址後面需要加入埠,默認是80

7、今天發現juju在查看狀態的時候,只默認查看之前一個錯誤的結點,所以我就將該結點刪除,刪除的方式是用maas shell工具,生成maasserver.models中Node類的對象node node=Node.objects.get(hostname='name'),再調用node的delete()方法就可以刪除。但是當結點狀態不正確的時候無法刪除,但是這裡有一個BUG,因為它是先刪除了mac地址,但是該node的詳細信息無法刪除(我認為要麼都能刪,要麼mac都不能刪除).我調用shell flush的時候出現一個BUG,和這個問題描述一樣,現在還沒有解決https://bugs.launchpad.net/ubuntu/+source/maas/+bug/1005482

8、juju bootstrap啟動錯誤:Unexpected Error interacting with provider: 409 CONFLICT該錯誤是因為juju找不到node的緣故,再次重啟機器,安裝完系統即可。

問題解決:http://marcoceppi.com/2012/05/juju-maas-virtualbox/

9、The authenticity of host 'node-0800271db357.local (10.217.12.91)' can't be established.
ECDSA key fingerprint is 15:8b:8e:ef:30:b5:b1:75:c2:68:2e:9a:7e:e2:0a:be.
Are you sure you want to continue connecting (yes/no)? yes
2012-07-24 14:20:30,190 ERROR Invalid SSH key
2012-07-24 14:20:53,829 ERROR Invalid SSH key
還是公鑰使用錯誤。。。。原應找到,是因為它的ks文件

/var/lib/cobbler/kickstarts/maas.preseed中使用的用戶是ubuntu,而我生成的公私鑰對是以root省份生成的,所以當以ubuntu的身份登錄的時候可以直接登錄,而且登錄后可以直接sudo su切換到root,然後更改root密碼!

10、執行ssh-add時候出錯:Could not open a connection to your authentication agent.

ssh-agemt bash --login -i //清除當前私鑰
《解決方案》

我很喜歡,太精彩了
《解決方案》

tulip0425 發表於 2012-08-11 03:45 static/image/common/back.gif
我很喜歡,太精彩了

謝謝了,歡迎大家多多交流,我也是看了陳沙克老師的博客轉過來的
《解決方案》

這個安裝是通過網路方式安裝是吧,安裝時,是從公網下載安裝文件還是人mass伺服器下載安裝文件?
另外,這個可以同步相關的配置文件到客戶端么?
《解決方案》

lxw2016 發表於 2012-08-14 17:31 static/image/common/back.gif
這個安裝是通過網路方式安裝是吧,安裝時,是從公網下載安裝文件還是人mass伺服器下載安裝文件?
另外,這 ...

首先,有一個官方的錯誤解答:https://wiki.ubuntu.com/ServerTeam/MAAS/Troubleshooting


1、Unable to create Node: Commissioning script is missing: etc/maas/commissioning-user-data

從log中分析

File "/usr/lib/python2.7/dist-packages/maasserver/models.py", line 617, in start_commissioning
"Commissioning script is missing: %s" % path)

很明顯是參數path的路徑不存在,我在/etc/maas/下發現了相應文件,重啟后該問題自動解決了,有待細查

2、在VirtualBox中切換tty可以使用Ctrl+Alt+F2

3、直接安裝后的原文件中在tftpboot下的default文件中,所有路徑是絕對路徑,經過測試,可以通過tftp客戶端get到絕對路徑的文件,所以該路徑沒問題

4、exceptions.TypeError: an integer is required
Unexpected TimeoutError interacting with provider: User timeout caused connection failure.
2012-07-20 18:44:51,950 ERROR Unexpected TimeoutError interacting with provider: User timeout caused connection failure.

這個錯誤是因為在juju的配置文件中,maas-server的ip地址後面需要加入埠,默認是80

5、刪除節點的方式用maas shell工具,生成maasserver.models中Node類的對象node node=Node.objects.get(hostname='name'),再調用node的delete()方法就可以刪除。但是當結點狀態不正確的時候無法刪除,但是這裡有一個BUG,因為它是先刪除了mac地址,但是該node的詳細信息無法刪除(我認為要麼都能刪,要麼mac都不能刪除).我調用shell flush的時候出現一個BUG,和這個問題描述一樣,現在還沒有解決https://bugs.launchpad.net/ubuntu/+source/maas/+bug/1005482

6、juju bootstrap啟動錯誤:Unexpected Error interacting with provider: 409 CONFLICT

該錯誤是因為juju找不到node的緣故,再次重啟機器,安裝完系統即可。

問題解決:http://marcoceppi.com/2012/05/juju-maas-virtualbox/

7、The authenticity of host 'node-0800271db357.local (10.217.12.91)' can't be established.
ECDSA key fingerprint is 15:8b:8e:ef:30:b5:b1:75:c2:68:2e:9a:7e:e2:0a:be.
Are you sure you want to continue connecting (yes/no)? yes
2012-07-24 14:20:30,190 ERROR Invalid SSH key
2012-07-24 14:20:53,829 ERROR Invalid SSH key
還是公鑰使用錯誤。。。。原應找到,是因為它的ks文件

/var/lib/cobbler/kickstarts/maas.preseed中使用的用戶是ubuntu,而我生成的公私鑰對是以root省份生成的,所以當以ubuntu的身份登錄的時候可以直接登錄,而且登錄后可以直接sudo su切換到root,然後更改root密碼!

8、執行ssh-add時候出錯:Could not open a connection to your authentication agent.

ssh-agemt bash --login -i //清除當前私鑰

9、Maas無法使用本地源或者本地的iso文件

需要修改兩處配置文件,1是要修改/var/lib/cobbler/snippets/maas_proxy,2是maas_preseed,修改過程我就不說了,關鍵地方修改結果如下:
d-i     mirror/protocol  string http
d-i     mirror/country   string manual
d-i     mirror/http/hostname string http地址
d-i     mirror/http/directory string /ubuntu
d-i     mirror/http/proxy string
d-i     clock-setup/ntp-server  string 鏡像源

d-i     apt-setup/security_host string 鏡像源
d-i     apt-setup/security_path string /ubuntu
d-i     mirror/http/directory string /ubuntu
d-i     mirror/http/proxy string
10、Failed To Process Preconfiguration File
有2個可能,源文件出問題了,重新下載源,或者http伺服器有問題,要麼下載許可權不夠,要麼防火牆沒留出80埠

11、preseed最後添加的shell腳本的執行問題,如果你寫的shell裡面有for循環,而ubuntu操作系統默認安裝的是dash,會出問題,所以改成如下:

chmod +x ./my.sh; chroot ./ bash my.sh

12、用自己源的時候出錯

DEBUG: command: wget -q http://Yourownsource/ubuntu/dists/precise/Release -O - | grep -E '^(Suite|Codename):'

INFO: mirror does not have any suite symlinkse

這個問題是因為指定國家時候錯了,換成manual,有時候你多換幾個,不同地方不一樣

13、 binary-amd64/Packages was corrupt      

到相應位置查看該文件,如果不存在,直接touch就可以了

14、使用virtualbox查看啟動信息無法按Ctrl+Alt+F4,可以按右Ctrl+F4,因為右Ctrl=Ctrl+Alt

15、CD-ROM couldn't be mounted是因為default文件寫錯了,需要把initrd.gz和linux指定到i386/amd64下面的文件才行

16、總是無法dhcp到地址

確定你的dhcp伺服器沒有問題的情況下,可以考慮一個原因,因為ubuntu的iso文件自帶了2個內核文件和2個根系統文件,而install/netboot/ubuntu-installer/amd64/linux的內核鏡像和install/netboot/ubuntu-installer/amd64/initrd.gz才可以有網路,另一組是不能配置網路的,所以要指定對文件

17、cobbler check的時候出錯

可以去log裡面看,是因為dnsmasq沒啟動的問題,但是不管你有沒有起,都報這個錯,所以是MAAS的一個自身錯誤

18、Failed to process the preconfiguration file

這個是因為preseed文件出錯了,改對就行了

19、在分區的時候提示要手動確定格式化

這個是因為在preseed文件中沒有指定自動確定格式化的配置,主要包括3行

d-i     partman-lvm/device_remove_lvm boolean true  //如果原磁碟文件上有LVM分區
d-i     partman-md/device_remove_md boolean true  //對於之前磁碟上有軟RAID
d-i     partman-lvm/confirm boolean true //確認覆蓋lvm

20、出現以下錯誤:

The partitiontable format in use on your disks normally requieres youto create a separatepartition for boot loader code.This partition should be marked for use as "Reserved BIOSbootarea" and should be at least 1 MB in size. Notethat this is not the same as a partitionmounted on /boot.

If you do not go backtothe partitioning menu and correct this error, boot loader installationmay fail later, although it may still be possibleto installthe boot loaderto a partition.

出現原因很簡單,因為分區出問題了,但是解決方案到現在都沒有很好的方法,只是找到一種默認把所有盤劃分到一個盤下的方法:

d-i     partman-auto/choose_recipe  select atomic
d-i     partman/choose_partition        select Finish partitioning and write changes to disk
d-i     partman/confirm boolean true
d-i     partman/confirm_nooverwrite boolean true
d-i     partman/default_filesystem string ext4

單獨給BIOS加入一段地址,這個方法容易造成gurb安裝失敗

   brtfs::                                               
              1   1   1  free                                 
                      $gptonly{ } $primary{ } $bios_boot{ }   
                      method{biosgrub }                       
              .
21、出現經常DHCP不到ip地址

解決方案有2個,一是換dnsmasq(需要配置2個文件/etc/dnsmasq.conf和/etc/cobler/modules.conf),二是清除/var/lib/dhcpd/下的租約文件

22、DHCP無法安裝的問題

  從pkgs.org下載相應的rpm包文件,然後rpm –Uvh強制安裝

23、No root file systemis defined. Pleasecorrect this from the partitioningmenu

是因為分區的時候少分一個區 /

[火星人 ] Ubuntu12.04的自動化部署工具MAAS學習筆記已經有2884次圍觀

http://coctec.com/docs/service/show-post-526.html