PVE 系列之二:安装基于 LXC 的容器

基于 LXC 的容器

CT模板换源

注意版本是否适配

cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm

重启服务。

systemctl restart pvedaemon.service

下载模板

  1. 数据中心 -> pve -> local -> CT模板 ,点击 模板
  2. 选中合适的模板,进行下载。

创建CT

点击 创建CT

  • 常规。

    CT ID : 102 。(记住,用于备份)

    主机名:Docker 。

    无特权的容器:不勾选。(可用于远程共享文件夹)

    密码:example 。

    确认密码:example 。

  • 模板。

    存储: local

    模板:选择下载好的模板。

  • 磁盘。

    存储:local-lvm

    确认所选存储是否有足够的空间,否则先去创建新存储。

    磁盘大小(GB):50 。

  • CPU。

    核心:4 。

  • 内存。

    内存(MiB): 2048 。

    交换分区(MiB): 2048 。

  • 网络。

    名称 eth0 IP 静态
    MAC地址 auto IPv4/CIDR 192.168.1.2/24
    桥接 vmbr0 网关 192.168.1.1
    VLAN标签 no VLAN IPv6 SLAAC
    速率限制 unlimited IPv6/CIDR
    防火墙 勾选
  • DNS。

    DNS域:192.168.1.1。

  • 下一步完成。

配置核显

如果 LXC 容器不需要使用核显进行视频编解码等,可以不设置这一部分。

在 PVE Shell 中。

  • 编辑配置文件。

    nano /etc/pve/lxc/[CT_ID].conf
    
  • 加入硬件参数配置:(可先用 ls -l /dev/dri 查询)

    参考: 【司波图】2022版通用型PVE_AIO服务器布局教程(中)

    lxc.cgroup2.devices.allow: c 226:0 rwm
    lxc.cgroup2.devices.allow: c 226:128 rwm
    lxc.cgroup2.devices.allow: c 29:0 rwm
    lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
    lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
    lxc.apparmor.profile: unconfined
    

    lxc.cgroup2.devices.allow: c 29:0 rwm :说是增缓冲的设置。

    lxc.apparmor.profile: unconfined :用于关闭 LXC 容器的apparmor保护,开启状态无法安装 Docker 。

  • 开启 LXC 虚拟机。

  • 检查核显直通。

    在 LXC Shell 中。

    cd /dev/dri
    ls
    

N5105

若宿主机为 N5105 的物理机,则需要额外配置。

在 PVE Shell 中。

  • 配置文件。

    nano /etc/default/grub
    
  • 加入:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on i915.enable_guc=3"
    

    intel_iommu=on :允许硬件直通。

    i915.enable_guc=3 :允许编解码器。

  • 更新重启 PVE。

    update-grub
    reboot
    
  • 确认是否开启。

    dmesg | grep -iE "guc|huc"
    
  • 若未开启,则更新内核。

    curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | apt-key add -
    echo "deb https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" > /etc/apt/sources.list.d/pve-edge-kernel.list
    
    apt update
    apt install pve-kernel-5.17-edge -y
    
    reboot
    

    视频说:5.18 版本需要同步更新 GUC 固件,有可能造成一定的兼容新问题。

换源

在 LXC Shell 中。

  • 配置文件。

    mv /etc/apt/sources.list /etc/apt/sources.list.bk
    nano /etc/apt/sources.list
    
  • 内容:

    注意版本。

    deb https://mirrors.ustc.edu.cn/debian/ bullseye main non-free contrib
    deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main non-free contrib
    deb https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main
    deb-src https://mirrors.ustc.edu.cn/debian-security/ bullseye-security main
    deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main non-free contrib
    deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main non-free contrib
    deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main non-free contrib
    deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main non-free contrib
    
  • 更新。

    apt update
    apt upgrade
    

安装雷池 WAF

安装雷池 WAF ,直接默认安装 Docker 。

请参考: Debian 安装雷池 WAF(SafeLine)+计划+DDNS - Yogile - 博客园 (cnblogs.com)

内网保护

设置 Debian IPv4 为 192.168.1.2 ,网关为 192.168.1.1

设置内网设备静态 IPv4 信息,指向 192.168.1.1 即可。

IP地址 192.168.1.3
掩码 255.255.255.0
网关 192.168.1.2
DNS 服务器 192.168.1.1
posted @ 2023-11-29 22:03  Yogile  阅读(1180)  评论(0编辑  收藏  举报