第 3 章: LXD 初始化和用户设置¶
在本章中,您需要以 root 身份或能够使用 sudo
成为 root。此外,假设您已经设置了 第 2 章 中描述的 ZFS 存储池。如果您选择不使用 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]:
金属即服务 (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