第 3 章:LXD 初始化和用户设置¶
在本章中,您需要以 root 用户身份或能够通过 sudo
成为 root 用户。此外,假设您已经设置了 ZFS 存储池,这在 第 2 章 中已进行了描述。如果您选择不使用 ZFS,也可以使用其他存储池,但需要调整初始化时的问题和答案。
LXD 初始化¶
您的服务器环境已全部设置完毕。您已准备好初始化 LXD。这是一个自动脚本,它会提出一系列问题,以使您的 LXD 实例启动并运行。
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]:
这似乎有些违反直觉。您已经创建了 ZFS 池,但稍后会有一个问题会说明原因。接受默认值。
Name of the new storage pool [default=default]: storage
将此设置为“默认”也是一个选项,但为了清晰起见,使用您为 ZFS 池指定的名称更好。
Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]:
您应该接受默认值。
Create a new ZFS pool? (yes/no) [default=yes]: no
这就是前面关于创建存储池的问题如何发挥作用的地方。
Name of the existing ZFS pool or dataset: storage
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Metal As A Service (MAAS) 超出了本文档的范围。
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
如果您想在 LXD 容器中使用 IPv6,可以启用此选项。这取决于您。
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]:
设置用户权限¶
在继续之前,您需要创建“lxdadmin”用户并确保其拥有所需的权限。您需要“lxdadmin”用户能够通过 sudo
成为 root 用户,并且它需要是 lxd 组的成员。要添加用户并确保其同时是这两个组的成员,请执行以下操作:
useradd -G wheel,lxd lxdadmin
设置密码
passwd lxdadmin
与之前的密码一样,将此密码保存在安全的位置。
作者:Steven Spencer
贡献者:Ezequiel Bruni, Ganna Zhyrnova