MAAS for ubuntu

安装MAAS

目前还是不建议使用snap, 一个是因为国内环境网络经常不通上代理只能上一部分,第二就是安装没有进度中断后需要abort 才能继续安装.

==2021-8-30更新
使用一个月后还是要用snap…, apt 安装的maas 虽然版本一样但是功能运行总是出现奇奇怪怪的问题…==

==2021-9-16更新
lxc exec 没办法进入安装centos的虚拟机,明明宣传支持就是连接不上,换成ubuntu 一切又都好了==

1
2
3
4
5
6
# in root user or add sudo
#apt-add-repository ppa:maas/3.0
#apt install maas -y

snap install maas

打开网页

http://192.168.2.150:5240/MAAS/
没有账号会提示使用sudo maas createadmin创建账号

创建账号

You will need to create a MAAS administrator user to access the web UI:

1
2
3
4
5
sudo maas createadmin --username=admin --email=574779754@qq.com --password=111111

#报错fe_sendauth: no password supplied,运行如下命令:
sudo snap install maas-test-db
sudo maas init region+rack --database-uri maas-test-db:///

验证状态
maas status
输出output如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#这是使用apt安装的
#bind9 RUNNING pid 7999, uptime 0:09:17
#dhcpd STOPPED Not started
#dhcpd6 STOPPED Not started
#ntp RUNNING pid 8598, uptime 0:05:42
#postgresql RUNNING pid 8001, uptime 0:09:17
#proxy STOPPED Not started
#rackd RUNNING pid 8000, uptime 0:09:17
#regiond:regiond-0 RUNNING pid 8003, uptime 0:09:17
#regiond:regiond-1 RUNNING pid 8008, uptime 0:09:17
#regiond:regiond-2 RUNNING pid 8005, uptime 0:09:17
#regiond:regiond-3 RUNNING pid 8015, uptime 0:09:17
#tgt RUNNING pid 8040, uptime 0:09:15


#这是使用snap 安装的
bind9 RUNNING pid 1952, uptime 0:06:24
dhcpd STOPPED Not started
dhcpd6 STOPPED Not started
http RUNNING pid 2241, uptime 0:05:28
ntp RUNNING pid 2129, uptime 0:05:37
proxy RUNNING pid 2297, uptime 0:05:23
rackd RUNNING pid 1956, uptime 0:06:24
regiond RUNNING pid 1957, uptime 0:06:24
syslog RUNNING pid 2102, uptime 0:05:38

生产环境使用参考

使用webUI登录操作
http://192.168.2.150:5240/MAAS/

LXD

snap install lxd --channel=latest/stable

首次使用运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]: lxd
Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]:
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]:
Size in GB of the new loop device (1GB minimum) [default=30GB]: 300GB
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like the LXD server to be available over the network? (yes/no) [default=no]: yes
Address to bind LXD to (not including port) [default=all]:
Port to bind LXD to [default=8443]:
Trust password for new clients:
Again:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: yes

### 安装文件在 /var/snap/lxd/common/lxd/disks/default.img
lxc storage list
查看文件具体位置
lxd shutdown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
config:
core.https_address: '[::]:8443'
core.trust_password: "111111"
networks:
- config:
ipv4.address: auto
ipv6.address: auto
description: ""
name: lxdbr0
type: ""
project: default
storage_pools:
- config:
size: 300GB
description: ""
name: lxd
driver: zfs
profiles:
- config: {}
description: ""
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: lxd
type: disk
name: default
projects: []
cluster: null

创建虚拟机

1
2
3
4
5
6
7
8
# 列出支持x86_64 CPU的所有ubuntu
lxc image list ubuntu: amd64

f: ubuntu 20.04 LTS amd64 (release) (20210819)
x: ubuntu 16.04 LTS amd64 (release) (20210429)
lxc launch ubuntu: f dev1
# 新版本
lxc launch ubuntu:20.04 dev1

连接MAAS

参考

1
2
lxc config set core.https_address :8443
lxc config set core.trust_password 111111

删除lxcbr0

1
2
3
4
#需要卸载lxd lxc
apt remove lxd lxc -y
apt autoremove -y