众所周知,甲骨文的ARM机有24G内存,这么大内存不如生点小鸡玩。而且甲骨文重装系统什么的比较麻烦,开小鸡可以用来随便折腾,不怕把宿主机搞坏了。
本来打算在上面折腾下kvm套娃的,后来发现母鸡没开嵌套虚拟化,那就没戏了。只能玩玩容器虚拟化了。
不过说实话,这个LXD用起来还真挺舒服的,后面详细说说。这里先把配置步骤记录一下。
咱用的系统是Debian10,如果你用的是别的系统,可以先按这篇文章重装一个:https://lala.im/7905.html
装snapd,然后用snap安装lxd:
apt -y update apt -y install snapd snap install lxd
注:安装完之后退出终端,重新登录一次。
执行下面的命令初始化:
lxd init
整个流程如下,除了存储后端的配置选择dir,其他的全部回车保持默认即可:
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]: Name of the storage backend to use (ceph, btrfs, dir, lvm) [default=btrfs]: dir 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]: 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]:
[重要]如果你的机器上安装了docker,docker往iptables里面自动添加的规则会导致lxd的容器没网,执行下面的命令修复:
iptables -A FORWARD -o lxdbr0 -j ACCEPT iptables -A FORWARD -i lxdbr0 -j ACCEPT
如果要删除上面的规则:
iptables -D FORWARD -o lxdbr0 -j ACCEPT iptables -D FORWARD -i lxdbr0 -j ACCEPT
现在就可以开一台小鸡了,首先查找你需要的系统镜像,这里我以opensuse为例:
lxc image list images: | grep opensuse
选择一个镜像创建小鸡,格式如下:
lxc launch images:[发行版]/[版本号]/[架构] [实例名]
比如说开一个opensuse15.2:
lxc launch images:opensuse/15.2/arm64 opensuse
进入你的小鸡:
lxc exec opensuse bash
简单测试一下网络:
下面是一些常用的管理命令:
lxc list # 列出所有小鸡的运行状态 lxc storage list # 列出存储信息 lxc start opensuse # 启动 lxc stop opensuse # 停止 lxc restart opensuse # 重启 lxc delete opensuse # 删除
你也可以限制小鸡的cpu和内存使用:
lxc config set opensuse limits.cpu=2 # 限制cpu lxc config set opensuse limits.memory=512MB # 限制内存 lxc config unset opensuse limits.cpu # 解除cpu限制 lxc config unset opensuse limits.memory # 解除内存限制
这里介绍一个lxd非常牛逼的功能,它可以把小鸡内的服务直接暴露出来。例如我在opensuse小鸡内先起一个nginx:
zypper in nginx systemctl start nginx
然后在宿主机上执行如下命令,添加一个名为nginx的proxy设备:
lxc config device add opensuse nginx proxy listen=tcp:0.0.0.0:55555 connect=tcp:127.0.0.1:80
检查宿主机的55555端口:
curl -I localhost:55555
可以看到nginx服务的回显:
HTTP/1.1 403 Forbidden Server: nginx/1.16.1 Date: Thu, 03 Jun 2021 12:20:31 GMT Content-Type: text/html Content-Length: 153 Connection: keep-alive
列出你给当前小鸡添加的设备:
lxc config device list opensuse
如果要删除刚才添加的proxy设备:
lxc config device remove opensuse nginx
文章最后,说说为啥我说lxd其实很好用。首先是安装用snap很简单,配置起来基本也是一路回车即可。。。
而且官方还提供了大量的系统镜像,几乎涵盖所有的linux发行版。。可以说你想用哪个,拉一个镜像下来启动就行了。并且还支持快照,可以随时给机器打快照。。
从lxd4.0开始其实还支持真正意义上的小鸡:虚拟机。基于kvm的。不过由于甲骨文的母鸡没嵌套我就没折腾了。
lala,聊天室换域名了没?上不去喽
首页好像没有进入的入口了。
以前右边栏有个绿色的入口
现在也有的,连接的是旧域名,我待会改过来。如果你浏览器没显示的话,估计是被广告拦截的插件屏蔽了。。。
今天刚换。。新的域名是:chat.233.fi
大佬大佬,能不能帮忙出一个甲骨文ARM架构,ubuntu系统装远程桌面的教程?感谢。怎么安装都装不了,看大佬有没有办法指导下,谢谢。
我现在开的arm机没有用ubuntu系统的,我不可能删了重新开吧。。而且现在也开不出来新机了。。
执行 snap install lxd就报错了:
error: cannot perform the following tasks:
– Mount snap “lxd” (20642) (snap “lxd” assumes unsupported features: snapd2.39 (try to update snapd and refresh the core snap))
执行下面的命令后再装一次lxd应该就可以了:
snap install core
snap refresh core
我也是这样,华为云之前圈的钱 提不出来 今天买了台学生机,发现是arm的 想起这篇教程,最后报错和你的一样
大佬,啥时候用lxd4.0搞NAT vm?
大佬,小鸡没网络怎么解决呀?
root@armubuntu:~# 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]: no
Would you like to connect to a MAAS server? (yes/no) [default=no]: 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]: none
Would you like the LXD server to be available over the network? (yes/no) [default=no]:
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]:
root@armubuntu:~# lxc launch ubuntu:21.04 myubuntu
root@armubuntu:~# lxc list
+———-+———+——+——+———–+———–+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+———-+———+——+——+———–+———–+
| myubuntu | RUNNING | | | CONTAINER | 0 |
+———-+———+——+——+———–+———–+
root@armubuntu:~# ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: mtu 9000 qdisc mq state UP group default qlen 1000
link/ether 02:00:17:00:94:df brd ff:ff:ff:ff:ff:ff
inet 10.0.0.237/24 brd 10.0.0.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::17ff:fe00:94df/64 scope link
valid_lft forever preferred_lft forever
3: docker0: mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:84:ad:b1:60 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:84ff:fead:b160/64 scope link
valid_lft forever preferred_lft forever
32: lxdbr0: mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:81:22:50 brd ff:ff:ff:ff:ff:ff
inet 10.24.86.1/24 scope global lxdbr0
valid_lft forever preferred_lft forever
inet6 fe80::216:3eff:fe81:2250/64 scope link
valid_lft forever preferred_lft forever
34: vethf07e6f57@if33: mtu 1500 qdisc noqueue master lxdbr0 state UP group default qlen 1000
link/ether 9a:59:c2:ba:c2:e4 brd ff:ff:ff:ff:ff:ff link-netnsid 0
root@armubuntu:~# lxc config show myubuntu -e
architecture: aarch64
config:
image.architecture: arm64
image.description: ubuntu 21.04 arm64 (release) (20210928)
image.label: release
image.os: ubuntu
image.release: hirsute
image.serial: “20210928”
image.type: squashfs
image.version: “21.04”
volatile.base_image: bdc589b60084bb18611836cdefa6e96a0dec8dc96a8a313827e4c426524c6853
volatile.eth0.host_name: vethf07e6f57
volatile.eth0.hwaddr: 00:16:3e:56:38:41
volatile.idmap.base: “0”
volatile.idmap.current: ‘[{“Isuid”:true,”Isgid”:false,”Hostid”:1000000,”Nsid”:0,”Maprange”:1000000000},{“Isuid”:false,”Isgid”:true,”Hostid”:1000000,”Nsid”:0,”Maprange”:1000000000}]’
volatile.idmap.next: ‘[{“Isuid”:true,”Isgid”:false,”Hostid”:1000000,”Nsid”:0,”Maprange”:1000000000},{“Isuid”:false,”Isgid”:true,”Hostid”:1000000,”Nsid”:0,”Maprange”:1000000000}]’
volatile.last_state.idmap: ‘[{“Isuid”:true,”Isgid”:false,”Hostid”:1000000,”Nsid”:0,”Maprange”:1000000000},{“Isuid”:false,”Isgid”:true,”Hostid”:1000000,”Nsid”:0,”Maprange”:1000000000}]’
volatile.last_state.power: RUNNING
volatile.uuid: 98be8b39-0a2c-471b-8cf5-d785a03897ac
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
ephemeral: false
profiles:
– default
stateful: false
description: “”
谢谢大佬!
防火墙的问题吧,甲骨文的机器默认有很多iptables规则,清空了再试试看。