免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 23265 | 回复: 4
打印 上一主题 下一主题

[其他] Ubuntu12.04的自动化部署工具MAAS学习笔记 [复制链接]

论坛徽章:
8
亥猪
日期:2014-02-09 10:55:252015小元宵徽章
日期:2015-03-06 15:57:20数据库技术版块每日发帖之星
日期:2015-06-08 22:20:00综合交流区版块每日发帖之星
日期:2015-06-14 22:20:002015亚冠之阿尔沙巴布
日期:2015-09-01 20:23:45IT运维版块每日发帖之星
日期:2015-09-04 06:20:00IT运维版块每日发帖之星
日期:2015-11-04 06:20:00IT运维版块每日发帖之星
日期:2015-12-04 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-08-08 09:29 |只看该作者 |倒序浏览
首先下载包mini.iso

http://mirrors.sohu.com/ubuntu/d ... ent/images/netboot/

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

https://maas.ubuntu.com/images/e ... e/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//p ... .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 //清除当前私钥

论坛徽章:
0
2 [报告]
发表于 2012-08-11 03:45 |只看该作者
我很喜欢,太精彩了

论坛徽章:
8
亥猪
日期:2014-02-09 10:55:252015小元宵徽章
日期:2015-03-06 15:57:20数据库技术版块每日发帖之星
日期:2015-06-08 22:20:00综合交流区版块每日发帖之星
日期:2015-06-14 22:20:002015亚冠之阿尔沙巴布
日期:2015-09-01 20:23:45IT运维版块每日发帖之星
日期:2015-09-04 06:20:00IT运维版块每日发帖之星
日期:2015-11-04 06:20:00IT运维版块每日发帖之星
日期:2015-12-04 06:20:00
3 [报告]
发表于 2012-08-14 13:27 |只看该作者
tulip0425 发表于 2012-08-11 03:45
我很喜欢,太精彩了


谢谢了,欢迎大家多多交流,我也是看了陈沙克老师的博客转过来的

论坛徽章:
0
4 [报告]
发表于 2012-08-14 17:31 |只看该作者
这个安装是通过网络方式安装是吧,安装时,是从公网下载安装文件还是人mass服务器下载安装文件?
另外,这个可以同步相关的配置文件到客户端么?

论坛徽章:
8
亥猪
日期:2014-02-09 10:55:252015小元宵徽章
日期:2015-03-06 15:57:20数据库技术版块每日发帖之星
日期:2015-06-08 22:20:00综合交流区版块每日发帖之星
日期:2015-06-14 22:20:002015亚冠之阿尔沙巴布
日期:2015-09-01 20:23:45IT运维版块每日发帖之星
日期:2015-09-04 06:20:00IT运维版块每日发帖之星
日期:2015-11-04 06:20:00IT运维版块每日发帖之星
日期:2015-12-04 06:20:00
5 [报告]
发表于 2012-11-04 20:11 |只看该作者
lxw2016 发表于 2012-08-14 17:31
这个安装是通过网络方式安装是吧,安装时,是从公网下载安装文件还是人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

是因为分区的时候少分一个区 /
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP