PVE基础配置
-
合并硬盘分区
1.1 删除local-lvmlvremove pve/data
1.2 扩容local
lvextend -l +100%FREE -r pve/root
1.3 然后数据中心进行图形界面的local-lvm删除和local编辑。
-
确认网络是否正常
ping www.baidu.com 如果ping不通,修改网关和dns。
-
更换软件源
https://mirrors.tuna.tsinghua.edu.cn/help/debian/nano /etc/apt/sources.list
添加网页上的内容,保存退出。
建议全部修改成清华源:deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
-
修改pve源
4.1 添加清华源
https://mirrors.tuna.tsinghua.edu.cn/help/proxmox/nano /etc/apt/sources.list.d/pve-no-subscription.list 加入内容 deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
4.2 去掉企业源
nano /etc/apt/sources.list.d/pve-enterprise.list 前面加入#
4.3 去掉ceph源(有需要的可以之后自行修改)
nano /etc/apt/sources.list.d/ceph.list 前面加入#
PVE更新--存储库里面添加pve-no-subscription
-
去掉登录弹窗:
sed -i.backup -z "s/res === null || res === undefined || \!res || res\n\t\t\t.data.status.toLowerCase() \!== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service
-
更新软件源,升级软件
apt update apt upgrade -y
-
开启IPV6(可选)
nano /etc/sysctl.conf
添加如下内容:
net.ipv6.conf.all.accept_ra=2 net.ipv6.conf.default.accept_ra=2 net.ipv6.conf.vmbr0.accept_ra=2 net.ipv6.conf.all.autoconf=1 net.ipv6.conf.default.autoconf=1 net.ipv6.conf.vmbr0.autoconf=1
重启系统:reboot
问题
docker: Error response from daemon: AppArmor enabled on system but the docker-default profile could not be loaded: running `/usr/sbin/apparmor_parser apparmor_parser -Kr /var/lib/docker/tmp/docker-default1737324594` failed with output: apparmor_parser: Unable to replace "docker-default". Permission denied; attempted to load a profile while confined?
error: exit status 243.
使用特权模式运行docker
docker run -itd --restart=always --privileged --name=webman -p 8787:8787 -v /mnt/www/mfan:/app php8webman:latest
老虎pve_source一键脚本
加速CT Templates下载
https://mirror.tuna.tsinghua.edu.cn/help/proxmox/
如果你需要加速 Proxmox 网页端下载 CT Templates,可以替换 CT Templates 的源。
具体方法:将 /usr/share/perl5/PVE/APLInfo.pm
文件中默认的源地址 http://download.proxmox.com
替换为
https://mirrors.tuna.tsinghua.edu.cn/proxmox
可以使用如下命令修改:
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
针对 /usr/share/perl5/PVE/APLInfo.pm
文件的修改,重启服务后生效。
systemctl restart pvedaemon.service
PVE中lxc容器中运行docker容器报错
Error response from daemon: AppArmor enabled on system but the docker-default profile could not be loaded: running `/usr/sbin/apparmor_parser apparmor_parser -Kr /var/lib/docker/tmp/docker-default962894337` failed with output: apparmor_parser: Unable to replace "docker-default". Permission denied; attempted to load a profile while confined?
error: exit status 243
Error: failed to start containers: openresty
出现这个错误的原因是系统启用了AppArmor安全模块,但docker-default配置文件无法被加载。以下是一些解决方法:
临时解决方案
- 禁用AppArmor:这是最简单直接的方法,但会降低系统的安全性。可以使用命令
sudo apt-get remove apparmor
来禁用AppArmor,然后再次尝试运行Docker容器。 - 使用特权模式运行容器:Docker的特权模式允许容器获得更多的系统资源和服务,从而为应用程序提供必要的权限以与AppArmor更好地兼容。可以使用命令
docker run --privileged ...
来运行容器,但请注意这会带来安全风险
其他可能的解决方案
-
修改LXC配置:如果是PVE环境下,可以进入PVC终端找到lxc配置文件,如
/etc/pve/lxc/100.conf
,添加以下配置:lxc.apparmor.profile: unconfined lxc.cgroup2.devices.allow: a lxc.cap.drop:
推荐的 Docker 镜像加速地址
根据网络环境的不同,您可以选择以下一个或多个镜像加速地址:
- 1Panel 镜像代理:
https://proxy.1panel.live
- 1Panel Docker 加速器:
https://docker.1panel.top
- DaoCloud 官方加速器:
https://docker.m.daocloud.io
- 1ms.run Docker 加速器:
https://docker.1ms.run
- Ketches.cn Docker 加速器:
https://docker.ketches.cn
终端命令添加 Docker 镜像加速
要配置 Docker 使用这些加速地址,您可以按照如下步骤操作:
-
编辑 /etc/docker/daemon.json 文件
将以下内容写入
/etc/docker/daemon.json
文件中(对于 root 用户,可以省略sudo
):echo '{ "registry-mirrors": [ "https://docker.1panelproxy.com", "https://proxy.1panel.live", "https://docker.1panel.top", "https://docker.m.daocloud.io", "https://docker.1ms.run", "https://docker.ketches.cn" ] }' | sudo tee /etc/docker/daemon.json
-
重启 Docker 服务
为了让新的配置生效,需要重启 Docker 服务:
sudo systemctl daemon-reload && sudo systemctl restart docker
-
验证配置是否成功
您可以通过运行
docker info
命令来检查配置是否生效。如果输出信息中包含Registry Mirrors
字段,并且列出了上述的镜像地址,则说明配置已经成功。
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。